Commit e8fe9e83 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge tag 'batadv-net-pullrequest-20220103' of git://git.open-mesh.org/linux-merge

Simon Wunderlich says:

====================
Here is a batman-adv bugfix:

 - avoid sending link-local multicast to multicast routers,
   by Linus Lüssing

* tag 'batadv-net-pullrequest-20220103' of git://git.open-mesh.org/linux-merge:
  batman-adv: mcast: don't send link-local multicast to mcast routers
====================

Link: https://lore.kernel.org/r/20220103171203.1124980-1-sw@simonwunderlich.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 065e1ae0 938f2e0b
...@@ -1339,6 +1339,7 @@ batadv_mcast_forw_rtr_node_get(struct batadv_priv *bat_priv, ...@@ -1339,6 +1339,7 @@ batadv_mcast_forw_rtr_node_get(struct batadv_priv *bat_priv,
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @skb: The multicast packet to check * @skb: The multicast packet to check
* @orig: an originator to be set to forward the skb to * @orig: an originator to be set to forward the skb to
* @is_routable: stores whether the destination is routable
* *
* Return: the forwarding mode as enum batadv_forw_mode and in case of * Return: the forwarding mode as enum batadv_forw_mode and in case of
* BATADV_FORW_SINGLE set the orig to the single originator the skb * BATADV_FORW_SINGLE set the orig to the single originator the skb
...@@ -1346,17 +1347,16 @@ batadv_mcast_forw_rtr_node_get(struct batadv_priv *bat_priv, ...@@ -1346,17 +1347,16 @@ batadv_mcast_forw_rtr_node_get(struct batadv_priv *bat_priv,
*/ */
enum batadv_forw_mode enum batadv_forw_mode
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
struct batadv_orig_node **orig) struct batadv_orig_node **orig, int *is_routable)
{ {
int ret, tt_count, ip_count, unsnoop_count, total_count; int ret, tt_count, ip_count, unsnoop_count, total_count;
bool is_unsnoopable = false; bool is_unsnoopable = false;
unsigned int mcast_fanout; unsigned int mcast_fanout;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
int is_routable = 0;
int rtr_count = 0; int rtr_count = 0;
ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable, ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable,
&is_routable); is_routable);
if (ret == -ENOMEM) if (ret == -ENOMEM)
return BATADV_FORW_NONE; return BATADV_FORW_NONE;
else if (ret < 0) else if (ret < 0)
...@@ -1369,7 +1369,7 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -1369,7 +1369,7 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
ip_count = batadv_mcast_forw_want_all_ip_count(bat_priv, ethhdr); ip_count = batadv_mcast_forw_want_all_ip_count(bat_priv, ethhdr);
unsnoop_count = !is_unsnoopable ? 0 : unsnoop_count = !is_unsnoopable ? 0 :
atomic_read(&bat_priv->mcast.num_want_all_unsnoopables); atomic_read(&bat_priv->mcast.num_want_all_unsnoopables);
rtr_count = batadv_mcast_forw_rtr_count(bat_priv, is_routable); rtr_count = batadv_mcast_forw_rtr_count(bat_priv, *is_routable);
total_count = tt_count + ip_count + unsnoop_count + rtr_count; total_count = tt_count + ip_count + unsnoop_count + rtr_count;
...@@ -1689,6 +1689,7 @@ batadv_mcast_forw_want_rtr(struct batadv_priv *bat_priv, ...@@ -1689,6 +1689,7 @@ batadv_mcast_forw_want_rtr(struct batadv_priv *bat_priv,
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @skb: the multicast packet to transmit * @skb: the multicast packet to transmit
* @vid: the vlan identifier * @vid: the vlan identifier
* @is_routable: stores whether the destination is routable
* *
* Sends copies of a frame with multicast destination to any node that signaled * Sends copies of a frame with multicast destination to any node that signaled
* interest in it, that is either via the translation table or the according * 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, ...@@ -1701,7 +1702,7 @@ batadv_mcast_forw_want_rtr(struct batadv_priv *bat_priv,
* is neither IPv4 nor IPv6. NET_XMIT_SUCCESS otherwise. * is neither IPv4 nor IPv6. NET_XMIT_SUCCESS otherwise.
*/ */
int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid) unsigned short vid, int is_routable)
{ {
int ret; int ret;
...@@ -1717,12 +1718,16 @@ int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -1717,12 +1718,16 @@ int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
return ret; return ret;
} }
if (!is_routable)
goto skip_mc_router;
ret = batadv_mcast_forw_want_rtr(bat_priv, skb, vid); ret = batadv_mcast_forw_want_rtr(bat_priv, skb, vid);
if (ret != NET_XMIT_SUCCESS) { if (ret != NET_XMIT_SUCCESS) {
kfree_skb(skb); kfree_skb(skb);
return ret; return ret;
} }
skip_mc_router:
consume_skb(skb); consume_skb(skb);
return ret; return ret;
} }
......
...@@ -43,7 +43,8 @@ enum batadv_forw_mode { ...@@ -43,7 +43,8 @@ enum batadv_forw_mode {
enum batadv_forw_mode enum batadv_forw_mode
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
struct batadv_orig_node **mcast_single_orig); struct batadv_orig_node **mcast_single_orig,
int *is_routable);
int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb,
...@@ -51,7 +52,7 @@ int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, ...@@ -51,7 +52,7 @@ int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node); struct batadv_orig_node *orig_node);
int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid); unsigned short vid, int is_routable);
void batadv_mcast_init(struct batadv_priv *bat_priv); void batadv_mcast_init(struct batadv_priv *bat_priv);
...@@ -68,7 +69,8 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node); ...@@ -68,7 +69,8 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node);
static inline enum batadv_forw_mode static inline enum batadv_forw_mode
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
struct batadv_orig_node **mcast_single_orig) struct batadv_orig_node **mcast_single_orig,
int *is_routable)
{ {
return BATADV_FORW_ALL; return BATADV_FORW_ALL;
} }
...@@ -85,7 +87,7 @@ batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, ...@@ -85,7 +87,7 @@ batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
static inline int static inline int
batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid) unsigned short vid, int is_routable)
{ {
kfree_skb(skb); kfree_skb(skb);
return NET_XMIT_DROP; return NET_XMIT_DROP;
......
...@@ -198,6 +198,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, ...@@ -198,6 +198,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
int gw_mode; int gw_mode;
enum batadv_forw_mode forw_mode = BATADV_FORW_SINGLE; enum batadv_forw_mode forw_mode = BATADV_FORW_SINGLE;
struct batadv_orig_node *mcast_single_orig = NULL; struct batadv_orig_node *mcast_single_orig = NULL;
int mcast_is_routable = 0;
int network_offset = ETH_HLEN; int network_offset = ETH_HLEN;
__be16 proto; __be16 proto;
...@@ -300,7 +301,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, ...@@ -300,7 +301,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
send: send:
if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) { if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) {
forw_mode = batadv_mcast_forw_mode(bat_priv, skb, forw_mode = batadv_mcast_forw_mode(bat_priv, skb,
&mcast_single_orig); &mcast_single_orig,
&mcast_is_routable);
if (forw_mode == BATADV_FORW_NONE) if (forw_mode == BATADV_FORW_NONE)
goto dropped; goto dropped;
...@@ -359,7 +361,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, ...@@ -359,7 +361,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid, ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid,
mcast_single_orig); mcast_single_orig);
} else if (forw_mode == BATADV_FORW_SOME) { } else if (forw_mode == BATADV_FORW_SOME) {
ret = batadv_mcast_forw_send(bat_priv, skb, vid); ret = batadv_mcast_forw_send(bat_priv, skb, vid,
mcast_is_routable);
} else { } else {
if (batadv_dat_snoop_outgoing_arp_request(bat_priv, if (batadv_dat_snoop_outgoing_arp_request(bat_priv,
skb)) skb))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment