From patchwork Mon Jun 6 12:58:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 630882 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 3rNZXC3qLqz9t5l for ; Mon, 6 Jun 2016 22:59:07 +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=ecIt2YmQ; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 7FF90B92007; Mon, 6 Jun 2016 14:58:46 +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 14:58:46 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id ED6E6B91FFE for ; Mon, 6 Jun 2016 14:58:43 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -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 14:58:43 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id m124so15194016wme.3 for ; Mon, 06 Jun 2016 05:58: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=/PNvmvCKooQrQ8QJC6tHTBnAXPjA16QDGGpg1lX173E=; b=ecIt2YmQeT1ZIeI2P4Lfns8Aa2KKnEUz02cDYK21bOsTAjGacMKm6zjl4KO8TbhZUt Par5h1uupJCYdvT25n0YtOOcdAWoExsr+3xJFGaKEQ91tev5o8jHMfMr5t8zCCzXHYIC 66KzUltaUq8fGewD4la42YrlY744O0zQ0J0rsbyloDCABmHlReH22VQ5x5cSOOebPr++ xpf329SOWr+OXDEeXW3+j9Dd7PHQtXDFfaoHliqVtLu5BvitYiiME8PQ8CddbjzpCxI3 tuu6xeGlJJUOkH1OFn+9cSa9XsBD6yWDuPGZ2SvSSLH54882IEHKAOKY3VzPmH9xLptG BxYg== 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=/PNvmvCKooQrQ8QJC6tHTBnAXPjA16QDGGpg1lX173E=; b=U2v7RHnpqV2KwGsVo9xVMdebAL3XJprjciBmPYe64EJDkWeSsZEPsjTkIoCdxSCPcT i9mU1oNvIepFwGrC2S7PbFwR2lVlIUsIgYaNOJ5+uOiyKNuJDW8nFyRLt+nVC0b8kQcB suVU3IZpqkKmsMrfGRFoc4/bWLYroxLUPJy4/QLRrarB51PbX3QPdhPgTOvLHoDTjfzI DIcQg4yBjNIhEmrP1+7gKOkBAEgsnjkheENkPUn6q4UxexGLoly+S04hr2KXHNORuuI+ pZxIdCuELKYKJl5HpOavkf2quvmI5IE7f6kG92SMM1yGd8afy8MQoyEvhVZbdpBW/x2r qUFQ== X-Gm-Message-State: ALyK8tKafyjzkPDqdI3PmZ+1QOY9iW3fOY8viUbtUHE0PRve0LdX0MGtu3H4E8HWsNTb5g== X-Received: by 10.28.188.7 with SMTP id m7mr11324652wmf.18.1465217923184; Mon, 06 Jun 2016 05:58:43 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id b189sm14127828wmh.5.2016.06.06.05.58.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 05:58:42 -0700 (PDT) From: Hans Dedecker To: lede-dev@lists.infradead.org, openwrt-devel@lists.openwrt.org Date: Mon, 6 Jun 2016 14:58:32 +0200 Message-Id: <1465217913-20861-2-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465217913-20861-1-git-send-email-dedeckeh@gmail.com> References: <1465217913-20861-1-git-send-email-dedeckeh@gmail.com> Subject: [OpenWrt-Devel] [PATCH v2 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 --- v1 -> v2 : Remove extra white line in cb_rtnl_event 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 | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/device.c b/device.c index a4d804e..fa3d00f 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..eb785b5 100644 --- a/system-linux.c +++ b/system-linux.c @@ -495,7 +495,7 @@ 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;