summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-09-02 15:29:18 +0300
committerDonald Sharp <sharpd@nvidia.com>2021-09-02 09:18:19 -0400
commit7224dcd86a9e8bee0430801f16c137721b2fb8dc (patch)
tree883b5c384b7681e250be607ff6cae90850b71928
parente7682ccd1b4929a7b2690b2c2f49ec9d4cf18875 (diff)
bgpd: fix bgp_get_bound_name to handle views better
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>
-rw-r--r--bgpd/bgp_network.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 3c061ef1e0..7c9aa44c80 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -611,8 +611,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;
@@ -628,14 +626,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,