1 --- a/net/bridge/br_device.c
2 +++ b/net/bridge/br_device.c
3 @@ -67,7 +67,8 @@ netdev_tx_t br_dev_xmit(struct sk_buff *
6 mdst = br_mdb_get(br, skb, vid);
7 - if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb))
8 + if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) &&
9 + br_multicast_querier_exists(br, eth_hdr(skb)))
10 br_multicast_deliver(mdst, skb);
12 br_flood_deliver(br, skb);
13 --- a/net/bridge/br_input.c
14 +++ b/net/bridge/br_input.c
15 @@ -98,7 +98,8 @@ int br_handle_frame_finish(struct sk_buf
17 else if (is_multicast_ether_addr(dest)) {
18 mdst = br_mdb_get(br, skb, vid);
19 - if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) {
20 + if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) &&
21 + br_multicast_querier_exists(br, eth_hdr(skb))) {
22 if ((mdst && mdst->mglist) ||
23 br_multicast_is_router(br))
25 --- a/net/bridge/br_multicast.c
26 +++ b/net/bridge/br_multicast.c
28 #include <linux/skbuff.h>
29 #include <linux/slab.h>
30 #include <linux/timer.h>
31 +#include <linux/inetdevice.h>
33 #if IS_ENABLED(CONFIG_IPV6)
36 #include <net/ip6_checksum.h>
37 +#include <net/addrconf.h>
40 #include "br_private.h"
42 -static void br_multicast_start_querier(struct net_bridge *br);
43 +static void br_multicast_start_querier(struct net_bridge *br,
44 + struct bridge_mcast_query *query);
45 unsigned int br_mdb_rehash_seq;
47 static inline int br_ip_equal(const struct br_ip *a, const struct br_ip *b)
48 @@ -381,7 +384,8 @@ static struct sk_buff *br_ip4_multicast_
49 iph->frag_off = htons(IP_DF);
51 iph->protocol = IPPROTO_IGMP;
53 + iph->saddr = br->multicast_query_use_ifaddr ?
54 + inet_select_addr(br->dev, 0, RT_SCOPE_LINK) : 0;
55 iph->daddr = htonl(INADDR_ALLHOSTS_GROUP);
56 ((u8 *)&iph[1])[0] = IPOPT_RA;
57 ((u8 *)&iph[1])[1] = 4;
58 @@ -724,7 +728,7 @@ static int br_ip6_multicast_add_group(st
60 struct br_ip br_group;
62 - if (!ipv6_is_transient_multicast(group))
63 + if (ipv6_addr_is_ll_all_nodes(group))
66 br_group.u.ip6 = *group;
67 @@ -756,20 +760,35 @@ static void br_multicast_local_router_ex
71 -static void br_multicast_querier_expired(unsigned long data)
72 +static void br_multicast_querier_expired(struct net_bridge *br,
73 + struct bridge_mcast_query *query)
75 - struct net_bridge *br = (void *)data;
77 spin_lock(&br->multicast_lock);
78 if (!netif_running(br->dev) || br->multicast_disabled)
81 - br_multicast_start_querier(br);
82 + br_multicast_start_querier(br, query);
85 spin_unlock(&br->multicast_lock);
88 +static void br_ip4_multicast_querier_expired(unsigned long data)
90 + struct net_bridge *br = (void *)data;
92 + br_multicast_querier_expired(br, &br->ip4_query);
95 +#if IS_ENABLED(CONFIG_IPV6)
96 +static void br_ip6_multicast_querier_expired(unsigned long data)
98 + struct net_bridge *br = (void *)data;
100 + br_multicast_querier_expired(br, &br->ip6_query);
104 static void __br_multicast_send_query(struct net_bridge *br,
105 struct net_bridge_port *port,
107 @@ -790,37 +809,45 @@ static void __br_multicast_send_query(st
110 static void br_multicast_send_query(struct net_bridge *br,
111 - struct net_bridge_port *port, u32 sent)
112 + struct net_bridge_port *port,
113 + struct bridge_mcast_query *query)
116 struct br_ip br_group;
117 + struct bridge_mcast_querier *querier = NULL;
119 if (!netif_running(br->dev) || br->multicast_disabled ||
120 - !br->multicast_querier ||
121 - timer_pending(&br->multicast_querier_timer))
122 + !br->multicast_querier)
125 memset(&br_group.u, 0, sizeof(br_group.u));
127 - br_group.proto = htons(ETH_P_IP);
128 - __br_multicast_send_query(br, port, &br_group);
130 + if (port ? (query == &port->ip4_query) :
131 + (query == &br->ip4_query)) {
132 + querier = &br->ip4_querier;
133 + br_group.proto = htons(ETH_P_IP);
134 #if IS_ENABLED(CONFIG_IPV6)
135 - br_group.proto = htons(ETH_P_IPV6);
136 - __br_multicast_send_query(br, port, &br_group);
138 + querier = &br->ip6_querier;
139 + br_group.proto = htons(ETH_P_IPV6);
143 + if (!querier || timer_pending(&querier->timer))
146 + __br_multicast_send_query(br, port, &br_group);
149 - time += sent < br->multicast_startup_query_count ?
150 + time += query->startup_sent < br->multicast_startup_query_count ?
151 br->multicast_startup_query_interval :
152 br->multicast_query_interval;
153 - mod_timer(port ? &port->multicast_query_timer :
154 - &br->multicast_query_timer, time);
155 + mod_timer(&query->timer, time);
158 -static void br_multicast_port_query_expired(unsigned long data)
159 +static void br_multicast_port_query_expired(struct net_bridge_port *port,
160 + struct bridge_mcast_query *query)
162 - struct net_bridge_port *port = (void *)data;
163 struct net_bridge *br = port->br;
165 spin_lock(&br->multicast_lock);
166 @@ -828,25 +855,43 @@ static void br_multicast_port_query_expi
167 port->state == BR_STATE_BLOCKING)
170 - if (port->multicast_startup_queries_sent <
171 - br->multicast_startup_query_count)
172 - port->multicast_startup_queries_sent++;
173 + if (query->startup_sent < br->multicast_startup_query_count)
174 + query->startup_sent++;
176 - br_multicast_send_query(port->br, port,
177 - port->multicast_startup_queries_sent);
178 + br_multicast_send_query(port->br, port, query);
181 spin_unlock(&br->multicast_lock);
184 +static void br_ip4_multicast_port_query_expired(unsigned long data)
186 + struct net_bridge_port *port = (void *)data;
188 + br_multicast_port_query_expired(port, &port->ip4_query);
191 +#if IS_ENABLED(CONFIG_IPV6)
192 +static void br_ip6_multicast_port_query_expired(unsigned long data)
194 + struct net_bridge_port *port = (void *)data;
196 + br_multicast_port_query_expired(port, &port->ip6_query);
200 void br_multicast_add_port(struct net_bridge_port *port)
202 port->multicast_router = 1;
204 setup_timer(&port->multicast_router_timer, br_multicast_router_expired,
205 (unsigned long)port);
206 - setup_timer(&port->multicast_query_timer,
207 - br_multicast_port_query_expired, (unsigned long)port);
208 + setup_timer(&port->ip4_query.timer, br_ip4_multicast_port_query_expired,
209 + (unsigned long)port);
210 +#if IS_ENABLED(CONFIG_IPV6)
211 + setup_timer(&port->ip6_query.timer, br_ip6_multicast_port_query_expired,
212 + (unsigned long)port);
216 void br_multicast_del_port(struct net_bridge_port *port)
217 @@ -854,13 +899,13 @@ void br_multicast_del_port(struct net_br
218 del_timer_sync(&port->multicast_router_timer);
221 -static void __br_multicast_enable_port(struct net_bridge_port *port)
222 +static void br_multicast_enable(struct bridge_mcast_query *query)
224 - port->multicast_startup_queries_sent = 0;
225 + query->startup_sent = 0;
227 - if (try_to_del_timer_sync(&port->multicast_query_timer) >= 0 ||
228 - del_timer(&port->multicast_query_timer))
229 - mod_timer(&port->multicast_query_timer, jiffies);
230 + if (try_to_del_timer_sync(&query->timer) >= 0 ||
231 + del_timer(&query->timer))
232 + mod_timer(&query->timer, jiffies);
235 void br_multicast_enable_port(struct net_bridge_port *port)
236 @@ -871,7 +916,10 @@ void br_multicast_enable_port(struct net
237 if (br->multicast_disabled || !netif_running(br->dev))
240 - __br_multicast_enable_port(port);
241 + br_multicast_enable(&port->ip4_query);
242 +#if IS_ENABLED(CONFIG_IPV6)
243 + br_multicast_enable(&port->ip6_query);
247 spin_unlock(&br->multicast_lock);
248 @@ -890,7 +938,10 @@ void br_multicast_disable_port(struct ne
249 if (!hlist_unhashed(&port->rlist))
250 hlist_del_init_rcu(&port->rlist);
251 del_timer(&port->multicast_router_timer);
252 - del_timer(&port->multicast_query_timer);
253 + del_timer(&port->ip4_query.timer);
254 +#if IS_ENABLED(CONFIG_IPV6)
255 + del_timer(&port->ip6_query.timer);
257 spin_unlock(&br->multicast_lock);
260 @@ -1015,6 +1066,17 @@ static int br_ip6_multicast_mld2_report(
265 +br_multicast_update_querier_timer(struct net_bridge *br,
266 + struct bridge_mcast_querier *querier,
267 + unsigned long max_delay)
269 + if (!timer_pending(&querier->timer))
270 + querier->delay_time = jiffies + max_delay;
272 + mod_timer(&querier->timer, jiffies + br->multicast_querier_interval);
276 * Add port to rotuer_list
277 * list is maintained ordered by pointer value
278 @@ -1065,12 +1127,13 @@ timer:
280 static void br_multicast_query_received(struct net_bridge *br,
281 struct net_bridge_port *port,
283 + struct bridge_mcast_querier *querier,
285 + unsigned long max_delay)
288 - mod_timer(&br->multicast_querier_timer,
289 - jiffies + br->multicast_querier_interval);
290 - else if (timer_pending(&br->multicast_querier_timer))
291 + br_multicast_update_querier_timer(br, querier, max_delay);
292 + else if (timer_pending(&querier->timer))
295 br_multicast_mark_router(br, port);
296 @@ -1097,8 +1160,6 @@ static int br_ip4_multicast_query(struct
297 (port && port->state == BR_STATE_DISABLED))
300 - br_multicast_query_received(br, port, !!iph->saddr);
304 if (skb->len == sizeof(*ih)) {
305 @@ -1122,6 +1183,9 @@ static int br_ip4_multicast_query(struct
306 IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE) : 1;
309 + br_multicast_query_received(br, port, &br->ip4_querier, !!iph->saddr,
315 @@ -1174,8 +1238,6 @@ static int br_ip6_multicast_query(struct
316 (port && port->state == BR_STATE_DISABLED))
319 - br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr));
321 /* RFC2710+RFC3810 (MLDv1+MLDv2) require link-local source addresses */
322 if (!(ipv6_addr_type(&ip6h->saddr) & IPV6_ADDR_LINKLOCAL)) {
324 @@ -1203,6 +1265,9 @@ static int br_ip6_multicast_query(struct
325 max_delay = max(msecs_to_jiffies(MLDV2_MRC(ntohs(mld2q->mld2q_mrc))), 1UL);
328 + br_multicast_query_received(br, port, &br->ip6_querier,
329 + !ipv6_addr_any(&ip6h->saddr), max_delay);
334 @@ -1235,7 +1300,9 @@ out:
336 static void br_multicast_leave_group(struct net_bridge *br,
337 struct net_bridge_port *port,
338 - struct br_ip *group)
339 + struct br_ip *group,
340 + struct bridge_mcast_querier *querier,
341 + struct bridge_mcast_query *query)
343 struct net_bridge_mdb_htable *mdb;
344 struct net_bridge_mdb_entry *mp;
345 @@ -1246,7 +1313,7 @@ static void br_multicast_leave_group(str
346 spin_lock(&br->multicast_lock);
347 if (!netif_running(br->dev) ||
348 (port && port->state == BR_STATE_DISABLED) ||
349 - timer_pending(&br->multicast_querier_timer))
350 + timer_pending(&querier->timer))
353 mdb = mlock_dereference(br->mdb, br);
354 @@ -1254,6 +1321,31 @@ static void br_multicast_leave_group(str
358 + if (br->multicast_querier) {
359 + __br_multicast_send_query(br, port, &mp->addr);
361 + time = jiffies + br->multicast_last_member_count *
362 + br->multicast_last_member_interval;
364 + mod_timer(&query->timer, time);
366 + for (p = mlock_dereference(mp->ports, br);
368 + p = mlock_dereference(p->next, br)) {
369 + if (p->port != port)
372 + if (!hlist_unhashed(&p->mglist) &&
373 + (timer_pending(&p->timer) ?
374 + time_after(p->timer.expires, time) :
375 + try_to_del_timer_sync(&p->timer) >= 0)) {
376 + mod_timer(&p->timer, time);
383 if (port && (port->flags & BR_MULTICAST_FAST_LEAVE)) {
384 struct net_bridge_port_group __rcu **pp;
386 @@ -1306,7 +1398,6 @@ static void br_multicast_leave_group(str
392 spin_unlock(&br->multicast_lock);
394 @@ -1317,6 +1408,8 @@ static void br_ip4_multicast_leave_group
397 struct br_ip br_group;
398 + struct bridge_mcast_query *query = port ? &port->ip4_query :
401 if (ipv4_is_local_multicast(group))
403 @@ -1325,7 +1418,7 @@ static void br_ip4_multicast_leave_group
404 br_group.proto = htons(ETH_P_IP);
407 - br_multicast_leave_group(br, port, &br_group);
408 + br_multicast_leave_group(br, port, &br_group, &br->ip4_querier, query);
411 #if IS_ENABLED(CONFIG_IPV6)
412 @@ -1335,15 +1428,18 @@ static void br_ip6_multicast_leave_group
415 struct br_ip br_group;
416 + struct bridge_mcast_query *query = port ? &port->ip6_query :
419 - if (!ipv6_is_transient_multicast(group))
421 + if (ipv6_addr_is_ll_all_nodes(group))
424 br_group.u.ip6 = *group;
425 br_group.proto = htons(ETH_P_IPV6);
428 - br_multicast_leave_group(br, port, &br_group);
429 + br_multicast_leave_group(br, port, &br_group, &br->ip6_querier, query);
433 @@ -1473,8 +1569,14 @@ static int br_multicast_ipv6_rcv(struct
434 * - MLD has always Router Alert hop-by-hop option
435 * - But we do not support jumbrograms.
437 - if (ip6h->version != 6 ||
438 - ip6h->nexthdr != IPPROTO_HOPOPTS ||
439 + if (ip6h->version != 6)
442 + /* Prevent flooding this packet if there is no listener present */
443 + if (!ipv6_addr_is_ll_all_nodes(&ip6h->daddr))
444 + BR_INPUT_SKB_CB(skb)->mrouters_only = 1;
446 + if (ip6h->nexthdr != IPPROTO_HOPOPTS ||
447 ip6h->payload_len == 0)
450 @@ -1605,19 +1707,32 @@ int br_multicast_rcv(struct net_bridge *
454 -static void br_multicast_query_expired(unsigned long data)
455 +static void br_multicast_query_expired(struct net_bridge *br,
456 + struct bridge_mcast_query *query)
458 + spin_lock(&br->multicast_lock);
459 + if (query->startup_sent < br->multicast_startup_query_count)
460 + query->startup_sent++;
462 + br_multicast_send_query(br, NULL, query);
463 + spin_unlock(&br->multicast_lock);
466 +static void br_ip4_multicast_query_expired(unsigned long data)
468 struct net_bridge *br = (void *)data;
470 - spin_lock(&br->multicast_lock);
471 - if (br->multicast_startup_queries_sent <
472 - br->multicast_startup_query_count)
473 - br->multicast_startup_queries_sent++;
474 + br_multicast_query_expired(br, &br->ip4_query);
477 - br_multicast_send_query(br, NULL, br->multicast_startup_queries_sent);
478 +#if IS_ENABLED(CONFIG_IPV6)
479 +static void br_ip6_multicast_query_expired(unsigned long data)
481 + struct net_bridge *br = (void *)data;
483 - spin_unlock(&br->multicast_lock);
484 + br_multicast_query_expired(br, &br->ip6_query);
488 void br_multicast_init(struct net_bridge *br)
490 @@ -1626,6 +1741,7 @@ void br_multicast_init(struct net_bridge
492 br->multicast_router = 1;
493 br->multicast_querier = 0;
494 + br->multicast_query_use_ifaddr = 0;
495 br->multicast_last_member_count = 2;
496 br->multicast_startup_query_count = 2;
498 @@ -1636,23 +1752,43 @@ void br_multicast_init(struct net_bridge
499 br->multicast_querier_interval = 255 * HZ;
500 br->multicast_membership_interval = 260 * HZ;
502 + br->ip4_querier.delay_time = 0;
503 +#if IS_ENABLED(CONFIG_IPV6)
504 + br->ip6_querier.delay_time = 0;
507 spin_lock_init(&br->multicast_lock);
508 setup_timer(&br->multicast_router_timer,
509 br_multicast_local_router_expired, 0);
510 - setup_timer(&br->multicast_querier_timer,
511 - br_multicast_querier_expired, (unsigned long)br);
512 - setup_timer(&br->multicast_query_timer, br_multicast_query_expired,
513 + setup_timer(&br->ip4_querier.timer, br_ip4_multicast_querier_expired,
515 + setup_timer(&br->ip4_query.timer, br_ip4_multicast_query_expired,
516 + (unsigned long)br);
517 +#if IS_ENABLED(CONFIG_IPV6)
518 + setup_timer(&br->ip6_querier.timer, br_ip6_multicast_querier_expired,
519 + (unsigned long)br);
520 + setup_timer(&br->ip6_query.timer, br_ip6_multicast_query_expired,
521 + (unsigned long)br);
525 -void br_multicast_open(struct net_bridge *br)
526 +static void __br_multicast_open(struct net_bridge *br,
527 + struct bridge_mcast_query *query)
529 - br->multicast_startup_queries_sent = 0;
530 + query->startup_sent = 0;
532 if (br->multicast_disabled)
535 - mod_timer(&br->multicast_query_timer, jiffies);
536 + mod_timer(&query->timer, jiffies);
539 +void br_multicast_open(struct net_bridge *br)
541 + __br_multicast_open(br, &br->ip4_query);
542 +#if IS_ENABLED(CONFIG_IPV6)
543 + __br_multicast_open(br, &br->ip6_query);
547 void br_multicast_stop(struct net_bridge *br)
548 @@ -1664,8 +1800,12 @@ void br_multicast_stop(struct net_bridge
551 del_timer_sync(&br->multicast_router_timer);
552 - del_timer_sync(&br->multicast_querier_timer);
553 - del_timer_sync(&br->multicast_query_timer);
554 + del_timer_sync(&br->ip4_querier.timer);
555 + del_timer_sync(&br->ip4_query.timer);
556 +#if IS_ENABLED(CONFIG_IPV6)
557 + del_timer_sync(&br->ip6_querier.timer);
558 + del_timer_sync(&br->ip6_query.timer);
561 spin_lock_bh(&br->multicast_lock);
562 mdb = mlock_dereference(br->mdb, br);
563 @@ -1767,18 +1907,24 @@ unlock:
567 -static void br_multicast_start_querier(struct net_bridge *br)
568 +static void br_multicast_start_querier(struct net_bridge *br,
569 + struct bridge_mcast_query *query)
571 struct net_bridge_port *port;
573 - br_multicast_open(br);
574 + __br_multicast_open(br, query);
576 list_for_each_entry(port, &br->port_list, list) {
577 if (port->state == BR_STATE_DISABLED ||
578 port->state == BR_STATE_BLOCKING)
581 - __br_multicast_enable_port(port);
582 + if (query == &br->ip4_query)
583 + br_multicast_enable(&port->ip4_query);
584 +#if IS_ENABLED(CONFIG_IPV6)
586 + br_multicast_enable(&port->ip6_query);
591 @@ -1813,7 +1959,10 @@ rollback:
595 - br_multicast_start_querier(br);
596 + br_multicast_start_querier(br, &br->ip4_query);
597 +#if IS_ENABLED(CONFIG_IPV6)
598 + br_multicast_start_querier(br, &br->ip6_query);
602 spin_unlock_bh(&br->multicast_lock);
603 @@ -1823,6 +1972,8 @@ unlock:
605 int br_multicast_set_querier(struct net_bridge *br, unsigned long val)
607 + unsigned long max_delay;
611 spin_lock_bh(&br->multicast_lock);
612 @@ -1830,8 +1981,22 @@ int br_multicast_set_querier(struct net_
615 br->multicast_querier = val;
617 - br_multicast_start_querier(br);
621 + max_delay = br->multicast_query_response_interval;
623 + if (!timer_pending(&br->ip4_querier.timer))
624 + br->ip4_querier.delay_time = jiffies + max_delay;
626 + br_multicast_start_querier(br, &br->ip4_query);
628 +#if IS_ENABLED(CONFIG_IPV6)
629 + if (!timer_pending(&br->ip6_querier.timer))
630 + br->ip6_querier.delay_time = jiffies + max_delay;
632 + br_multicast_start_querier(br, &br->ip6_query);
636 spin_unlock_bh(&br->multicast_lock);
637 --- a/net/bridge/br_private.h
638 +++ b/net/bridge/br_private.h
639 @@ -66,6 +66,20 @@ struct br_ip
643 +#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
644 +/* our own querier */
645 +struct bridge_mcast_query {
646 + struct timer_list timer;
651 +struct bridge_mcast_querier {
652 + struct timer_list timer;
653 + unsigned long delay_time;
657 struct net_port_vlans {
660 @@ -159,10 +173,12 @@ struct net_bridge_port
661 #define BR_ADMIN_COST 0x00000010
663 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
664 - u32 multicast_startup_queries_sent;
665 + struct bridge_mcast_query ip4_query;
666 +#if IS_ENABLED(CONFIG_IPV6)
667 + struct bridge_mcast_query ip6_query;
668 +#endif /* IS_ENABLED(CONFIG_IPV6) */
669 unsigned char multicast_router;
670 struct timer_list multicast_router_timer;
671 - struct timer_list multicast_query_timer;
672 struct hlist_head mglist;
673 struct hlist_node rlist;
675 @@ -246,12 +262,12 @@ struct net_bridge
677 u8 multicast_disabled:1;
678 u8 multicast_querier:1;
679 + u8 multicast_query_use_ifaddr:1;
684 u32 multicast_last_member_count;
685 - u32 multicast_startup_queries_sent;
686 u32 multicast_startup_query_count;
688 unsigned long multicast_last_member_interval;
689 @@ -266,8 +282,12 @@ struct net_bridge
690 struct hlist_head router_list;
692 struct timer_list multicast_router_timer;
693 - struct timer_list multicast_querier_timer;
694 - struct timer_list multicast_query_timer;
695 + struct bridge_mcast_querier ip4_querier;
696 + struct bridge_mcast_query ip4_query;
697 +#if IS_ENABLED(CONFIG_IPV6)
698 + struct bridge_mcast_querier ip6_querier;
699 + struct bridge_mcast_query ip6_query;
700 +#endif /* IS_ENABLED(CONFIG_IPV6) */
703 struct timer_list hello_timer;
704 @@ -477,22 +497,35 @@ extern void br_mdb_notify(struct net_dev
705 #define mlock_dereference(X, br) \
706 rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock))
708 -#if IS_ENABLED(CONFIG_IPV6)
709 -#include <net/addrconf.h>
710 -static inline int ipv6_is_transient_multicast(const struct in6_addr *addr)
712 - if (ipv6_addr_is_multicast(addr) && IPV6_ADDR_MC_FLAG_TRANSIENT(addr))
718 static inline bool br_multicast_is_router(struct net_bridge *br)
720 return br->multicast_router == 2 ||
721 (br->multicast_router == 1 &&
722 timer_pending(&br->multicast_router_timer));
726 +__br_multicast_querier_exists(struct net_bridge *br,
727 + struct bridge_mcast_querier *querier)
729 + return time_is_before_jiffies(querier->delay_time) &&
730 + (br->multicast_querier || timer_pending(&querier->timer));
733 +static inline bool br_multicast_querier_exists(struct net_bridge *br,
734 + struct ethhdr *eth)
736 + switch (eth->h_proto) {
737 + case (htons(ETH_P_IP)):
738 + return __br_multicast_querier_exists(br, &br->ip4_querier);
739 +#if IS_ENABLED(CONFIG_IPV6)
740 + case (htons(ETH_P_IPV6)):
741 + return __br_multicast_querier_exists(br, &br->ip6_querier);
748 static inline int br_multicast_rcv(struct net_bridge *br,
749 struct net_bridge_port *port,
750 @@ -549,6 +582,11 @@ static inline bool br_multicast_is_route
754 +static inline bool br_multicast_querier_exists(struct net_bridge *br,
755 + struct ethhdr *eth)
759 static inline void br_mdb_init(void)
762 --- a/net/bridge/br_sysfs_br.c
763 +++ b/net/bridge/br_sysfs_br.c
764 @@ -375,6 +375,31 @@ static ssize_t store_multicast_snooping(
765 static DEVICE_ATTR(multicast_snooping, S_IRUGO | S_IWUSR,
766 show_multicast_snooping, store_multicast_snooping);
768 +static ssize_t show_multicast_query_use_ifaddr(struct device *d,
769 + struct device_attribute *attr,
772 + struct net_bridge *br = to_bridge(d);
773 + return sprintf(buf, "%d\n", br->multicast_query_use_ifaddr);
776 +static int set_query_use_ifaddr(struct net_bridge *br, unsigned long val)
778 + br->multicast_query_use_ifaddr = !!val;
783 +store_multicast_query_use_ifaddr(struct device *d,
784 + struct device_attribute *attr,
785 + const char *buf, size_t len)
787 + return store_bridge_parm(d, buf, len, set_query_use_ifaddr);
789 +static DEVICE_ATTR(multicast_query_use_ifaddr, S_IRUGO | S_IWUSR,
790 + show_multicast_query_use_ifaddr,
791 + store_multicast_query_use_ifaddr);
793 static ssize_t show_multicast_querier(struct device *d,
794 struct device_attribute *attr,
796 @@ -734,6 +759,7 @@ static struct attribute *bridge_attrs[]
797 &dev_attr_multicast_router.attr,
798 &dev_attr_multicast_snooping.attr,
799 &dev_attr_multicast_querier.attr,
800 + &dev_attr_multicast_query_use_ifaddr.attr,
801 &dev_attr_hash_elasticity.attr,
802 &dev_attr_hash_max.attr,
803 &dev_attr_multicast_last_member_count.attr,
804 --- a/net/bridge/br_mdb.c
805 +++ b/net/bridge/br_mdb.c
807 #include <net/netlink.h>
808 #if IS_ENABLED(CONFIG_IPV6)
809 #include <net/ipv6.h>
810 +#include <net/addrconf.h>
813 #include "br_private.h"
814 @@ -253,7 +254,7 @@ static bool is_valid_mdb_entry(struct br
816 #if IS_ENABLED(CONFIG_IPV6)
817 } else if (entry->addr.proto == htons(ETH_P_IPV6)) {
818 - if (!ipv6_is_transient_multicast(&entry->addr.u.ip6))
819 + if (ipv6_addr_is_ll_all_nodes(&entry->addr.u.ip6))
823 @@ -414,16 +415,20 @@ static int __br_mdb_del(struct net_bridg
824 if (!netif_running(br->dev) || br->multicast_disabled)
827 - if (timer_pending(&br->multicast_querier_timer))
830 ip.proto = entry->addr.proto;
831 - if (ip.proto == htons(ETH_P_IP))
832 + if (ip.proto == htons(ETH_P_IP)) {
833 + if (timer_pending(&br->ip4_querier.timer))
836 ip.u.ip4 = entry->addr.u.ip4;
837 #if IS_ENABLED(CONFIG_IPV6)
840 + if (timer_pending(&br->ip6_querier.timer))
843 ip.u.ip6 = entry->addr.u.ip6;
847 spin_lock_bh(&br->multicast_lock);
848 mdb = mlock_dereference(br->mdb, br);