public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: bridge: mst: Check vlan state for egress decision
@ 2024-07-05  3:00 Elliot Ayrey
  2024-07-05  6:19 ` Nikolay Aleksandrov
  2024-07-05 22:00 ` Tobias Waldekranz
  0 siblings, 2 replies; 4+ messages in thread
From: Elliot Ayrey @ 2024-07-05  3:00 UTC (permalink / raw)
  To: davem
  Cc: Elliot Ayrey, Roopa Prabhu, Nikolay Aleksandrov, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Tobias Waldekranz, bridge, netdev,
	linux-kernel

If a port is blocking in the common instance but forwarding in an MST
instance, traffic egressing the bridge will be dropped because the
state of the common instance is overriding that of the MST instance.

Fix this by temporarily forcing the port state to forwarding when in
MST mode to allow checking the vlan state via br_allowed_egress().
This is similar to what happens in br_handle_frame_finish() when
checking ingress traffic, which was introduced in the change below.

Fixes: ec7328b59176 ("net: bridge: mst: Multiple Spanning Tree (MST) mode")
Signed-off-by: Elliot Ayrey <elliot.ayrey@alliedtelesis.co.nz>
---
 net/bridge/br_forward.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index d97064d460dc..911b37a38a32 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -22,10 +22,16 @@ static inline int should_deliver(const struct net_bridge_port *p,
 				 const struct sk_buff *skb)
 {
 	struct net_bridge_vlan_group *vg;
+	u8 state;
+
+	if (br_mst_is_enabled(p->br))
+		state = BR_STATE_FORWARDING;
+	else
+		state = p->state;
 
 	vg = nbp_vlan_group_rcu(p);
 	return ((p->flags & BR_HAIRPIN_MODE) || skb->dev != p->dev) &&
-		p->state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&
+		state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&
 		nbp_switchdev_allowed_egress(p, skb) &&
 		!br_skb_isolated(p, skb);
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: bridge: mst: Check vlan state for egress decision
  2024-07-05  3:00 [PATCH net] net: bridge: mst: Check vlan state for egress decision Elliot Ayrey
@ 2024-07-05  6:19 ` Nikolay Aleksandrov
  2024-07-05 22:00 ` Tobias Waldekranz
  1 sibling, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2024-07-05  6:19 UTC (permalink / raw)
  To: Elliot Ayrey, davem
  Cc: Roopa Prabhu, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Tobias Waldekranz, bridge, netdev, linux-kernel

On 05/07/2024 06:00, Elliot Ayrey wrote:
> If a port is blocking in the common instance but forwarding in an MST
> instance, traffic egressing the bridge will be dropped because the
> state of the common instance is overriding that of the MST instance.
> 
> Fix this by temporarily forcing the port state to forwarding when in
> MST mode to allow checking the vlan state via br_allowed_egress().
> This is similar to what happens in br_handle_frame_finish() when
> checking ingress traffic, which was introduced in the change below.
> 
> Fixes: ec7328b59176 ("net: bridge: mst: Multiple Spanning Tree (MST) mode")
> Signed-off-by: Elliot Ayrey <elliot.ayrey@alliedtelesis.co.nz>
> ---
>  net/bridge/br_forward.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> index d97064d460dc..911b37a38a32 100644
> --- a/net/bridge/br_forward.c
> +++ b/net/bridge/br_forward.c
> @@ -22,10 +22,16 @@ static inline int should_deliver(const struct net_bridge_port *p,
>  				 const struct sk_buff *skb)
>  {
>  	struct net_bridge_vlan_group *vg;
> +	u8 state;

state = p->state
...

> +
> +	if (br_mst_is_enabled(p->br))
> +		state = BR_STATE_FORWARDING;

...
and you can drop the else clause

> +	else
> +		state = p->state;
>  
>  	vg = nbp_vlan_group_rcu(p);
>  	return ((p->flags & BR_HAIRPIN_MODE) || skb->dev != p->dev) &&
> -		p->state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&
> +		state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&
>  		nbp_switchdev_allowed_egress(p, skb) &&
>  		!br_skb_isolated(p, skb);
>  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: bridge: mst: Check vlan state for egress decision
  2024-07-05  3:00 [PATCH net] net: bridge: mst: Check vlan state for egress decision Elliot Ayrey
  2024-07-05  6:19 ` Nikolay Aleksandrov
@ 2024-07-05 22:00 ` Tobias Waldekranz
  2024-07-08  3:37   ` Elliot Ayrey
  1 sibling, 1 reply; 4+ messages in thread
From: Tobias Waldekranz @ 2024-07-05 22:00 UTC (permalink / raw)
  To: Elliot Ayrey, davem
  Cc: Elliot Ayrey, Roopa Prabhu, Nikolay Aleksandrov, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, bridge, netdev, linux-kernel

On fre, jul 05, 2024 at 15:00, Elliot Ayrey <elliot.ayrey@alliedtelesis.co.nz> wrote:
> If a port is blocking in the common instance but forwarding in an MST
> instance, traffic egressing the bridge will be dropped because the
> state of the common instance is overriding that of the MST instance.

Can't believe I missed this - thanks!

> Fix this by temporarily forcing the port state to forwarding when in
> MST mode to allow checking the vlan state via br_allowed_egress().
> This is similar to what happens in br_handle_frame_finish() when
> checking ingress traffic, which was introduced in the change below.
>
> Fixes: ec7328b59176 ("net: bridge: mst: Multiple Spanning Tree (MST) mode")
> Signed-off-by: Elliot Ayrey <elliot.ayrey@alliedtelesis.co.nz>
> ---
>  net/bridge/br_forward.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> index d97064d460dc..911b37a38a32 100644
> --- a/net/bridge/br_forward.c
> +++ b/net/bridge/br_forward.c
> @@ -22,10 +22,16 @@ static inline int should_deliver(const struct net_bridge_port *p,
>  				 const struct sk_buff *skb)
>  {
>  	struct net_bridge_vlan_group *vg;
> +	u8 state;
> +
> +	if (br_mst_is_enabled(p->br))
> +		state = BR_STATE_FORWARDING;
> +	else
> +		state = p->state;
>  
>  	vg = nbp_vlan_group_rcu(p);
>  	return ((p->flags & BR_HAIRPIN_MODE) || skb->dev != p->dev) &&

I think it might read a bit better if we model it like the hairpin check
above. I.e. (special_mode || regular_condition)

It's not really that the state is forwarding when mst is enabled, we
simply ignore the port-global state in that case.

> -		p->state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&
> +		state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&

so something like:

    ...
    (br_mst_is_enabled(p->br) || p->state == BR_STATE_FORWARDING) &&
    br_allowed_egress(vg, skb) && nbp_switchdev_allowed_egress(p, skb) &&
    ...

>  		nbp_switchdev_allowed_egress(p, skb) &&
>  		!br_skb_isolated(p, skb);
>  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: bridge: mst: Check vlan state for egress decision
  2024-07-05 22:00 ` Tobias Waldekranz
@ 2024-07-08  3:37   ` Elliot Ayrey
  0 siblings, 0 replies; 4+ messages in thread
From: Elliot Ayrey @ 2024-07-08  3:37 UTC (permalink / raw)
  To: tobias@waldekranz.com, davem@davemloft.net
  Cc: razor@blackwall.org, bridge@lists.linux.dev,
	linux-kernel@vger.kernel.org, kuba@kernel.org,
	netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	roopa@nvidia.com

On Sat, 2024-07-06 at 00:00 +0200, Tobias Waldekranz wrote:
> I think it might read a bit better if we model it like the hairpin check
> above. I.e. (special_mode || regular_condition)
> 
> It's not really that the state is forwarding when mst is enabled, we
> simply ignore the port-global state in that case.
> 
> > -		p->state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&
> > +		state == BR_STATE_FORWARDING && br_allowed_egress(vg, skb) &&
> 
> so something like:
> 
>     ...
>     (br_mst_is_enabled(p->br) || p->state == BR_STATE_FORWARDING) &&
>     br_allowed_egress(vg, skb) && nbp_switchdev_allowed_egress(p, skb) &&
>     ...

Yes you're right, that's much clearer. I'll go with that.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-08  3:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-05  3:00 [PATCH net] net: bridge: mst: Check vlan state for egress decision Elliot Ayrey
2024-07-05  6:19 ` Nikolay Aleksandrov
2024-07-05 22:00 ` Tobias Waldekranz
2024-07-08  3:37   ` Elliot Ayrey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox