summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_evpn_mh.c12
-rw-r--r--bgpd/bgp_fsm.c1
-rw-r--r--bgpd/bgp_network.c17
-rw-r--r--bgpd/bgpd.c2
-rw-r--r--bgpd/bgpd.h1
5 files changed, 25 insertions, 8 deletions
diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c
index aa28b6f3d8..375687fe0f 100644
--- a/bgpd/bgp_evpn_mh.c
+++ b/bgpd/bgp_evpn_mh.c
@@ -1202,6 +1202,7 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
mpls_label_t label;
struct in_addr vtep_ip;
struct prefix_evpn p;
+ uint8_t num_labels = 0;
if (psize != BGP_EVPN_TYPE1_PSIZE) {
flog_err(EC_BGP_EVPN_ROUTE_INVALID,
@@ -1226,6 +1227,7 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
pfx += EVPN_ETH_TAG_BYTES;
memcpy(&label, pfx, BGP_LABEL_BYTES);
+ num_labels++;
/* EAD route prefix doesn't include the nexthop in the global
* table
@@ -1234,13 +1236,11 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
build_evpn_type1_prefix(&p, eth_tag, &esi, vtep_ip);
/* Process the route. */
if (attr) {
- bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
- safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
- 0, 0, NULL);
+ bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi, safi, ZEBRA_ROUTE_BGP,
+ BGP_ROUTE_NORMAL, &prd, &label, num_labels, 0, NULL);
} else {
- bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi,
- ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0,
- NULL);
+ bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi, ZEBRA_ROUTE_BGP,
+ BGP_ROUTE_NORMAL, &prd, &label, num_labels, NULL);
}
return 0;
}
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 7605501754..b07afaf384 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -603,6 +603,7 @@ const char *const peer_down_str[] = {
"Socket Error",
"Admin. shutdown (RTT)",
"Suppress Fib Turned On or Off",
+ "Router ID is missing",
};
static void bgp_graceful_restart_timer_off(struct peer_connection *connection,
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index e09dbc22af..a4be725937 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -568,7 +568,7 @@ static void bgp_accept(struct event *thread)
/* Do not try to reconnect if the peer reached maximum
* prefixes, restart timer is still running or the peer
- * is shutdown.
+ * is shutdown, or BGP identifier is not set (0.0.0.0).
*/
if (BGP_PEER_START_SUPPRESSED(peer1)) {
if (bgp_debug_neighbor_events(peer1)) {
@@ -585,6 +585,14 @@ static void bgp_accept(struct event *thread)
return;
}
+ if (peer1->bgp->router_id.s_addr == INADDR_ANY) {
+ zlog_warn("[Event] Incoming BGP connection rejected from %s due missing BGP identifier, set it with `bgp router-id`",
+ peer1->host);
+ peer1->last_reset = PEER_DOWN_ROUTER_ID_ZERO;
+ close(bgp_sock);
+ return;
+ }
+
if (bgp_debug_neighbor_events(peer1))
zlog_debug("[Event] connection from %s fd %d, active peer status %d fd %d",
inet_sutop(&su, buf), bgp_sock, connection1->status,
@@ -770,6 +778,13 @@ int bgp_connect(struct peer_connection *connection)
assert(!CHECK_FLAG(connection->thread_flags, PEER_THREAD_READS_ON));
ifindex_t ifindex = 0;
+ if (peer->bgp->router_id.s_addr == INADDR_ANY) {
+ peer->last_reset = PEER_DOWN_ROUTER_ID_ZERO;
+ zlog_warn("%s: BGP identifier is missing for peer %s, set it with `bgp router-id`",
+ __func__, peer->host);
+ return connect_error;
+ }
+
if (peer->conf_if && BGP_CONNECTION_SU_UNSPEC(connection)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug("Peer address not learnt: Returning from connect");
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 7c1be226b1..17a34dbacb 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3735,7 +3735,7 @@ int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as, const char *name,
/* Multiple instance check. */
if (name)
- bgp = bgp_lookup_by_name_filter(name, false);
+ bgp = bgp_lookup_by_name(name);
else
bgp = bgp_get_default();
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 61907140d9..a565a323b5 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1801,6 +1801,7 @@ struct peer {
#define PEER_DOWN_SOCKET_ERROR 34U /* Some socket error happened */
#define PEER_DOWN_RTT_SHUTDOWN 35U /* Automatically shutdown due to RTT */
#define PEER_DOWN_SUPPRESS_FIB_PENDING 36U /* Suppress fib pending changed */
+#define PEER_DOWN_ROUTER_ID_ZERO 37U /* router-id is 0.0.0.0 */
/*
* Remember to update peer_down_str in bgp_fsm.c when you add
* a new value to the last_reset reason