netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Manning <mmanning@vyatta.att-mail.com>
To: netdev@vger.kernel.org, nikolay@cumulusnetworks.com,
	roopa@cumulusnetworks.com
Subject: [PATCH net-next v2 4/5] bridge: update vlan dev state when port added to or deleted from vlan
Date: Wed, 17 Apr 2019 19:16:28 +0100	[thread overview]
Message-ID: <20190417181629.5791-5-mmanning@vyatta.att-mail.com> (raw)
In-Reply-To: <20190417181629.5791-1-mmanning@vyatta.att-mail.com>

If vlan bridge binding is enabled, then the link state of a vlan device
that is an upper device of the bridge should track the state of bridge
ports that are members of that vlan. So if a bridge port becomes or
stops being a member of a vlan, then update the link state of the
vlan device if necessary.

Signed-off-by: Mike Manning <mmanning@vyatta.att-mail.com>
---
 net/bridge/br_vlan.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index b903689a8fc5..89146a5f0c23 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -7,6 +7,8 @@
 #include "br_private.h"
 #include "br_private_tunnel.h"
 
+static void nbp_vlan_set_vlan_dev_state(struct net_bridge_port *p, u16 vid);
+
 static inline int br_vlan_cmp(struct rhashtable_compare_arg *arg,
 			      const void *ptr)
 {
@@ -293,6 +295,9 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
 
 	__vlan_add_list(v);
 	__vlan_add_flags(v, flags);
+
+	if (p)
+		nbp_vlan_set_vlan_dev_state(p, v->vid);
 out:
 	return err;
 
@@ -357,6 +362,7 @@ static int __vlan_del(struct net_bridge_vlan *v)
 		rhashtable_remove_fast(&vg->vlan_hash, &v->vnode,
 				       br_vlan_rht_params);
 		__vlan_del_list(v);
+		nbp_vlan_set_vlan_dev_state(p, v->vid);
 		call_rcu(&v->rcu, nbp_vlan_rcu_free);
 	}
 
@@ -1388,6 +1394,19 @@ static void br_vlan_upper_change(struct net_device *dev,
 }
 
 /* Must be protected by RTNL. */
+static void nbp_vlan_set_vlan_dev_state(struct net_bridge_port *p, u16 vid)
+{
+	struct net_device *vlan_dev;
+
+	if (!br_opt_get(p->br, BROPT_VLAN_BRIDGE_BINDING))
+		return;
+
+	vlan_dev = br_vlan_get_upper_bind_vlan_dev(p->br->dev, vid);
+	if (vlan_dev)
+		br_vlan_set_vlan_dev_state(p->br, vlan_dev);
+}
+
+/* Must be protected by RTNL. */
 void br_vlan_bridge_event(struct net_device *dev, unsigned long event,
 			  void *ptr)
 {
-- 
2.11.0


  parent reply	other threads:[~2019-04-17 18:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-17 18:16 [PATCH net-next v2 0/5] net: support binding vlan dev link state to vlan member bridge ports Mike Manning
2019-04-17 18:16 ` [PATCH net-next v2 1/5] vlan: support binding " Mike Manning
2019-04-18 11:25   ` Nikolay Aleksandrov
2019-04-17 18:16 ` [PATCH net-next v2 2/5] vlan: do not transfer link state in vlan bridge binding mode Mike Manning
2019-04-18 11:25   ` Nikolay Aleksandrov
2019-04-17 18:16 ` [PATCH net-next v2 3/5] bridge: support binding vlan dev link state to vlan member bridge ports Mike Manning
2019-04-18 11:28   ` Nikolay Aleksandrov
2019-04-18 14:42     ` Mike Manning
2019-04-17 18:16 ` Mike Manning [this message]
2019-04-18 11:41   ` [PATCH net-next v2 4/5] bridge: update vlan dev state when port added to or deleted from vlan Nikolay Aleksandrov
2019-04-17 18:16 ` [PATCH net-next v2 5/5] bridge: update vlan dev link state for bridge netdev changes Mike Manning
2019-04-18 11:45   ` Nikolay Aleksandrov
2019-04-18 11:43 ` [PATCH net-next v2 0/5] net: support binding vlan dev link state to vlan member bridge ports Nikolay Aleksandrov

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=20190417181629.5791-5-mmanning@vyatta.att-mail.com \
    --to=mmanning@vyatta.att-mail.com \
    --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).