]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: fix bgp_get_bound_name to handle views better
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 2 Sep 2021 12:29:18 +0000 (15:29 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Fri, 3 Sep 2021 14:09:09 +0000 (17:09 +0300)
The vrf socket code needs a interface/vrf name to be passed
in, in order for it to properly bind to the correct vrf.
In the case where bgp is using a view based instance
the bgp_get_bound_name should handle views better and
not return anything to be bound to.

Fixes #9519.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
bgpd/bgp_network.c

index 137f0a6b59dca11a8bee219e66ca9e21d4a10693..ecaa1cd9513a6bf001a7af08728907b0c9fb0a73 100644 (file)
@@ -612,8 +612,6 @@ static int bgp_accept(struct thread *thread)
 /* BGP socket bind. */
 static char *bgp_get_bound_name(struct peer *peer)
 {
-       char *name = NULL;
-
        if (!peer)
                return NULL;
 
@@ -629,14 +627,16 @@ static char *bgp_get_bound_name(struct peer *peer)
         * takes precedence over VRF. For IPv4 peering, explicit interface or
         * VRF are the situations to bind.
         */
-       if (peer->su.sa.sa_family == AF_INET6)
-               name = (peer->conf_if ? peer->conf_if
-                                     : (peer->ifname ? peer->ifname
-                                                     : peer->bgp->name));
-       else
-               name = peer->ifname ? peer->ifname : peer->bgp->name;
+       if (peer->su.sa.sa_family == AF_INET6 && peer->conf_if)
+               return peer->conf_if;
+
+       if (peer->ifname)
+               return peer->ifname;
+
+       if (peer->bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+               return NULL;
 
-       return name;
+       return peer->bgp->name;
 }
 
 static int bgp_update_address(struct interface *ifp, const union sockunion *dst,