From patchwork Tue Oct 25 09:08:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 686381 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 3t36lL2Kqsz9svs for ; Tue, 25 Oct 2016 20:08:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=CvMUiQFu; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 6C2EDB8045F; Tue, 25 Oct 2016 11:08:41 +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; Tue, 25 Oct 2016 11:08:41 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 48FACB8045A for ; Tue, 25 Oct 2016 11:08:40 +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 ; Tue, 25 Oct 2016 11:08:39 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id d128so621825wmf.0 for ; Tue, 25 Oct 2016 02:08:39 -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; bh=itErglQAfuiHqTmQ3h1CvSSZMCFW3HpMlfRfAdw2MBE=; b=CvMUiQFug0p0td8hm1r5yhcJsnXAvqQndyd2314vlqOGjAoshpyTIRkvRPUZ5/cQyz D6BdwdaagOjcw+NGy7npANOf0tyu6aufelE29NgxfD9acbGmMY+GISWPZgDeL0wTcmxB U1BOwcxOgOImLiuT03R57DOXPVDCz+DBkL2LajfSpy/TkYZ/P1NqKv0/oAXRutW8HkZb R0VidT9Pd8SCy3fCzlVGdfRyqqhrpOb9cBhKExSQ4NcXsxe7ppH5b2Ta75plwx8j15Sk 6IcTLN5TzWFkbFAp6mA7R0kzqs+GlVoJ03bbY28Q+Ta+3dEfbICOzXZYHlSDR+EUfrpx LB+A== 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; bh=itErglQAfuiHqTmQ3h1CvSSZMCFW3HpMlfRfAdw2MBE=; b=EtlOMEtGSjkD/a68ECRHoqkkN94Sg7sgP5LzsvJVVmSIvUH/7ezl63XMQR7Na4ZmNV 5k/XOnttmNzA8D1bMLG14I0cI00yd8amuODFcMoFS73EdhwDmwuubrO99IplXvcaLJza MEvfnWcbcfi/H1gZNfAeCWU/T6qnAVEK4Qd0LMg0uQIhICmgd/vU6bCeVV8LhSayPGpt 6hrl0y5fNAzVvklYtEq0IKUYukjP2IkxsDToCXnbCbMQP0poCSGtlYXCsy8gKKEu4keU UIK2GXzq5cLeDj39zGLVhQL7AGajlo1A8DRX5n1OAocC+JBV2kPil3UO1Zd4774kXiQF IS5g== X-Gm-Message-State: ABUngvempCInpADVeN3noTSwSQzHAEvtSH//xpruM4ODbulvQ+DTZ6w0EpDA9Wq7QARfJA== X-Received: by 10.194.105.104 with SMTP id gl8mr17916707wjb.83.1477386519143; Tue, 25 Oct 2016 02:08:39 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id g17sm23825344wjs.38.2016.10.25.02.08.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 02:08:38 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org, lede-dev@lists.infradead.org, nbd@nbd.name Date: Tue, 25 Oct 2016 11:08:33 +0200 Message-Id: <1477386514-3336-1-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [OpenWrt-Devel] [PATCH netifd 1/2] bridge: Don't use device name as bridge member name 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" The bridge name is a copy of the device name; but the device name can change which is the case when an aliased interface is used as bridge member. This will result into unwanted side effects like bridge reload triggering a topology change effect after doing network reload; therefore use the configured ifname as fixed bridge member name. Also don't display bridge member devices which are hidden Signed-off-by: Hans Dedecker --- bridge.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bridge.c b/bridge.c index 8e6c9a6..30fd58d 100644 --- a/bridge.c +++ b/bridge.c @@ -394,24 +394,25 @@ bridge_set_state(struct device *dev, bool up) } static struct bridge_member * -bridge_create_member(struct bridge_state *bst, struct device *dev, bool hotplug) +bridge_create_member(struct bridge_state *bst, const char *name, + struct device *dev, bool hotplug) { struct bridge_member *bm; - bm = calloc(1, sizeof(*bm) + strlen(dev->ifname) + 1); + bm = calloc(1, sizeof(*bm) + strlen(name) + 1); if (!bm) return NULL; bm->bst = bst; bm->dev.cb = bridge_member_cb; bm->dev.hotplug = hotplug; - strcpy(bm->name, dev->ifname); + strcpy(bm->name, name); bm->dev.dev = dev; vlist_add(&bst->members, &bm->node, bm->name); // Need to look up the bridge member again as the above // created pointer will be freed in case the bridge member // already existed - bm = vlist_find(&bst->members, dev->ifname, bm, node); + bm = vlist_find(&bst->members, name, bm, node); if (hotplug && bm) bm->node.version = -1; @@ -455,7 +456,7 @@ bridge_add_member(struct bridge_state *bst, const char *name) if (!dev) return; - bridge_create_member(bst, dev, false); + bridge_create_member(bst, name, dev, false); } static int @@ -463,7 +464,7 @@ bridge_hotplug_add(struct device *dev, struct device *member) { struct bridge_state *bst = container_of(dev, struct bridge_state, dev); - bridge_create_member(bst, member, true); + bridge_create_member(bst, member->ifname, member, true); return 0; } @@ -523,8 +524,12 @@ bridge_dump_info(struct device *dev, struct blob_buf *b) system_if_dump_info(dev, b); list = blobmsg_open_array(b, "bridge-members"); - vlist_for_each_element(&bst->members, bm, node) + vlist_for_each_element(&bst->members, bm, node) { + if (bm->dev.dev->hidden) + continue; + blobmsg_add_string(b, NULL, bm->dev.dev->ifname); + } blobmsg_close_array(b, list); }