]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Set ifindex to find the correct nexthop 14218/head
authorPooja Jagadeesh Doijode <pdoijode@nvidia.com>
Wed, 16 Aug 2023 22:27:38 +0000 (15:27 -0700)
committerPooja Jagadeesh Doijode <pdoijode@nvidia.com>
Wed, 16 Aug 2023 22:27:38 +0000 (15:27 -0700)
Problem:
    On GR helper, paths learnt from an interface based peer were linked
    to bnc with ifindex=0. During restart of GR peer, BGP (unnumbered)
    session (with GR restarter peer) goes down on GR helper but the routes
    are retained. Later, when BGP receives an interface up event, it
    will process all the paths associated with BNC whose ifindex matches the
    ifindex of the interface for which UP event is received. However, paths
    associated with bnc that has ifindex=0 were not being reinstalled since
    ifindex=0 doesn't match ifindex of any interfaces. This results in
    BGP routes not being reinstalled in zebra and kernel.

Fix:
    For paths learnt from an interface based peer, set the
    ifindex to peer's interface ifindex so that correct
    peer based nexthop can be found and linked to the path.

Signed-off-by: Donald Sharp sharpd@nvidia.com
Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
bgpd/bgp_nht.c

index bbc30365c7fea78948f6debf574fcd4a2fde20b7..733dcc72a2d568c6127c25d0d80a513f11fa9c2c 100644 (file)
@@ -316,6 +316,14 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
                if (make_prefix(afi, pi, &p) < 0)
                        return 1;
 
+               /*
+                * If path is learnt from an interface based peer,
+                * set the ifindex to peer's interface index so that
+                * correct nexthop can be found in nexthop tree.
+                */
+               if (pi->peer->conf_if)
+                       ifindex = pi->peer->su.sin6.sin6_scope_id;
+
                if (!is_bgp_static_route && orig_prefix
                    && prefix_same(&p, orig_prefix)) {
                        if (BGP_DEBUG(nht, NHT)) {