Skip to content

Commit 1c8ad5b

Browse files
Cong Wangdavem330
Cong Wang
authored andcommitted
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 <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Stephen Hemminger <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Adam Baker <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4f45c40 commit 1c8ad5b

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

net/bridge/br_multicast.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/skbuff.h>
2424
#include <linux/slab.h>
2525
#include <linux/timer.h>
26+
#include <linux/inetdevice.h>
2627
#include <net/ip.h>
2728
#if IS_ENABLED(CONFIG_IPV6)
2829
#include <net/ipv6.h>
@@ -381,7 +382,8 @@ static struct sk_buff *br_ip4_multicast_alloc_query(struct net_bridge *br,
381382
iph->frag_off = htons(IP_DF);
382383
iph->ttl = 1;
383384
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;
385387
iph->daddr = htonl(INADDR_ALLHOSTS_GROUP);
386388
((u8 *)&iph[1])[0] = IPOPT_RA;
387389
((u8 *)&iph[1])[1] = 4;
@@ -1618,6 +1620,7 @@ void br_multicast_init(struct net_bridge *br)
16181620

16191621
br->multicast_router = 1;
16201622
br->multicast_querier = 0;
1623+
br->multicast_query_use_ifaddr = 0;
16211624
br->multicast_last_member_count = 2;
16221625
br->multicast_startup_query_count = 2;
16231626

net/bridge/br_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ struct net_bridge
249249

250250
u8 multicast_disabled:1;
251251
u8 multicast_querier:1;
252+
u8 multicast_query_use_ifaddr:1;
252253

253254
u32 hash_elasticity;
254255
u32 hash_max;

net/bridge/br_sysfs_br.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,31 @@ static ssize_t store_multicast_snooping(struct device *d,
375375
static DEVICE_ATTR(multicast_snooping, S_IRUGO | S_IWUSR,
376376
show_multicast_snooping, store_multicast_snooping);
377377

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+
378403
static ssize_t show_multicast_querier(struct device *d,
379404
struct device_attribute *attr,
380405
char *buf)
@@ -734,6 +759,7 @@ static struct attribute *bridge_attrs[] = {
734759
&dev_attr_multicast_router.attr,
735760
&dev_attr_multicast_snooping.attr,
736761
&dev_attr_multicast_querier.attr,
762+
&dev_attr_multicast_query_use_ifaddr.attr,
737763
&dev_attr_hash_elasticity.attr,
738764
&dev_attr_hash_max.attr,
739765
&dev_attr_multicast_last_member_count.attr,

0 commit comments

Comments
 (0)