summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_network.c35
-rw-r--r--bgpd/bgpd.c17
-rw-r--r--lib/vrf.c7
-rw-r--r--lib/vrf.h1
4 files changed, 38 insertions, 22 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 3c061ef1e0..3005eba271 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;
- return name;
+ if (peer->ifname)
+ return peer->ifname;
+
+ if (peer->bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+ return NULL;
+
+ return peer->bgp->name;
}
static int bgp_update_address(struct interface *ifp, const union sockunion *dst,
@@ -706,7 +706,8 @@ int bgp_connect(struct peer *peer)
ifindex_t ifindex = 0;
if (peer->conf_if && BGP_PEER_SU_UNSPEC(peer)) {
- zlog_debug("Peer address not learnt: Returning from connect");
+ if (bgp_debug_neighbor_events(peer))
+ zlog_debug("Peer address not learnt: Returning from connect");
return 0;
}
frr_with_privs(&bgpd_privs) {
@@ -714,8 +715,13 @@ int bgp_connect(struct peer *peer)
peer->fd = vrf_sockunion_socket(&peer->su, peer->bgp->vrf_id,
bgp_get_bound_name(peer));
}
- if (peer->fd < 0)
+ if (peer->fd < 0) {
+ if (bgp_debug_neighbor_events(peer))
+ zlog_debug("%s: Failure to create socket for connection to %s, error received: %s(%d)",
+ __func__, peer->host, safe_strerror(errno),
+ errno);
return -1;
+ }
set_nonblocking(peer->fd);
@@ -725,8 +731,13 @@ int bgp_connect(struct peer *peer)
bgp_socket_set_buffer_size(peer->fd);
- if (bgp_set_socket_ttl(peer, peer->fd) < 0)
+ if (bgp_set_socket_ttl(peer, peer->fd) < 0) {
+ if (bgp_debug_neighbor_events(peer))
+ zlog_debug("%s: Failure to set socket ttl for connection to %s, error received: %s(%d)",
+ __func__, peer->host, safe_strerror(errno),
+ errno);
return -1;
+ }
sockopt_reuseaddr(peer->fd);
sockopt_reuseport(peer->fd);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 9004dff3b8..7236b9fe4b 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3409,8 +3409,21 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name,
return ret;
bgp = bgp_create(as, name, inst_type);
- if (bgp_option_check(BGP_OPT_NO_ZEBRA) && name)
- bgp->vrf_id = vrf_generate_id();
+
+ /*
+ * view instances will never work inside of a vrf
+ * as such they must always be in the VRF_DEFAULT
+ * Also we must set this to something useful because
+ * of the vrf socket code needing an actual useful
+ * default value to send to the underlying OS.
+ *
+ * This code is currently ignoring vrf based
+ * code using the -Z option( and that is probably
+ * best addressed elsewhere in the code )
+ */
+ if (inst_type == BGP_INSTANCE_TYPE_VIEW)
+ bgp->vrf_id = VRF_DEFAULT;
+
bgp_router_id_set(bgp, &bgp->router_id_zebra, true);
bgp_address_init(bgp);
bgp_tip_hash_init(bgp);
diff --git a/lib/vrf.c b/lib/vrf.c
index 79313d66d9..f9307d3039 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -1068,13 +1068,6 @@ int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id,
return ret;
}
-vrf_id_t vrf_generate_id(void)
-{
- static int vrf_id_local;
-
- return ++vrf_id_local;
-}
-
/* ------- Northbound callbacks ------- */
/*
diff --git a/lib/vrf.h b/lib/vrf.h
index f8b0148eb8..9949ec4112 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -323,7 +323,6 @@ extern int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,
extern void vrf_disable(struct vrf *vrf);
extern int vrf_enable(struct vrf *vrf);
extern void vrf_delete(struct vrf *vrf);
-extern vrf_id_t vrf_generate_id(void);
extern const struct frr_yang_module_info frr_vrf_info;