提交 7a68cc16 编写于 作者: L Linus Lüssing 提交者: Simon Wunderlich

batman-adv: mcast: add MRD + routable IPv4 multicast with bridges support

This adds support for routable IPv4 multicast addresses
(224.0.0.0/4, excluding 224.0.0.0/24) in bridged setups.

This utilizes the Multicast Router Discovery (MRD, RFC4286) support
in the Linux bridge. batman-adv will now query the Linux bridge for
IPv4 multicast routers, which the bridge has previously learned about
via MRD.

This allows us to then safely send routable IPv4 multicast packets in
bridged setups to multicast listeners and multicast routers only. Before
we had to flood such packets to avoid potential multicast packet loss to
IPv4 multicast routers, which we were not able to detect before.

With the bridge MRD integration, we are now also able to perform more
fine-grained detection of IPv6 multicast routers in bridged setups:
Before we were "guessing" IPv6 multicast routers by looking up multicast
listeners for the link-local All Routers multicast address (ff02::2),
which every IPv6 multicast router is listening to. However this would
also include more nodes than necessary: For instance nodes which are
just a router for unicast, but not multicast would be included, too.
Signed-off-by: NLinus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: NSven Eckelmann <sven@narfation.org>
Signed-off-by: NSimon Wunderlich <sw@simonwunderlich.de>
上级 4cbf0550
...@@ -193,53 +193,22 @@ static u8 batadv_mcast_mla_rtr_flags_softif_get(struct batadv_priv *bat_priv, ...@@ -193,53 +193,22 @@ static u8 batadv_mcast_mla_rtr_flags_softif_get(struct batadv_priv *bat_priv,
* BATADV_MCAST_WANT_NO_RTR6: No IPv6 multicast router is present * BATADV_MCAST_WANT_NO_RTR6: No IPv6 multicast router is present
* The former two OR'd: no multicast router is present * The former two OR'd: no multicast router is present
*/ */
#if IS_ENABLED(CONFIG_IPV6)
static u8 batadv_mcast_mla_rtr_flags_bridge_get(struct batadv_priv *bat_priv, static u8 batadv_mcast_mla_rtr_flags_bridge_get(struct batadv_priv *bat_priv,
struct net_device *bridge) struct net_device *bridge)
{ {
struct list_head bridge_mcast_list = LIST_HEAD_INIT(bridge_mcast_list);
struct net_device *dev = bat_priv->soft_iface; struct net_device *dev = bat_priv->soft_iface;
struct br_ip_list *br_ip_entry, *tmp; u8 flags = BATADV_NO_FLAGS;
u8 flags = BATADV_MCAST_WANT_NO_RTR6;
int ret;
if (!bridge) if (!bridge)
return BATADV_MCAST_WANT_NO_RTR4 | BATADV_MCAST_WANT_NO_RTR6; return BATADV_MCAST_WANT_NO_RTR4 | BATADV_MCAST_WANT_NO_RTR6;
/* TODO: ask the bridge if a multicast router is present (the bridge if (!br_multicast_has_router_adjacent(dev, ETH_P_IP))
* is capable of performing proper RFC4286 multicast router flags |= BATADV_MCAST_WANT_NO_RTR4;
* discovery) instead of searching for a ff02::2 listener here if (!br_multicast_has_router_adjacent(dev, ETH_P_IPV6))
*/ flags |= BATADV_MCAST_WANT_NO_RTR6;
ret = br_multicast_list_adjacent(dev, &bridge_mcast_list);
if (ret < 0)
return BATADV_NO_FLAGS;
list_for_each_entry_safe(br_ip_entry, tmp, &bridge_mcast_list, list) {
/* the bridge snooping does not maintain IPv4 link-local
* addresses - therefore we won't find any IPv4 multicast router
* address here, only IPv6 ones
*/
if (br_ip_entry->addr.proto == htons(ETH_P_IPV6) &&
ipv6_addr_is_ll_all_routers(&br_ip_entry->addr.dst.ip6))
flags &= ~BATADV_MCAST_WANT_NO_RTR6;
list_del(&br_ip_entry->list);
kfree(br_ip_entry);
}
return flags; return flags;
} }
#else
static inline u8
batadv_mcast_mla_rtr_flags_bridge_get(struct batadv_priv *bat_priv,
struct net_device *bridge)
{
if (bridge)
return BATADV_NO_FLAGS;
else
return BATADV_MCAST_WANT_NO_RTR4 | BATADV_MCAST_WANT_NO_RTR6;
}
#endif
/** /**
* batadv_mcast_mla_rtr_flags_get() - get multicast router flags * batadv_mcast_mla_rtr_flags_get() - get multicast router flags
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册