From patchwork Fri Sep 23 13:08:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 674071 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sgYdR5hTPz9t14 for ; Fri, 23 Sep 2016 23:10:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=nPDfLNO5; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 8F93FB92D09; Fri, 23 Sep 2016 15:08:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Fri, 23 Sep 2016 15:08:52 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 3DFAAB92CDC for ; Fri, 23 Sep 2016 15:08:43 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -7 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 23 Sep 2016 15:08:43 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id l132so2735969wmf.1 for ; Fri, 23 Sep 2016 06:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=THcbH3onhyXP5A7cJF3XomhiJ9ciEbDt7lHXCIHgCKo=; b=nPDfLNO5kh5fE9fcrFKBFefZxhuggSZeTNBSrB6Fq8EgqMkXPO6tTsZ3fU9akmJr1J qDAJlxYpgsKPOXnCetlz+r2w6OkR5DHN000G0eVDBYs/vBwuNQ69O9XT36Y0c1w2ehX5 Xk5NqJG9Lv8rPctMgKTmxb8cwHhNs4N31CC1o71+wZ1nWeBfpb8kP1eGF8OE7KouTMLj y/zECj/oicZrMTkxvIL8BLh5H1XML9jYj6W4Nj/rWoREwPeha5MasBkyp4R+rnB6sip4 VoetZIKpet8tvd/kDDFaBjgbajt5mZmWYxgBPynN/KLfwxxQ7WFT2y68svBFBuwMGY8j EWEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=THcbH3onhyXP5A7cJF3XomhiJ9ciEbDt7lHXCIHgCKo=; b=hKk50nJdNB/b9cY2ZPGja1a+CD9JY3Iug0jq34eHvBl7vqgkFN5hGx41ve03p5Aw4N /L7aDjyMXOLFcMFXHHmo0+hJpXRfci+FxXyn+UZDpClh3WpVKkPYcaMSK5uhzfXMlFMP Gj/rYN8XizvMBYio6d4oICEJqs75jTkzuWTS3smYhlI4YMGrkh042gayH/h/Zg6hrsSA ORCCqj4i09mYycspHEfYP/QmplV/bpVH+0Hfmop6UY/iGSnURBct4Ozs73M6/fSyXAhG TyJZrUsJmcYTBRJ5clMFTEqZl7ZeFlJ8jWzQL+12C6tkOqpEvTR/t/dW7c+w1jdZF1dU scaw== X-Gm-Message-State: AE9vXwNUZynhCSGPZOpw6HrYvMF1rcaS4MYRAv+Mcp0AlYzaSDD/DLVSLjGek96kWjNjww== X-Received: by 10.194.175.198 with SMTP id cc6mr6731565wjc.77.1474636122824; Fri, 23 Sep 2016 06:08:42 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id u124sm3069784wmu.10.2016.09.23.06.08.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Sep 2016 06:08:42 -0700 (PDT) From: Hans Dedecker To: nbd@nbd.name, lede-dev@lists.infradead.org, openwrt-devel@lists.openwrt.org Date: Fri, 23 Sep 2016 15:08:23 +0200 Message-Id: <1474636103-25093-7-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1474636103-25093-1-git-send-email-dedeckeh@gmail.com> References: <1474636103-25093-1-git-send-email-dedeckeh@gmail.com> Subject: [OpenWrt-Devel] [PATCH netifd 7/7] device: Drop device down event during device release if device gets active again X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Fixes a race condition as the device can be active again; due to a device_claim; by the logic behind the set_state device type function. In this case the down event cannot be sent anymore as it would bring down the interface(s) referencing the device. This can be the case for an aliased device when the underlying device is switched during a reload; the alias_set_device function can add a new dependency on the new active device which will put the aliased device in active mode again as the aliased device is already claimed by the interface using it. Signed-off-by: Hans Dedecker --- device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/device.c b/device.c index e17df13..996ffab 100644 --- a/device.c +++ b/device.c @@ -450,6 +450,10 @@ void device_release(struct device_user *dep) device_broadcast_event(dev, DEV_EVENT_TEARDOWN); if (!dev->external) dev->set_state(dev, false); + + if (dev->active) + return; + device_broadcast_event(dev, DEV_EVENT_DOWN); }