bridge: pass correct vlan id to multicast code
Subsystems (3)
PATCH 1/1 bridge: pass correct vlan id to multicast code
Currently multicast code attempts to extrace the vlan id from the skb even when vlan filtering is disabled. This can lead to mdb entries being created with the wrong vlan id. Pass the already extracted vlan id to the multicast filtering code to make the correct id is used in creation as well as lookup.
--- net/bridge/br_device.c | 2 +- net/bridge/br_input.c | 2 +- net/bridge/br_multicast.c | 44 +++++++++++++++++++------------------------- net/bridge/br_private.h | 6 ++++-- 4 files changed, 25 insertions(+), 29 deletions(-)
net/bridge/br_device.c +1 -1
@@ -64,7 +64,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)br_flood_deliver (br, skb, false); goto out; } -if (br_multicast_rcv (br,NULL , skb)) { +if (br_multicast_rcv (br,NULL , skb, vid)) {kfree_skb (skb); goto out; }
net/bridge/br_input.c +1 -1
@@ -80,7 +80,7 @@ int br_handle_frame_finish(struct sk_buff *skb)br_fdb_update (br, p,eth_hdr (skb)->h_source, vid);if (!is_broadcast_ether_addr (dest) &&is_multicast_ether_addr (dest) && -br_multicast_rcv (br, p, skb)) +br_multicast_rcv (br, p, skb, vid)) goto drop;if (p->state ==BR_STATE_LEARNING )
net/bridge/br_multicast.c +19 -25
178 lines not on this page · raw message
net/bridge/br_private.h +4 -2
@@ -451,7 +451,8 @@ extern int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __usextern unsigned int br_mdb_rehash_seq;extern int br_multicast_rcv (struct net_bridge *br,struct net_bridge_port *port, -struct sk_buff *skb); +struct sk_buff *skb, +u16 vid);extern struct net_bridge_mdb_entry *br_mdb_get (struct net_bridge *br,struct sk_buff *skb,u16 vid);extern void br_multicast_add_port (struct net_bridge_port *port);
@@ -522,7 +523,8 @@ static inline bool br_multicast_querier_exists(struct net_bridge *br,#else static inline int br_multicast_rcv (struct net_bridge *br,struct net_bridge_port *port, -struct sk_buff *skb) +struct sk_buff *skb, +u16 vid) {return 0 ; }
Signature · 1 line
1.8.3.1
Quoted 6 lines · Vlad Yasevich
Currently multicast code attempts to extrace the vlan id from the skb even when vlan filtering is disabled. This can lead to mdb entries being created with the wrong vlan id. Pass the already extracted vlan id to the multicast filtering code to make the correct id is used in creation as well as lookup.
Hi Vlad,
Can we just update br_vlan_get_tag() to set vid to 0 if dev->vlan is disabled? I guess it would effect br_handle_local_finish().
Quoted 7 lines
Signed-off-by Vlad Yasevich <[email protected]>--- net/bridge/br_device.c | 2 +- net/bridge/br_input.c | 2 +- net/bridge/br_multicast.c | 44 +++++++++++++++++++------------------------- net/bridge/br_private.h | 6 ++++-- 4 files changed, 25 insertions(+), 29 deletions(-)
...
Quoted 15 lines
net/bridge/br_multicast.c +2
-1@@ -947,7 +947,8 @@ void br_multicast_disable_port(struct net_bridge_port *port)static int br_ip4_multicast_igmp3_report (struct net_bridge *br,struct net_bridge_port *port, -struct sk_buff *skb) +struct sk_buff *skb, +u16 vid) {struct igmpv3_report *ih;struct igmpv3_grec *grec;
net/bridge/br_multicast.c static int br_ip4_multicast_igmp3_report(struct net_bridge *br, · line 965
Quoted 9 lines
net/bridge/br_multicast.c +0
-2@@ -957,12 +958,10 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,int type;int err =0 ;__be32 group; -u16 vid =0 ;if (!pskb_may_pull (skb,sizeof (*ih)))return -EINVAL ; -br_vlan_get_tag (skb, &vid);
After applied the patch, we always use vid in br_dev_xmit()->br_allowed_ingress(), is it possible that the vlan of bridge is re-enabled when other changed functions are called?
We can just add a enabled checking before this kind of br_vlan_get_tag()?
if (!br->vlan_enabled)
br_vlan_get_tag(skb2, &vid);
Quoted 3 lines
net/bridge/br_multicast.c +0
-0ih =igmpv3_report_hdr (skb); num =ntohs (ih->ngrec); len =sizeof (*ih);
...
Signature · 1 line
Amos.
Toshiaki Makita
Acked-byQuoted 7 lines · Amos Kong
Quoted 6 lines · Vlad Yasevich
Currently multicast code attempts to extrace the vlan id from the skb even when vlan filtering is disabled. This can lead to mdb entries being created with the wrong vlan id. Pass the already extracted vlan id to the multicast filtering code to make the correct id is used in creation as well as lookup.
Thanks!
Quoted 5 lines
Hi Vlad,
Can we just update
br_vlan_get_tag()to set vid to 0 ifdev->vlanis disabled? I guess it would effectbr_handle_local_finish().
br_handle_local_finish() looks also buggy.
But adding vlan enabled checking would not fix it completely because vlan_bitmap and PVID are not taken into account in that function.
Since we cannot pass vid as an argument from br_dev_xmit() to br_handle_[local/frame]_finish() because of NF_HOOK, br_handle_local_finish() seems to have to check vlan_enabled, vlan_bitmap, and pvid by itself.
IMHO it can be addressed by another patch.
Quoted 40 lines
Quoted 8 lines
Signed-off-by Vlad Yasevich <[email protected]>--- net/bridge/br_device.c | 2 +- net/bridge/br_input.c | 2 +- net/bridge/br_multicast.c | 44 +++++++++++++++++++------------------------- net/bridge/br_private.h | 6 ++++-- 4 files changed, 25 insertions(+), 29 deletions(-)...
Quoted 15 lines
net/bridge/br_multicast.c +2
-1@@ -947,7 +947,8 @@ void br_multicast_disable_port(struct net_bridge_port *port)static int br_ip4_multicast_igmp3_report (struct net_bridge *br,struct net_bridge_port *port, -struct sk_buff *skb) +struct sk_buff *skb, +u16 vid) {struct igmpv3_report *ih;struct igmpv3_grec *grec;net/bridge/br_multicast.c static int br_ip4_multicast_igmp3_report(struct net_bridge *br, · line 965
Quoted 9 lines
net/bridge/br_multicast.c +0
-2@@ -957,12 +958,10 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,int type;int err =0 ;__be32 group; -u16 vid =0 ;if (!pskb_may_pull (skb,sizeof (*ih)))return -EINVAL ; -br_vlan_get_tag (skb, &vid);After applied the patch, we always use vid in br_dev_xmit()->br_allowed_ingress(), is it possible that the vlan of bridge is re-enabled when other changed functions are called?
Quoted 4 lines
We can just add a enabled checking before this kind of
br_vlan_get_tag()?if (!br->vlan_enabled)
br_vlan_get_tag(skb2, &vid);
Maybe this leads to a wrong way to update mdb in some cases like
Vlan_filtering is disabled (by default).
Add some vids we want to allow.
Receive a frame whose vid wouldn't be allowed with vlan_filtering enabled. The frame passes br_allowed_ingress().
Enable vlan_filtering.
The frame reaches br_ip4_multicast_igmp3_report().
Mdb is updated with disabled vid.
Thanks,
Toshiaki Makita
Quoted 8 lines
Quoted 5 lines
net/bridge/br_multicast.c +0
-0ih =igmpv3_report_hdr (skb); num =ntohs (ih->ngrec); len =sizeof (*ih);...
Quoted 84 lines · Toshiaki Makita
Quoted 7 lines · Amos Kong
Quoted 6 lines · Vlad Yasevich
Currently multicast code attempts to extrace the vlan id from the skb even when vlan filtering is disabled. This can lead to mdb entries being created with the wrong vlan id. Pass the already extracted vlan id to the multicast filtering code to make the correct id is used in creation as well as lookup.
Thanks!
Acked-by Toshiaki Makita <[email protected]>Quoted 5 lines
Hi Vlad,
Can we just update
br_vlan_get_tag()to set vid to 0 ifdev->vlanis disabled? I guess it would effectbr_handle_local_finish().
br_handle_local_finish()looks also buggy.
But adding vlan enabled checking would not fix it completely becausevlan_bitmapand PVID are not taken into account in that function.Since we cannot pass vid as an argument from
br_dev_xmit()to br_handle_[local/frame]_finish() because ofNF_HOOK,br_handle_local_finish()seems to have to checkvlan_enabled,vlan_bitmap, and pvid by itself.IMHO it can be addressed by another patch.
Quoted 39 lines
Quoted 7 lines
Signed-off-by Vlad Yasevich <[email protected]>--- net/bridge/br_device.c | 2 +- net/bridge/br_input.c | 2 +- net/bridge/br_multicast.c | 44 +++++++++++++++++++------------------------- net/bridge/br_private.h | 6 ++++-- 4 files changed, 25 insertions(+), 29 deletions(-)...
Quoted 15 lines
net/bridge/br_multicast.c +2
-1@@ -947,7 +947,8 @@ void br_multicast_disable_port(struct net_bridge_port *port)static int br_ip4_multicast_igmp3_report (struct net_bridge *br,struct net_bridge_port *port, -struct sk_buff *skb) +struct sk_buff *skb, +u16 vid) {struct igmpv3_report *ih;struct igmpv3_grec *grec;net/bridge/br_multicast.c static int br_ip4_multicast_igmp3_report(struct net_bridge *br, · line 965
Quoted 9 lines
net/bridge/br_multicast.c +0
-2@@ -957,12 +958,10 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,int type;int err =0 ;__be32 group; -u16 vid =0 ;if (!pskb_may_pull (skb,sizeof (*ih)))return -EINVAL ; -br_vlan_get_tag (skb, &vid);After applied the patch, we always use vid in br_dev_xmit()->br_allowed_ingress(), is it possible that the vlan of bridge is re-enabled when other changed functions are called?
Quoted 4 lines
We can just add a enabled checking before this kind of
br_vlan_get_tag()?if (!br->vlan_enabled)
br_vlan_get_tag(skb2, &vid);Maybe this leads to a wrong way to update mdb in some cases like
Vlan_filteringis disabled (by default).
Add some vids we want to allow.
Receive a frame whose vid wouldn't be allowed withvlan_filteringenabled. The frame passesbr_allowed_ingress().
Enablevlan_filtering.
The frame reachesbr_ip4_multicast_igmp3_report().
Mdb is updated with disabled vid.
Quoted 3 lines
Thanks,
Toshiaki Makita
Thanks all your explanation, I'm ok with the patch.
Signature · 1 line
Amos.
Quoted 8 lines · Amos Kong
Quoted 6 lines · Vlad Yasevich
Currently multicast code attempts to extrace the vlan id from the skb even when vlan filtering is disabled. This can lead to mdb entries being created with the wrong vlan id. Pass the already extracted vlan id to the multicast filtering code to make the correct id is used in creation as well as lookup.
Quoted 4 lines
Hi Vlad,
Can we just update
br_vlan_get_tag()to set vid to 0 ifdev->vlanis disabled? I guess it would effectbr_handle_local_finish().
I have another patch that refactors the br_vlan_get_tag() and that would address this issue. I am testing it now.
I am hoping to simplify the patch a bit though since I am not crazy about the function signature that br_vlan_get_tag() gets.
-vlad
Quoted 52 lines
Quoted 8 lines
Signed-off-by Vlad Yasevich <[email protected]>--- net/bridge/br_device.c | 2 +- net/bridge/br_input.c | 2 +- net/bridge/br_multicast.c | 44 +++++++++++++++++++------------------------- net/bridge/br_private.h | 6 ++++-- 4 files changed, 25 insertions(+), 29 deletions(-)...
Quoted 15 lines
net/bridge/br_multicast.c +2
-1@@ -947,7 +947,8 @@ void br_multicast_disable_port(struct net_bridge_port *port)static int br_ip4_multicast_igmp3_report (struct net_bridge *br,struct net_bridge_port *port, -struct sk_buff *skb) +struct sk_buff *skb, +u16 vid) {struct igmpv3_report *ih;struct igmpv3_grec *grec;net/bridge/br_multicast.c static int br_ip4_multicast_igmp3_report(struct net_bridge *br, · line 965
Quoted 9 lines
net/bridge/br_multicast.c +0
-2@@ -957,12 +958,10 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,int type;int err =0 ;__be32 group; -u16 vid =0 ;if (!pskb_may_pull (skb,sizeof (*ih)))return -EINVAL ; -br_vlan_get_tag (skb, &vid);After applied the patch, we always use vid in br_dev_xmit()->br_allowed_ingress(), is it possible that the vlan of bridge is re-enabled when other changed functions are called?
We can just add a enabled checking before this kind of
br_vlan_get_tag()?if (!br->vlan_enabled)
br_vlan_get_tag(skb2, &vid);Quoted 3 lines
net/bridge/br_multicast.c +0
-0ih =igmpv3_report_hdr (skb); num =ntohs (ih->ngrec); len =sizeof (*ih);...
Quoted 22 lines · Amos Kong
Quoted 20 lines · Vlad Yasevich
net/bridge/br_multicast.c +2
-2@@ -947,7 +947,8 @@ void br_multicast_disable_port(struct net_bridge_port *port)static int br_ip4_multicast_igmp3_report (struct net_bridge *br,struct net_bridge_port *port, -struct sk_buff *skb) +struct sk_buff *skb, +u16 vid) {struct igmpv3_report *ih;struct igmpv3_grec *grec;@@ -957,12 +958,10 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,int type;int err =0 ;__be32 group; -u16 vid =0 ;
Quoted 5 lines
net/bridge/br_multicast.c static int br_ip4_multicast_igmp3_report(struct net_bridge *br, · line 965
Quoted 4 lines
net/bridge/br_multicast.c +0
-1if (!pskb_may_pull (skb,sizeof (*ih)))return -EINVAL ; -br_vlan_get_tag (skb, &vid);
Sorry, missed this question last time.
Quoted 4 lines
After applied the patch, we always use vid in br_dev_xmit()->br_allowed_ingress(), is it possible that the vlan of bridge is re-enabled when other changed functions are called?
If the frame was allowed to enter, then the current configuration should apply the the frame. If the config changes during the frame processing we don't really want to use that. Otherwise, you'd get
inconsistent results.
Quoted 5 lines
We can just add a enabled checking before this kind of
br_vlan_get_tag()?if (!br->vlan_enabled)
br_vlan_get_tag(skb2, &vid);
This sort of what the next patches I am working on do. But we still want to get the vlan id once and then use it throught out. There is no need to retrieve it again.
-vlad
Quoted 7 lines
Quoted 4 lines
net/bridge/br_multicast.c +0
-0ih =igmpv3_report_hdr (skb); num =ntohs (ih->ngrec); len =sizeof (*ih);...
From: Vlad Yasevich <[email protected]>
Date: Mon, 28 Oct 2013 15:45:07 -0400
Quoted 8 lines
Currently multicast code attempts to extrace the vlan id from the skb even when vlan filtering is disabled. This can lead to mdb entries being created with the wrong vlan id. Pass the already extracted vlan id to the multicast filtering code to make the correct id is used in creation as well as lookup.
Signed-off-by Vlad Yasevich <[email protected]>
Applied, thanks Vlad and others.