summaryrefslogtreecommitdiff
path: root/bgpd/bgp_network.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2025-01-29 23:03:06 +0200
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2025-02-04 16:37:55 +0000
commit46d210ce80e2bbabf3471114d70a9712eb9116f3 (patch)
treefe4d14591ee4cd9bfd26986304d0cbed89f3ee2b /bgpd/bgp_network.c
parent388f9ef0cbdfefb5e36a3719954e8f865bf3ce2a (diff)
bgpd: Do not start BGP session if BGP identifier is not set
If we have IPv6-only network and no IPv4 addresses at all, then by default 0.0.0.0 is created which is treated as malformed according to RFC 6286. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> (cherry picked from commit 739f2b566a8217acce84d4c21aaf033314f535bb)
Diffstat (limited to 'bgpd/bgp_network.c')
-rw-r--r--bgpd/bgp_network.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index af5d815d30..3df4aa286e 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -571,7 +571,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)) {
@@ -588,6 +588,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,
@@ -776,6 +784,13 @@ enum connect_result 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");