netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
To: Mike Manning <mmanning@vyatta.att-mail.com>,
	netdev@vger.kernel.org, roopa@cumulusnetworks.com
Subject: Re: [PATCH net-next v2 5/5] bridge: update vlan dev link state for bridge netdev changes
Date: Thu, 18 Apr 2019 14:45:24 +0300	[thread overview]
Message-ID: <4d1e2530-d87b-ba43-258b-bb8082846d55@cumulusnetworks.com> (raw)
In-Reply-To: <20190417181629.5791-6-mmanning@vyatta.att-mail.com>

On 17/04/2019 21:16, Mike Manning wrote:
> If vlan bridge binding is enabled, then the link state of a vlan device
> that is an upper device of the bridge tracks the state of bridge ports
> that are members of that vlan. But this can only be done when the link
> state of the bridge is up. If it is down, then the link state of the
> vlan devices must also be down. This is to maintain existing behavior
> for when STP is enabled and there are no live ports, in which case the
> link state for the bridge and any vlan devices is down.
> 
> Signed-off-by: Mike Manning <mmanning@vyatta.att-mail.com>
> ---
>  net/bridge/br_vlan.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 47 insertions(+), 3 deletions(-)
> 
> diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> index 89146a5f0c23..2db63997f313 100644
> --- a/net/bridge/br_vlan.c
> +++ b/net/bridge/br_vlan.c
> @@ -1343,6 +1343,11 @@ static void br_vlan_set_vlan_dev_state(const struct net_bridge *br,
>  	struct net_bridge_port *p;
>  	bool has_carrier = false;
>  
> +	if (!netif_carrier_ok(br->dev)) {
> +		netif_carrier_off(vlan_dev);
> +		return;
> +	}
> +
>  	list_for_each_entry(p, &br->port_list, list) {
>  		vg = nbp_vlan_group(p);
>  		if (br_vlan_find(vg, vid) && br_vlan_is_dev_up(p->dev)) {
> @@ -1367,10 +1372,12 @@ static void br_vlan_set_all_vlan_dev_state(struct net_bridge_port *p)
>  		vlan_dev = br_vlan_get_upper_bind_vlan_dev(p->br->dev,
>  							   vlan->vid);
>  		if (vlan_dev) {
> -			if (br_vlan_is_dev_up(p->dev))
> -				netif_carrier_on(vlan_dev);
> -			else
> +			if (br_vlan_is_dev_up(p->dev)) {
> +				if (netif_carrier_ok(p->br->dev))
> +					netif_carrier_on(vlan_dev);
> +			} else {
>  				br_vlan_set_vlan_dev_state(p->br, vlan_dev);
> +			}
>  		}
>  	}
>  }
> @@ -1393,6 +1400,34 @@ static void br_vlan_upper_change(struct net_device *dev,
>  	}
>  }
>  
> +struct br_vlan_link_state_walk_data {
> +	struct net_bridge *br;
> +};
> +
> +static int br_vlan_link_state_change_fn(struct net_device *vlan_dev,
> +					void *data_in)
> +{
> +	struct br_vlan_link_state_walk_data *data = data_in;
> +
> +	if (br_vlan_is_bind_vlan_dev(vlan_dev))
> +		br_vlan_set_vlan_dev_state(data->br, vlan_dev);
> +
> +	return 0;
> +}
> +
> +static void br_vlan_link_state_change(struct net_device *dev,
> +				      struct net_bridge *br)
> +{
> +	struct br_vlan_link_state_walk_data data = {
> +		.br = br
> +	};
> +
> +	rcu_read_lock();
> +	netdev_walk_all_upper_dev_rcu(dev, br_vlan_link_state_change_fn,
> +				      &data);
> +	rcu_read_unlock();
> +}
> +
>  /* Must be protected by RTNL. */
>  static void nbp_vlan_set_vlan_dev_state(struct net_bridge_port *p, u16 vid)
>  {
> @@ -1411,12 +1446,21 @@ void br_vlan_bridge_event(struct net_device *dev, unsigned long event,
>  			  void *ptr)
>  {
>  	struct netdev_notifier_changeupper_info *info;
> +	struct net_bridge *br;
>  
>  	switch (event) {
>  	case NETDEV_CHANGEUPPER:
>  		info = ptr;
>  		br_vlan_upper_change(dev, info->upper_dev, info->linking);
>  		break;
> +
> +	case NETDEV_CHANGE:
> +	case NETDEV_UP:
> +		br = netdev_priv(dev);
> +		if (!br_opt_get(br, BROPT_VLAN_BRIDGE_BINDING))
> +			return;
> +		br_vlan_link_state_change(dev, br);
> +		break;
>  	}
>  }
>  
> 

Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>


  reply	other threads:[~2019-04-18 11:45 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 ` [PATCH net-next v2 4/5] bridge: update vlan dev state when port added to or deleted from vlan Mike Manning
2019-04-18 11:41   ` 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 [this message]
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=4d1e2530-d87b-ba43-258b-bb8082846d55@cumulusnetworks.com \
    --to=nikolay@cumulusnetworks.com \
    --cc=mmanning@vyatta.att-mail.com \
    --cc=netdev@vger.kernel.org \
    --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).