mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
To: Horatiu Vultur <horatiu.vultur@microchip.com>,
	davem@davemloft.net, jiri@resnulli.us, ivecera@redhat.com,
	kuba@kernel.org, roopa@cumulusnetworks.com, olteanv@gmail.com,
	andrew@lunn.ch, UNGLinuxDriver@microchip.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	bridge@lists.linux-foundation.org
Subject: Re: [PATCH net-next v3 11/11] net: bridge: Add checks for enabling the STP.
Date: Fri, 24 Apr 2020 16:20:35 +0300	[thread overview]
Message-ID: <2d97fea6-8f24-89ba-a97b-99a12cf41b09@cumulusnetworks.com> (raw)
In-Reply-To: <20200422161833.1123-12-horatiu.vultur@microchip.com>

On 22/04/2020 19:18, Horatiu Vultur wrote:
> It is not possible to have the MRP and STP running at the same time on the
> bridge, therefore add check when enabling the STP to check if MRP is already
> enabled. In that case return error.
> 
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
>  net/bridge/br_ioctl.c    |  3 +--
>  net/bridge/br_netlink.c  |  4 +++-
>  net/bridge/br_private.h  |  3 ++-
>  net/bridge/br_stp.c      |  6 ++++++
>  net/bridge/br_stp_if.c   | 11 ++++++++++-
>  net/bridge/br_sysfs_br.c |  4 +---
>  6 files changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
> index ae22d784b88a..5e71fc8b826f 100644
> --- a/net/bridge/br_ioctl.c
> +++ b/net/bridge/br_ioctl.c
> @@ -242,8 +242,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
>  		if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
>  			return -EPERM;
>  
> -		br_stp_set_enabled(br, args[1]);
> -		ret = 0;
> +		ret = br_stp_set_enabled(br, args[1], NULL);
>  		break;
>  
>  	case BRCTL_SET_BRIDGE_PRIORITY:
> diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
> index 1a5e681a626a..a774e19c41bb 100644
> --- a/net/bridge/br_netlink.c
> +++ b/net/bridge/br_netlink.c
> @@ -1109,7 +1109,9 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
>  	if (data[IFLA_BR_STP_STATE]) {
>  		u32 stp_enabled = nla_get_u32(data[IFLA_BR_STP_STATE]);
>  
> -		br_stp_set_enabled(br, stp_enabled);
> +		err = br_stp_set_enabled(br, stp_enabled, extack);
> +		if (err)
> +			return err;
>  	}
>  
>  	if (data[IFLA_BR_PRIORITY]) {
> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> index 5835828320b6..c35647cb138a 100644
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -1283,7 +1283,8 @@ int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time);
>  /* br_stp_if.c */
>  void br_stp_enable_bridge(struct net_bridge *br);
>  void br_stp_disable_bridge(struct net_bridge *br);
> -void br_stp_set_enabled(struct net_bridge *br, unsigned long val);
> +int br_stp_set_enabled(struct net_bridge *br, unsigned long val,
> +		       struct netlink_ext_ack *extack);
>  void br_stp_enable_port(struct net_bridge_port *p);
>  void br_stp_disable_port(struct net_bridge_port *p);
>  bool br_stp_recalculate_bridge_id(struct net_bridge *br);
> diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
> index 1f14b8455345..3e88be7aa269 100644
> --- a/net/bridge/br_stp.c
> +++ b/net/bridge/br_stp.c
> @@ -36,6 +36,12 @@ void br_set_state(struct net_bridge_port *p, unsigned int state)
>  	};
>  	int err;
>  
> +	/* Don't change the state of the ports if they are driven by a different
> +	 * protocol.
> +	 */
> +	if (p->flags & BR_MRP_AWARE)
> +		return;
> +
>  	p->state = state;
>  	err = switchdev_port_attr_set(p->dev, &attr);
>  	if (err && err != -EOPNOTSUPP)
> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
> index d174d3a566aa..a42850b7eb9a 100644
> --- a/net/bridge/br_stp_if.c
> +++ b/net/bridge/br_stp_if.c
> @@ -196,10 +196,17 @@ static void br_stp_stop(struct net_bridge *br)
>  	br->stp_enabled = BR_NO_STP;
>  }
>  
> -void br_stp_set_enabled(struct net_bridge *br, unsigned long val)
> +int br_stp_set_enabled(struct net_bridge *br, unsigned long val,
> +		       struct netlink_ext_ack *extack)
>  {
>  	ASSERT_RTNL();
>  
> +	if (br_mrp_enabled(br)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "STP can't be enabled if MRP is already enabled\n");

The operation could be disable (noop in case it's already disabled) and this will still
return an error.

> +		return -EINVAL;
> +	}
> +
>  	if (val) {
>  		if (br->stp_enabled == BR_NO_STP)
>  			br_stp_start(br);
> @@ -207,6 +214,8 @@ void br_stp_set_enabled(struct net_bridge *br, unsigned long val)
>  		if (br->stp_enabled != BR_NO_STP)
>  			br_stp_stop(br);
>  	}
> +
> +	return 0;
>  }
>  
>  /* called under bridge lock */
> diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
> index 9ab0f00b1081..7db06e3f642a 100644
> --- a/net/bridge/br_sysfs_br.c
> +++ b/net/bridge/br_sysfs_br.c
> @@ -126,9 +126,7 @@ static ssize_t stp_state_show(struct device *d,
>  
>  static int set_stp_state(struct net_bridge *br, unsigned long val)
>  {
> -	br_stp_set_enabled(br, val);
> -
> -	return 0;
> +	return br_stp_set_enabled(br, val, NULL);
>  }
>  
>  static ssize_t stp_state_store(struct device *d,
> 


      reply	other threads:[~2020-04-24 13:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22 16:18 [PATCH net-next v3 00/11] net: bridge: mrp: Add support for Media Redundancy Protocol(MRP) Horatiu Vultur
2020-04-22 16:18 ` [PATCH net-next v3 01/11] bridge: uapi: mrp: Add mrp attributes Horatiu Vultur
2020-04-24 13:11   ` Nikolay Aleksandrov
2020-04-22 16:18 ` [PATCH net-next v3 02/11] bridge: mrp: Update Kconfig Horatiu Vultur
2020-04-24 13:11   ` Nikolay Aleksandrov
2020-04-22 16:18 ` [PATCH net-next v3 03/11] bridge: mrp: Extend bridge interface Horatiu Vultur
2020-04-24 13:11   ` Nikolay Aleksandrov
2020-04-22 16:18 ` [PATCH net-next v3 04/11] net: bridge: Add port attribute IFLA_BRPORT_MRP_RING_OPEN Horatiu Vultur
2020-04-24 13:12   ` Nikolay Aleksandrov
2020-04-22 16:18 ` [PATCH net-next v3 05/11] bridge: mrp: Add MRP interface Horatiu Vultur
2020-04-24 13:13   ` Nikolay Aleksandrov
2020-04-22 16:18 ` [PATCH net-next v3 06/11] switchdev: mrp: Extend switchdev API to offload MRP Horatiu Vultur
2020-04-22 16:18 ` [PATCH net-next v3 07/11] bridge: switchdev: mrp: Implement MRP API for switchdev Horatiu Vultur
2020-04-22 16:18 ` [PATCH net-next v3 08/11] bridge: mrp: Connect MRP API with the switchdev API Horatiu Vultur
2020-04-24 13:47   ` Nikolay Aleksandrov
2020-04-25  8:57     ` Horatiu Vultur
2020-04-22 16:18 ` [PATCH net-next v3 09/11] bridge: mrp: Implement netlink interface to configure MRP Horatiu Vultur
2020-04-22 16:18 ` [PATCH net-next v3 10/11] bridge: mrp: Integrate MRP into the bridge Horatiu Vultur
2020-04-24 13:49   ` Nikolay Aleksandrov
2020-04-22 16:18 ` [PATCH net-next v3 11/11] net: bridge: Add checks for enabling the STP Horatiu Vultur
2020-04-24 13:20   ` Nikolay Aleksandrov [this message]

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=2d97fea6-8f24-89ba-a97b-99a12cf41b09@cumulusnetworks.com \
    --to=nikolay@cumulusnetworks.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=horatiu.vultur@microchip.com \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.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

all inboxes | Powered by JetHome®