Skip to content

Commit 938f2e0

Browse files
T-Xsimonwunderlich
authored andcommitted
batman-adv: mcast: don't send link-local multicast to mcast routers
The addition of routable multicast TX handling introduced a bug/regression for packets with a link-local multicast destination: These packets would be sent to all batman-adv nodes with a multicast router and to all batman-adv nodes with an old version without multicast router detection. This even disregards the batman-adv multicast fanout setting, which can potentially lead to an unwanted, high number of unicast transmissions or even congestion. Fixing this by avoiding to send link-local multicast packets to nodes in the multicast router list. Fixes: 11d458c ("batman-adv: mcast: apply optimizations for routable packets, too") Signed-off-by: Linus Lüssing <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 66f4bea commit 938f2e0

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

net/batman-adv/multicast.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,24 +1339,24 @@ batadv_mcast_forw_rtr_node_get(struct batadv_priv *bat_priv,
13391339
* @bat_priv: the bat priv with all the soft interface information
13401340
* @skb: The multicast packet to check
13411341
* @orig: an originator to be set to forward the skb to
1342+
* @is_routable: stores whether the destination is routable
13421343
*
13431344
* Return: the forwarding mode as enum batadv_forw_mode and in case of
13441345
* BATADV_FORW_SINGLE set the orig to the single originator the skb
13451346
* should be forwarded to.
13461347
*/
13471348
enum batadv_forw_mode
13481349
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
1349-
struct batadv_orig_node **orig)
1350+
struct batadv_orig_node **orig, int *is_routable)
13501351
{
13511352
int ret, tt_count, ip_count, unsnoop_count, total_count;
13521353
bool is_unsnoopable = false;
13531354
unsigned int mcast_fanout;
13541355
struct ethhdr *ethhdr;
1355-
int is_routable = 0;
13561356
int rtr_count = 0;
13571357

13581358
ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable,
1359-
&is_routable);
1359+
is_routable);
13601360
if (ret == -ENOMEM)
13611361
return BATADV_FORW_NONE;
13621362
else if (ret < 0)
@@ -1369,7 +1369,7 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
13691369
ip_count = batadv_mcast_forw_want_all_ip_count(bat_priv, ethhdr);
13701370
unsnoop_count = !is_unsnoopable ? 0 :
13711371
atomic_read(&bat_priv->mcast.num_want_all_unsnoopables);
1372-
rtr_count = batadv_mcast_forw_rtr_count(bat_priv, is_routable);
1372+
rtr_count = batadv_mcast_forw_rtr_count(bat_priv, *is_routable);
13731373

13741374
total_count = tt_count + ip_count + unsnoop_count + rtr_count;
13751375

@@ -1689,6 +1689,7 @@ batadv_mcast_forw_want_rtr(struct batadv_priv *bat_priv,
16891689
* @bat_priv: the bat priv with all the soft interface information
16901690
* @skb: the multicast packet to transmit
16911691
* @vid: the vlan identifier
1692+
* @is_routable: stores whether the destination is routable
16921693
*
16931694
* Sends copies of a frame with multicast destination to any node that signaled
16941695
* interest in it, that is either via the translation table or the according
@@ -1701,7 +1702,7 @@ batadv_mcast_forw_want_rtr(struct batadv_priv *bat_priv,
17011702
* is neither IPv4 nor IPv6. NET_XMIT_SUCCESS otherwise.
17021703
*/
17031704
int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
1704-
unsigned short vid)
1705+
unsigned short vid, int is_routable)
17051706
{
17061707
int ret;
17071708

@@ -1717,12 +1718,16 @@ int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
17171718
return ret;
17181719
}
17191720

1721+
if (!is_routable)
1722+
goto skip_mc_router;
1723+
17201724
ret = batadv_mcast_forw_want_rtr(bat_priv, skb, vid);
17211725
if (ret != NET_XMIT_SUCCESS) {
17221726
kfree_skb(skb);
17231727
return ret;
17241728
}
17251729

1730+
skip_mc_router:
17261731
consume_skb(skb);
17271732
return ret;
17281733
}

net/batman-adv/multicast.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ enum batadv_forw_mode {
4343

4444
enum batadv_forw_mode
4545
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
46-
struct batadv_orig_node **mcast_single_orig);
46+
struct batadv_orig_node **mcast_single_orig,
47+
int *is_routable);
4748

4849
int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
4950
struct sk_buff *skb,
5051
unsigned short vid,
5152
struct batadv_orig_node *orig_node);
5253

5354
int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
54-
unsigned short vid);
55+
unsigned short vid, int is_routable);
5556

5657
void batadv_mcast_init(struct batadv_priv *bat_priv);
5758

@@ -68,7 +69,8 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node);
6869

6970
static inline enum batadv_forw_mode
7071
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
71-
struct batadv_orig_node **mcast_single_orig)
72+
struct batadv_orig_node **mcast_single_orig,
73+
int *is_routable)
7274
{
7375
return BATADV_FORW_ALL;
7476
}
@@ -85,7 +87,7 @@ batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
8587

8688
static inline int
8789
batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
88-
unsigned short vid)
90+
unsigned short vid, int is_routable)
8991
{
9092
kfree_skb(skb);
9193
return NET_XMIT_DROP;

net/batman-adv/soft-interface.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
198198
int gw_mode;
199199
enum batadv_forw_mode forw_mode = BATADV_FORW_SINGLE;
200200
struct batadv_orig_node *mcast_single_orig = NULL;
201+
int mcast_is_routable = 0;
201202
int network_offset = ETH_HLEN;
202203
__be16 proto;
203204

@@ -300,7 +301,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
300301
send:
301302
if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) {
302303
forw_mode = batadv_mcast_forw_mode(bat_priv, skb,
303-
&mcast_single_orig);
304+
&mcast_single_orig,
305+
&mcast_is_routable);
304306
if (forw_mode == BATADV_FORW_NONE)
305307
goto dropped;
306308

@@ -359,7 +361,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
359361
ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid,
360362
mcast_single_orig);
361363
} else if (forw_mode == BATADV_FORW_SOME) {
362-
ret = batadv_mcast_forw_send(bat_priv, skb, vid);
364+
ret = batadv_mcast_forw_send(bat_priv, skb, vid,
365+
mcast_is_routable);
363366
} else {
364367
if (batadv_dat_snoop_outgoing_arp_request(bat_priv,
365368
skb))

0 commit comments

Comments
 (0)