Skip to contentSkip to conversation

batman-adv: mcast: add option to forward MLD reports only to mcast routers

PATCH In review Linus Lüssing 2 participants 3 messages Aug 31, 2024 – Oct 7, 2024 Batman advanced

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: mcast: add option to forward MLD reports only to mcast routers

In most setups it is sufficient for us to only send MLD reports to nodes which have a multicast router attached. Which reduces overall overhead, especially in large batman-adv mesh networks, where broadcasts are particularly undesirable.

However there is one specific, known issue / broken scenario with this setting:

If the IGMP/MLD querier is configured directly on the bridge on top of bat0. But there is no multicast router on or behind this node. Then this bridge will be unable to detect multicast listeners on/behind other nodes which have the MLD-RTR-ONLY setting enabled. (A workaround for this can then in turn be to set multicast_router=2 on the bat0 bridge port on the node with the IGMP/MLD querier.)

Therefore MLD report flooding is kept the default and MLD report to multicast routers only forwarding is considered experimental and warned about.

---

An list of scenarios with illustrations and a step-by-step
evaluation with this setting for them can be found on the batman-adv wiki:
* https://www.open-mesh.org/projects/batman-adv/wiki/Multicast-IGMP-MLD-Report-Forwarding#section-2

This patchset is applied and tested on/between Freifunk Lübeck (180 nodes) and a small Freifunk Vogtland domain. It allowed using layer 3 IPv6 multicast routing here without flooding the whole mesh network with MLD reports.

 include/uapi/linux/batman_adv.h |  9 ++++++
 net/batman-adv/multicast.c      | 52 +++++++++++++++++++++++++--------
 net/batman-adv/netlink.c        | 17 +++++++++++
 net/batman-adv/soft-interface.c |  1 +
 net/batman-adv/types.h          |  7 +++++
 5 files changed, 74 insertions(+), 12 deletions(-)
include/uapi/linux/batman_adv.h +9 -0
index 35dc016c9bb4..11cd170036ff 100644
@@ -481,6 +481,15 @@ enum batadv_nl_attrs {
 	 */
 	BATADV_ATTR_MULTICAST_FANOUT,
 
+	/**
+	 * @BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED: defines how IGMP/MLD
+	 * reports are forwarded in the mesh. If set to non-zero then IGMP/MLD
+	 * reports are only forwarded to detected multicast routers. If set to
+	 * zero then they are flooded instead.
+	 * Warning: The former is experimental and potentially unsafe!
+	 */
+	BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED,
+
 	/* add attributes above here, update the policy in netlink.c */
 
 	/**
net/batman-adv/multicast.c +40 -12

114 lines not on this page · raw message

net/batman-adv/netlink.c +17 -0
index 3f0003fc502c..0923117d63b2 100644
@@ -145,6 +145,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
 	[BATADV_ATTR_LOG_LEVEL]			= { .type = NLA_U32 },
 	[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED]	= { .type = NLA_U8 },
 	[BATADV_ATTR_MULTICAST_FANOUT]		= { .type = NLA_U32 },
+	[BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED]	= { .type = NLA_U8 },
 	[BATADV_ATTR_NETWORK_CODING_ENABLED]	= { .type = NLA_U8 },
 	[BATADV_ATTR_ORIG_INTERVAL]		= { .type = NLA_U32 },
 	[BATADV_ATTR_ELP_INTERVAL]		= { .type = NLA_U32 },
@@ -345,6 +346,10 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg,
 	if (nla_put_u32(msg, BATADV_ATTR_MULTICAST_FANOUT,
 			atomic_read(&bat_priv->multicast_fanout)))
 		goto nla_put_failure;
+
+	if (nla_put_u8(msg, BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED,
+		       atomic_read(&bat_priv->multicast_mld_rtr_only)))
+		goto nla_put_failure;
 #endif /* CONFIG_BATMAN_ADV_MCAST */
 
 #ifdef CONFIG_BATMAN_ADV_NC
@@ -588,6 +593,18 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info)
 
 		atomic_set(&bat_priv->multicast_fanout, nla_get_u32(attr));
 	}
+
+	if (info->attrs[BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED]) {
+		u8 mld_rtr_only;
+
+		attr = info->attrs[BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED];
+		mld_rtr_only = !!nla_get_u8(attr);
+		if (mld_rtr_only)
+			batadv_info(bat_priv->soft_iface,
+				    "Warning: MLD-RTR-ONLY is experimental and has known, broken scenarios\n");
+
+		atomic_set(&bat_priv->multicast_mld_rtr_only, mld_rtr_only);
+	}
 #endif /* CONFIG_BATMAN_ADV_MCAST */
 
 #ifdef CONFIG_BATMAN_ADV_NC
net/batman-adv/soft-interface.c +1 -0
index 30ecbc2ef1fd..bd9168450995 100644
@@ -762,6 +762,7 @@ static int batadv_softif_init_late(struct net_device *dev)
 #ifdef CONFIG_BATMAN_ADV_MCAST
 	atomic_set(&bat_priv->multicast_mode, 1);
 	atomic_set(&bat_priv->multicast_fanout, 16);
+	atomic_set(&bat_priv->multicast_mld_rtr_only, 0);
 	atomic_set(&bat_priv->mcast.num_want_all_unsnoopables, 0);
 	atomic_set(&bat_priv->mcast.num_want_all_ipv4, 0);
 	atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0);
net/batman-adv/types.h +7 -0
index 00840d5784fe..bf8eab36e43b 100644
@@ -1683,6 +1683,13 @@ struct batadv_priv {
 	 *  multicast-to-unicast conversion
 	 */
 	atomic_t multicast_fanout;
+
+	/**
+	 * @multicast_mld_rtr_only: bool indicating whether to send IGMP/MLD
+	 *  reports only to multicast routers or to flood them otherwise.
+	 * Warning: The former is experimental and potentially unsafe!
+	 */
+	atomic_t multicast_mld_rtr_only;
 #endif
 
 	/** @orig_interval: OGM broadcast interval in milliseconds */
Signature · 1 line
2.45.2
maintainer
#1 lore raw
Quoted 4 lines · On Saturday, 31 August 2024 21:45:28 CEST Linus Lüssing wrote:

In most setups it is sufficient for us to only send MLD reports to nodes which have a multicast router attached. Which reduces overall overhead, especially in large batman-adv mesh networks, where broadcasts are particularly undesirable.

What is the situation before. How does this change try to modify the behavior. Why is this good?

It also doesn't mention anywhere that the old (multicast filter) behavior was just to handle IPv4/IPv6 messages and it is now expanded to IGMP_HOST_MEMBERSHIP_REPORT + ICMPV6_MGM_REPORT.

Quoted 11 lines

However there is one specific, known issue / broken scenario with this setting:

If the IGMP/MLD querier is configured directly on the bridge on top of bat0. But there is no multicast router on or behind this node. Then this bridge will be unable to detect multicast listeners on/behind other nodes which have the MLD-RTR-ONLY setting enabled. (A workaround for this can then in turn be to set multicast_router=2 on the bat0 bridge port on the node with the IGMP/MLD querier.)

Quoted 3 lines

Therefore MLD report flooding is kept the default and MLD report to multicast routers only forwarding is considered experimental and warned about.

Most of the text here seems to suggest that (whatever reason you want to enable it), you should most likely not do it because it just creates more problems.

The commit message doesn't show me why I should apply this change in the first place - especially when it just causes more headaches in the end.

Another headache I get is the "Warning: MLD-RTR-ONLY is experimental and has known, broken scenarios" part. Which seems to suggest to me that there might be changes in the future which will cause more problems if I just apply this patch now - and in this process create ABI incompatibilities or "no regression" conflicts later.

Btw. BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED seems to suggest that it is about MLD - but it seems to be also about IGMP. At least I didn't expect this.

Kind regards,
Sven

#2 lore raw
Quoted 7 lines · Sven Eckelmann
Quoted 4 lines · On Saturday, 31 August 2024 21:45:28 CEST Linus Lüssing wrote:

In most setups it is sufficient for us to only send MLD reports to nodes which have a multicast router attached. Which reduces overall overhead, especially in large batman-adv mesh networks, where broadcasts are particularly undesirable.

What is the situation before.

For Gluon the situation was that IGMP+MLD is filtered via ebtables, because it otherwise would have a significant broadcast overhead.

For batman-adv the situation was that IGMP+MLD got flooded so far.

Quoted 1 line

How does this change try to modify the behavior.

With this option a node would only send it to detected multicast routers instead.

Quoted 1 line

Why is this good?

I would like to enable layer 3 IPv6 multicast routing between Freifunk communities / Gluon domains. But without the broadcast flooding overhead, to stay somewhat scalable.

And the reason why I would want to do layer 3 multicast routing:
Right now multicast has a chicken & egg problem: There aren't many transmitters or receivers for it (other than ICMPv6 Neighbor Discovery or mDNS). However one strength of multicast lies in the significantly increased throughput when there are many simultaneous receivers.

So I'm hoping that while at Freifunk Lübeck with its ~200 nodes / ~200 clients domain I'm basically the only one using it that if there were all 40'000 Gluon nodes connected on layer 3 that the chances of a multicast stream being received by multiple people would significantly increase. Also more multicast content should then become available for everyone.

Quoted 4 lines

It also doesn't mention anywhere that the old (multicast filter) behavior was just to handle IPv4/IPv6 messages and it is now expanded to IGMP_HOST_MEMBERSHIP_REPORT + ICMPV6_MGM_REPORT.

Ok, maybe I should have written that more directly in the first two sentences.

Quoted 13 lines
Quoted 13 lines

However there is one specific, known issue / broken scenario with this setting:

If the IGMP/MLD querier is configured directly on the bridge on top of bat0. But there is no multicast router on or behind this node. Then this bridge will be unable to detect multicast listeners on/behind other nodes which have the MLD-RTR-ONLY setting enabled. (A workaround for this can then in turn be to set multicast_router=2 on the bat0 bridge port on the node with the IGMP/MLD querier.)

Quoted 7 lines
Quoted 3 lines

Therefore MLD report flooding is kept the default and MLD report to multicast routers only forwarding is considered experimental and warned about.

Most of the text here seems to suggest that (whatever reason you want to enable it), you should most likely not do it because it just creates more problems.

Right, in most cases I wouldn't suggest people to enable it. As can be seen in the wiki page examples it is not trivial. I would only suggest enabling it in setups where you have thoroughly checked your use-case against the ones in the wiki. And then only if you care about layer 3 multicast routing in the first place.

Quoted 11 lines

The commit message doesn't show me why I should apply this change in the first place - especially when it just causes more headaches in the end.

Another headache I get is the "Warning: MLD-RTR-ONLY is experimental and has known, broken scenarios" part. Which seems to suggest to me that there might be changes in the future which will cause more problems if I just apply this patch now - and in this process create ABI incompatibilities or "no regression" conflicts later.

I don't have any future ABI changes for this in mind. This was more thought as a warning that the list of examples in the wiki might not be exhaustive. I could only find one setup where enabling this option would not work, but despite having spent several days thinking about these scenarios I can't guarantee right now that it's the only one. That's why I wanted to mark it as experimental.

Quoted 3 lines

Btw. BATADV_ATTR_MULTICAST_MLD_RTR_ONLY_ENABLED seems to suggest that it is about MLD - but it seems to be also about IGMP. At least I didn't expect this.

Yeah, it's a bit annoying that for IPv4 it was named IGMP and for IPv6 it was then renamed to MLD even though the protocol is 99% the same thing. I'm not sure if it would make sense to make two separate knobs for IGMP and MLD? (I kind of more and more have the stance that where "legacy IP" creates extra hassle to ignore it where possible. And multicast with IPv4 is not as much fun as with IPv6 anyway, where you have things like embedded RP etc.)

Quoted 3 lines

Kind regards,
Sven