From patchwork Tue Sep 1 12:43:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 512808 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 2CD0C14056B for ; Tue, 1 Sep 2015 22:45:57 +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=qEPNZ/AD; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 51B7128C67A; Tue, 1 Sep 2015 14:43:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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 version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id C9F5728C66D for ; Tue, 1 Sep 2015 14:43:27 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -8.5 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Tue, 1 Sep 2015 14:43:27 +0200 (CEST) Received: by wicjd9 with SMTP id jd9so31813230wic.1 for ; Tue, 01 Sep 2015 05:44:25 -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=AutDkiyDP43r2ddqUZzUHNl4PH3g9VcQFUCoLvpgI/Y=; b=qEPNZ/AD3V7oPw3l0g2gMTS2dWCIdZzxd1UqcZOMH3KayPHcH53KJynvWLIK4I75eV dVf3qc6lClv5eIVIr9fTF+p2kKLycOcwQBfJmrVAr3RBori/xrkQAl+F8V8y1UnmQSkQ t1dEVyiUA0ObLqxSpx6zSd2vXTokDL/9wRmsMpHCK8o+BA63+xkiKhY+ZzmN+D5KaiDk M7llbmW/JE/Ozy33sRPDCiCT5b4DsFDXGU1ALvwBJ1u9Ag8nc2CZVmtnlT+wWqDklzbB mQj4IJJchVHvoL7+jwvV8e+Cju4OL2LxcjwF3NBq+vev98Q1I79PqQfV9DLA3cLaGxmY YiCA== X-Received: by 10.195.18.5 with SMTP id gi5mr35790439wjd.0.1441111465600; Tue, 01 Sep 2015 05:44:25 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id im10sm27036529wjb.40.2015.09.01.05.44.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 05:44:24 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Tue, 1 Sep 2015 14:43:58 +0200 Message-Id: <1441111438-30921-2-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441111438-30921-1-git-send-email-dedeckeh@gmail.com> References: <1441111438-30921-1-git-send-email-dedeckeh@gmail.com> Cc: Hans Dedecker , cyrus@openwrt.org Subject: [OpenWrt-Devel] [PATCH 2/2] netifd: Don't call set_state for external device in device_claim X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" The function set_state disable is not called for external devices in device_release which means for external vlan/macvlan devices they won't be deleted. As a result of this the set_state enable call for external devices by device_claim fails as vlan/macvlan devices cannot be created since the device already exists in the kernel. Therefore move the external device check from device_set_state to device_claim so external vlan/macvlan devices are not created again and can also be external. Signed-off-by: Hans Dedecker --- device.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/device.c b/device.c index 0d73138..21b436f 100644 --- a/device.c +++ b/device.c @@ -81,9 +81,6 @@ static int set_device_state(struct device *dev, bool state) return -1; } - if (dev->external) - return 0; - if (state) system_if_up(dev); else @@ -324,7 +321,7 @@ void device_broadcast_event(struct device *dev, enum device_event ev) int device_claim(struct device_user *dep) { struct device *dev = dep->dev; - int ret; + int ret = 0; if (dep->claimed) return 0; @@ -335,7 +332,9 @@ int device_claim(struct device_user *dep) return 0; device_broadcast_event(dev, DEV_EVENT_SETUP); - ret = dev->set_state(dev, true); + if (!dev->external) + ret = dev->set_state(dev, true); + if (ret == 0) device_broadcast_event(dev, DEV_EVENT_UP); else {