[PATCH] bridge: don't flood multicast packets if no snooping entry

Lin Ming
2012-10-12T01:18:39Z

From: Lin Ming <mlin@ss.pku.edu.cn>

Currently, multicast packets will be flood even if there is no
mutlicast snooping entry attached to port.

With IGMP snooping enabled, we should stop sending multicast packets
if there is no member joined.

Signed-off-by: Lin Ming <mlin@ss.pku.edu.cn>
---
net/bridge/br_input.c | 2 ++
net/bridge/br_private.h | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 76f15fd..2821085 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -90,6 +90,8 @@ int br_handle_frame_finish(struct sk_buff *skb)
skb = NULL;
if (!skb2)
goto out;
+ } else if (!mdst && BR_INPUT_SKB_CB_NOT_IGMP(skb)) {
+ skb = NULL;
} else
skb2 = skb;

diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 9b278c4..e2c894d 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -268,8 +268,10 @@ struct br_input_skb_cb {

#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (BR_INPUT_SKB_CB(__skb)->mrouters_only)
+# define BR_INPUT_SKB_CB_NOT_IGMP(__skb) (!BR_INPUT_SKB_CB(__skb)->igmp)
#else
# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (0)
+# define BR_INPUT_SKB_CB_NOT_IGMP(__skb) (0)
#endif

#define br_printk(level, br, format, args...) \
--
1.7.2.5