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>
/* BGP socket bind. */
static char *bgp_get_bound_name(struct peer *peer)
{
- char *name = NULL;
-
if (!peer)
return NULL;
* 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,