summaryrefslogtreecommitdiffstats
path: root/pimd/pim_mroute.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-04-27 09:23:27 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2022-04-28 10:46:57 +0200
commitfef295d439236b2673ae4bb0d77f7681322b57f9 (patch)
treeebe268eb6ee99a25aca3062fc96f3cee37a8f994 /pimd/pim_mroute.c
parentMerge pull request #11031 from AbhishekNR/v6_multicast (diff)
downloadfrr-fef295d439236b2673ae4bb0d77f7681322b57f9.tar.xz
frr-fef295d439236b2673ae4bb0d77f7681322b57f9.zip
pim6d: use ICMP6_FILTER instead of BPF on mroute
The ICMP6_FILTER option is always checked by the kernel, so the cost is taken whether or not anything is set there. Use it instead of taking on additional cost with a BPF program. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'pimd/pim_mroute.c')
-rw-r--r--pimd/pim_mroute.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 43d05dfe9..7cad0d971 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -571,6 +571,27 @@ int pim_mroute_socket_enable(struct pim_instance *pim)
return -2;
}
+#if PIM_IPV == 6
+ struct icmp6_filter filter[1];
+ int ret;
+
+ /* Unlike IPv4, this socket is not used for MLD, so just drop
+ * everything with an empty ICMP6 filter. Otherwise we get
+ * all kinds of garbage here, possibly even non-multicast
+ * related ICMPv6 traffic (e.g. ping)
+ *
+ * (mroute kernel upcall "packets" are injected directly on the
+ * socket, this sockopt -or any other- has no effect on them)
+ */
+ ICMP6_FILTER_SETBLOCKALL(filter);
+ ret = setsockopt(fd, SOL_ICMPV6, ICMP6_FILTER, filter,
+ sizeof(filter));
+ if (ret)
+ zlog_err(
+ "(VRF %s) failed to set mroute control filter: %m",
+ pim->vrf->name);
+#endif
+
#ifdef SO_BINDTODEVICE
if (pim->vrf->vrf_id != VRF_DEFAULT
&& setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,