From: Stephen Worley Date: Thu, 7 Jan 2021 20:28:28 +0000 (-0500) Subject: pbrd: nht only handle if updates if IPV*_IFINDEX nh X-Git-Tag: base_8.0~408^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=e6b00e3fb9d40e33e4d756e5f5ef35b4b4cd07b4;p=mirror%2Ffrr.git pbrd: nht only handle if updates if IPV*_IFINDEX nh Only handle an interface update in the nexthop tracking code if the nexthop in question was set with an interface to point out of. If the nexthop is GW only, the interface update could be unrelated but have overlapping address space. Let that be handled elsewhere. Ex) ``` 5.5.5.0/30 dev dummyDoof proto kernel scope link src 5.5.5.1 5.5.5.0/24 dev goofDummy proto kernel scope link src 5.5.5.1 [root@alfred frr-2]# ip ro show table 10000 default via 5.5.5.2 dev dummyDoof proto pbr metric 20 [root@alfred frr-2]# ip link set goofDummy down [root@alfred frr-2]# ip ro show table 10000 [root@alfred frr-2]# ip link set goofDummy up [root@alfred frr-2]# ip ro show table 10000 ``` Signed-off-by: Stephen Worley --- diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index 723374d9d6..5b79a3d211 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -711,7 +711,6 @@ pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc, struct pbr_nht_individual *pnhi) { bool is_valid = pnhc->valid; - bool all_done = false; /* * If we have an interface down event, let's note that @@ -723,43 +722,21 @@ pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc, * interface event. */ if (!pnhi->nhr && pnhi->ifp) { - struct connected *connected; - struct listnode *node; - struct prefix p; - switch (pnhc->nexthop.type) { case NEXTHOP_TYPE_BLACKHOLE: - all_done = true; + case NEXTHOP_TYPE_IPV4: + case NEXTHOP_TYPE_IPV6: + goto done; break; case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IPV4_IFINDEX: case NEXTHOP_TYPE_IPV6_IFINDEX: - is_valid = if_is_up(pnhi->ifp); - all_done = true; - break; - case NEXTHOP_TYPE_IPV4: - p.family = AF_INET; - p.prefixlen = IPV4_MAX_BITLEN; - p.u.prefix4 = pnhc->nexthop.gate.ipv4; - break; - case NEXTHOP_TYPE_IPV6: - p.family = AF_INET6; - p.prefixlen = IPV6_MAX_BITLEN; - memcpy(&p.u.prefix6, &pnhc->nexthop.gate.ipv6, - sizeof(struct in6_addr)); + if (pnhc->nexthop.ifindex == pnhi->ifp->ifindex) + is_valid = if_is_up(pnhi->ifp); + goto done; break; } - /* Early exit in a couple of cases. */ - if (all_done) - goto done; - - FOR_ALL_INTERFACES_ADDRESSES (pnhi->ifp, connected, node) { - if (prefix_match(connected->address, &p)) { - is_valid = if_is_up(pnhi->ifp); - break; - } - } goto done; }