]> git.puffer.fish Git - mirror/frr.git/commitdiff
pbrd: nht only handle if updates if IPV*_IFINDEX nh
authorStephen Worley <sworley@nvidia.com>
Thu, 7 Jan 2021 20:28:28 +0000 (15:28 -0500)
committerStephen Worley <sworley@nvidia.com>
Mon, 1 Feb 2021 18:32:37 +0000 (13:32 -0500)
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 <sworley@nvidia.com>
pbrd/pbr_nht.c

index 723374d9d690e92df192643f37f7b3cc4efa6d78..5b79a3d2117e42b19f9ee93441ed085f93ebade1 100644 (file)
@@ -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;
        }