From patchwork Mon Jun 6 10:03:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 630771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (caladan.dune.hu [78.24.191.180]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rNVfn1y0jz9t5R for ; Mon, 6 Jun 2016 20:04:33 +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=atoQLV2X; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id ECA94B9251B; Mon, 6 Jun 2016 12:04:10 +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; Mon, 6 Jun 2016 12:04:10 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 847ABB92516 for ; Mon, 6 Jun 2016 12:04:09 +0200 (CEST) X-policyd-weight: using cached result; rate: -7 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 6 Jun 2016 12:04:08 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id n184so15131345wmn.1 for ; Mon, 06 Jun 2016 03:04:08 -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=9AUQHnSoYP3v6SAGnZnZuN+QiakuPv1myEtJTdUgd58=; b=atoQLV2X3LAVDXku4fSlwtGuX3C/y6KwJ8+iYYbkWdrmESE+OmQEyS54pDWIgO0P45 dlmJNQrXBLmPw8jM+N8OkAPWmen9AdEN7j8lVieWv7gDtdW/GJ9DmyCT88ZdcyoNiIru iEvxNYTD00k5299ph2naBdNl8gJsldPEolsyXXJjlmqtr3fwt7Rmd6HIy0sQwoA7JHQY aFy7DUlXV2/IoQWj+LxxYPYdctis5TvJ3gv7A5rsP8E3vFh+Yu/4OSm6ed1+yAIB/iZz JFCLpRZUENK0BaHFnTQ1HICIPDhV6Y8u5qLMYjVQ1hc7cbByzAeHH/CltbJY3DpLBtnb ECYQ== 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=9AUQHnSoYP3v6SAGnZnZuN+QiakuPv1myEtJTdUgd58=; b=D/YNEx/MZcFMmr9uHRJIUA0r6oGfynYRC6N+zvG1HZY8IfZmV4XAPDyxoe9WTCLTc7 evgCohFTB1tM/DvX3Rg8POxXXI3RDt4c0D//RKRNZgiBdvFuGvUCwE1zl6RVaD47yD7H mEGDZLqGie99QE6lwsLlpFqFLD7A7oqJdgoA+dT4KdBM9hj64TwONG1CBLnQyWmxI+dc /I9HIQZHyY3doI568WPhO9USCaCsSwPeIu1xl+ZgU+9WrOBfFRMChlKwLNXqV/0zosFo STmYFJRFGqMqh8dIU1oIJVuDR8+iXeUo6/Qd9OdmPCSpHGJfEkqW0SEHtAXjuyzZnwWU J/gA== X-Gm-Message-State: ALyK8tLfiCLlFAwdF5Sq/GqEFeu9W83k2P5o3PCan/0Eg/Ap7BTI9e+Xmwhk7Y3I2NMZ7w== X-Received: by 10.28.194.4 with SMTP id s4mr11013633wmf.68.1465207448225; Mon, 06 Jun 2016 03:04:08 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id a199sm379839wma.2.2016.06.06.03.04.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 03:04:07 -0700 (PDT) From: Hans Dedecker To: lede-dev@lists.infradead.org, openwrt-devel@lists.openwrt.org Date: Mon, 6 Jun 2016 12:03:42 +0200 Message-Id: <1465207423-20413-2-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465207423-20413-1-git-send-email-dedeckeh@gmail.com> References: <1465207423-20413-1-git-send-email-dedeckeh@gmail.com> Subject: [OpenWrt-Devel] [PATCH netifd 2/3] device: Fix dotted vlan interface staying down 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 , steven@midlink.org MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Using the config below a dotted vlan interface stays down as get_vlan_device does not find the device due to the aliased device stacked on top of the base device. As all devices; aliased devices being the exception; are in the device list use device_find to find the device when setting the link state config interface 'test' option proto 'static' option ipaddr '192.168.2.1' option netmask '255.255.255.0' config interface 'test2' option ifname '@test.1' option proto 'dhcp' Signed-off-by: Hans Dedecker --- This fixes the issue reported in https://lists.openwrt.org/pipermail/openwrt-devel/2016-May/041323.html device.c | 8 ++++++++ device.h | 3 ++- system-linux.c | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/device.c b/device.c index 7149d86..45a9d07 100644 --- a/device.c +++ b/device.c @@ -477,6 +477,14 @@ device_create_default(const char *name, bool external) } struct device * +device_find(const char *name) +{ + struct device *dev; + + return avl_find_element(&devices, name, dev, avl); +} + +struct device * device_get(const char *name, int create) { struct device *dev; diff --git a/device.h b/device.h index b069a2b..e13e435 100644 --- a/device.h +++ b/device.h @@ -241,7 +241,8 @@ void device_set_default_ps(bool state); void device_init_virtual(struct device *dev, const struct device_type *type, const char *name); int device_init(struct device *iface, const struct device_type *type, const char *ifname); -void device_cleanup(struct device *iface); +void device_cleanup(struct device *dev); +struct device *device_find(const char *name); struct device *device_get(const char *name, int create); void device_add_user(struct device_user *dep, struct device *iface); void device_remove_user(struct device_user *dep); diff --git a/system-linux.c b/system-linux.c index 90b0775..98acb9d 100644 --- a/system-linux.c +++ b/system-linux.c @@ -495,10 +495,11 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) if (!nla[IFLA_IFNAME]) goto out; - struct device *dev = device_get(nla_data(nla[IFLA_IFNAME]), false); + struct device *dev = device_find(nla_data(nla[IFLA_IFNAME])); if (!dev) goto out; + if (!system_get_dev_sysctl("/sys/class/net/%s/carrier", dev->ifname, buf, sizeof(buf))) link_state = strtoul(buf, NULL, 0);