summaryrefslogtreecommitdiff
path: root/zebra/rt_netlink.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-07-06 11:19:05 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2022-07-06 11:19:05 +0200
commitafeb8524e296cc765ff11e28de126c342ac7852b (patch)
treecee3ac2f87dcd52451c4c97d8752a1936e819224 /zebra/rt_netlink.c
parent5adddad38f7716d7d118204b3ac39f5b18040305 (diff)
zebra: correctly ignore multicast nl msgs
zebra does not care about _notifications_ from the kernel regarding multicast routing; we only use the MR netlink API to request stats from the kernel by actively sending a RTM_GETROUTE. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r--zebra/rt_netlink.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index ce06f1683d..2f9d0ac887 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1044,7 +1044,6 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
struct rtmsg *rtm;
struct rtattr *tb[RTA_MAX + 1];
struct mcast_route_data *m;
- struct mcast_route_data mr;
int iif = 0;
int count;
int oif[256];
@@ -1053,12 +1052,8 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
vrf_id_t vrf;
int table;
- if (mroute)
- m = mroute;
- else {
- memset(&mr, 0, sizeof(mr));
- m = &mr;
- }
+ assert(mroute);
+ m = mroute;
rtm = NLMSG_DATA(h);
@@ -1165,9 +1160,19 @@ int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
return 0;
}
- if (!(rtm->rtm_family == AF_INET ||
- rtm->rtm_family == AF_INET6 ||
- rtm->rtm_family == RTNL_FAMILY_IPMR )) {
+ switch (rtm->rtm_family) {
+ case AF_INET:
+ case AF_INET6:
+ break;
+
+ case RTNL_FAMILY_IPMR:
+ case RTNL_FAMILY_IP6MR:
+ /* notifications on IPMR are irrelevant to zebra, we only care
+ * about responses to RTM_GETROUTE requests we sent.
+ */
+ return 0;
+
+ default:
flog_warn(
EC_ZEBRA_UNKNOWN_FAMILY,
"Invalid address family: %u received from kernel route change: %s",
@@ -1193,10 +1198,14 @@ int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
return -1;
}
+ /* these are "magic" kernel-managed *unicast* routes used for
+ * outputting locally generated multicast traffic (which uses unicast
+ * handling on Linux because ~reasons~.
+ */
if (rtm->rtm_type == RTN_MULTICAST)
- netlink_route_change_read_multicast(h, ns_id, startup);
- else
- netlink_route_change_read_unicast(h, ns_id, startup);
+ return 0;
+
+ netlink_route_change_read_unicast(h, ns_id, startup);
return 0;
}