From: Stephen Hemminger <stephen@networkplumber.org>
To: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com,
davem@davemloft.net, bridge@lists.linux-foundation.org,
michael-dev <michael-dev@fami-braun.de>
Subject: Re: [PATCH net v4] net: bridge: move default pvid init/deinit to NETDEV_REGISTER/UNREGISTER
Date: Fri, 2 Aug 2019 08:35:19 -0700 [thread overview]
Message-ID: <20190802083519.71cb4fa2@hermes.lan> (raw)
In-Reply-To: <20190802105736.26767-1-nikolay@cumulusnetworks.com>
On Fri, 2 Aug 2019 13:57:36 +0300
Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:
> +int br_vlan_bridge_event(struct net_device *dev, unsigned long event, void *ptr)
> {
> struct netdev_notifier_changeupper_info *info;
> - struct net_bridge *br;
> + struct net_bridge *br = netdev_priv(dev);
> + bool changed;
> + int ret = 0;
>
> switch (event) {
> + case NETDEV_REGISTER:
> + ret = br_vlan_add(br, br->default_pvid,
> + BRIDGE_VLAN_INFO_PVID |
> + BRIDGE_VLAN_INFO_UNTAGGED |
> + BRIDGE_VLAN_INFO_BRENTRY, &changed, NULL);
> + break;
Looks good.
As minor optimization br_vlan_add could ignore changed pointer if NULL.
This would save places where you don't care.
Something like:
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 021cc9f66804..bacd3543b215 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -626,10 +626,11 @@ static int br_vlan_add_existing(struct net_bridge *br,
refcount_inc(&vlan->refcnt);
vlan->flags |= BRIDGE_VLAN_INFO_BRENTRY;
vg->num_vlans++;
- *changed = true;
+ if (changed)
+ *changed = true;
}
- if (__vlan_add_flags(vlan, flags))
+ if (__vlan_add_flags(vlan, flags) && changed)
*changed = true;
return 0;
@@ -653,7 +654,8 @@ int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags, bool *changed,
ASSERT_RTNL();
- *changed = false;
+ if (changed)
+ *changed = false;
vg = br_vlan_group(br);
vlan = br_vlan_find(vg, vid);
if (vlan)
@@ -679,7 +681,7 @@ int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags, bool *changed,
if (ret) {
free_percpu(vlan->stats);
kfree(vlan);
- } else {
+ } else if (changed) {
*changed = true;
}
next prev parent reply other threads:[~2019-08-02 15:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 18:36 [PATCH net] net: bridge: move vlan init/deinit to NETDEV_REGISTER/UNREGISTER Nikolay Aleksandrov
2019-07-31 22:37 ` [PATCH net v2] " Nikolay Aleksandrov
2019-07-31 22:40 ` Nikolay Aleksandrov
2019-07-31 22:49 ` [PATCH net v3] " Nikolay Aleksandrov
2019-07-31 22:53 ` Stephen Hemminger
2019-07-31 23:32 ` Nikolay Aleksandrov
2019-07-31 23:36 ` Nikolay Aleksandrov
2019-08-02 0:38 ` Nikolay Aleksandrov
2019-08-02 10:57 ` [PATCH net v4] net: bridge: move default pvid " Nikolay Aleksandrov
2019-08-02 14:29 ` Roopa Prabhu
2019-08-02 15:35 ` Stephen Hemminger [this message]
2019-08-02 15:41 ` Nikolay Aleksandrov
2019-08-05 20:33 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190802083519.71cb4fa2@hermes.lan \
--to=stephen@networkplumber.org \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=michael-dev@fami-braun.de \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).