diff options
author | Cong Wang <amwang@redhat.com> | 2013-05-21 17:52:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-05-22 17:54:37 -0400 |
commit | 1c8ad5bfa2be5025b0c81e3c2decd0574d453ab1 (patch) | |
tree | f69ac9d37009526ae924c23940207b6531534f9f | |
parent | 4f45c40f2c018e5c278988521a74fd5ee06fb819 (diff) |
bridge: use the bridge IP addr as source addr for querier
Quote from Adam:
"If it is believed that the use of 0.0.0.0
as the IP address is what is causing strange behaviour on other devices
then is there a good reason that a bridge rather than a router shouldn't
be the active querier? If not then using the bridge IP address and
having the querier enabled by default may be a reasonable solution
(provided that our querier obeys the election rules and shuts up if it
sees a query from a lower IP address that isn't 0.0.0.0). Just because a
device is the elected querier for IGMP doesn't appear to mean it is
required to perform any other routing functions."
And introduce a new troggle for it, as suggested by Herbert.
Suggested-by: Adam Baker <linux@baker-net.org.uk>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Adam Baker <linux@baker-net.org.uk>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/bridge/br_multicast.c | 5 | ||||
-rw-r--r-- | net/bridge/br_private.h | 1 | ||||
-rw-r--r-- | net/bridge/br_sysfs_br.c | 26 |
3 files changed, 31 insertions, 1 deletions
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 81f2389f78eb..247514793101 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/skbuff.h> | 23 | #include <linux/skbuff.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
26 | #include <linux/inetdevice.h> | ||
26 | #include <net/ip.h> | 27 | #include <net/ip.h> |
27 | #if IS_ENABLED(CONFIG_IPV6) | 28 | #if IS_ENABLED(CONFIG_IPV6) |
28 | #include <net/ipv6.h> | 29 | #include <net/ipv6.h> |
@@ -381,7 +382,8 @@ static struct sk_buff *br_ip4_multicast_alloc_query(struct net_bridge *br, | |||
381 | iph->frag_off = htons(IP_DF); | 382 | iph->frag_off = htons(IP_DF); |
382 | iph->ttl = 1; | 383 | iph->ttl = 1; |
383 | iph->protocol = IPPROTO_IGMP; | 384 | iph->protocol = IPPROTO_IGMP; |
384 | iph->saddr = 0; | 385 | iph->saddr = br->multicast_query_use_ifaddr ? |
386 | inet_select_addr(br->dev, 0, RT_SCOPE_LINK) : 0; | ||
385 | iph->daddr = htonl(INADDR_ALLHOSTS_GROUP); | 387 | iph->daddr = htonl(INADDR_ALLHOSTS_GROUP); |
386 | ((u8 *)&iph[1])[0] = IPOPT_RA; | 388 | ((u8 *)&iph[1])[0] = IPOPT_RA; |
387 | ((u8 *)&iph[1])[1] = 4; | 389 | ((u8 *)&iph[1])[1] = 4; |
@@ -1618,6 +1620,7 @@ void br_multicast_init(struct net_bridge *br) | |||
1618 | 1620 | ||
1619 | br->multicast_router = 1; | 1621 | br->multicast_router = 1; |
1620 | br->multicast_querier = 0; | 1622 | br->multicast_querier = 0; |
1623 | br->multicast_query_use_ifaddr = 0; | ||
1621 | br->multicast_last_member_count = 2; | 1624 | br->multicast_last_member_count = 2; |
1622 | br->multicast_startup_query_count = 2; | 1625 | br->multicast_startup_query_count = 2; |
1623 | 1626 | ||
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index d2c043a857b6..e260710a01d4 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -249,6 +249,7 @@ struct net_bridge | |||
249 | 249 | ||
250 | u8 multicast_disabled:1; | 250 | u8 multicast_disabled:1; |
251 | u8 multicast_querier:1; | 251 | u8 multicast_querier:1; |
252 | u8 multicast_query_use_ifaddr:1; | ||
252 | 253 | ||
253 | u32 hash_elasticity; | 254 | u32 hash_elasticity; |
254 | u32 hash_max; | 255 | u32 hash_max; |
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index 8baa9c08e1a4..394bb96b6087 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c | |||
@@ -375,6 +375,31 @@ static ssize_t store_multicast_snooping(struct device *d, | |||
375 | static DEVICE_ATTR(multicast_snooping, S_IRUGO | S_IWUSR, | 375 | static DEVICE_ATTR(multicast_snooping, S_IRUGO | S_IWUSR, |
376 | show_multicast_snooping, store_multicast_snooping); | 376 | show_multicast_snooping, store_multicast_snooping); |
377 | 377 | ||
378 | static ssize_t show_multicast_query_use_ifaddr(struct device *d, | ||
379 | struct device_attribute *attr, | ||
380 | char *buf) | ||
381 | { | ||
382 | struct net_bridge *br = to_bridge(d); | ||
383 | return sprintf(buf, "%d\n", br->multicast_query_use_ifaddr); | ||
384 | } | ||
385 | |||
386 | static int set_query_use_ifaddr(struct net_bridge *br, unsigned long val) | ||
387 | { | ||
388 | br->multicast_query_use_ifaddr = !!val; | ||
389 | return 0; | ||
390 | } | ||
391 | |||
392 | static ssize_t | ||
393 | store_multicast_query_use_ifaddr(struct device *d, | ||
394 | struct device_attribute *attr, | ||
395 | const char *buf, size_t len) | ||
396 | { | ||
397 | return store_bridge_parm(d, buf, len, set_query_use_ifaddr); | ||
398 | } | ||
399 | static DEVICE_ATTR(multicast_query_use_ifaddr, S_IRUGO | S_IWUSR, | ||
400 | show_multicast_query_use_ifaddr, | ||
401 | store_multicast_query_use_ifaddr); | ||
402 | |||
378 | static ssize_t show_multicast_querier(struct device *d, | 403 | static ssize_t show_multicast_querier(struct device *d, |
379 | struct device_attribute *attr, | 404 | struct device_attribute *attr, |
380 | char *buf) | 405 | char *buf) |
@@ -734,6 +759,7 @@ static struct attribute *bridge_attrs[] = { | |||
734 | &dev_attr_multicast_router.attr, | 759 | &dev_attr_multicast_router.attr, |
735 | &dev_attr_multicast_snooping.attr, | 760 | &dev_attr_multicast_snooping.attr, |
736 | &dev_attr_multicast_querier.attr, | 761 | &dev_attr_multicast_querier.attr, |
762 | &dev_attr_multicast_query_use_ifaddr.attr, | ||
737 | &dev_attr_hash_elasticity.attr, | 763 | &dev_attr_hash_elasticity.attr, |
738 | &dev_attr_hash_max.attr, | 764 | &dev_attr_hash_max.attr, |
739 | &dev_attr_multicast_last_member_count.attr, | 765 | &dev_attr_multicast_last_member_count.attr, |