summaryrefslogtreecommitdiff
path: root/bgpd/bgp_network.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2025-03-17 14:52:42 +0200
committerDonatas Abraitis <donatas@opensourcerouting.org>2025-03-17 14:52:42 +0200
commitace4b8fe61df2bd8e0819b1624efa90e24f6452c (patch)
treec8526bbef8edaae3553d4a249cadeaa70960273a /bgpd/bgp_network.c
parentc288e5fbaf73bafb9aa15ade13969fc321e321db (diff)
bgpd: Print the real reason why the peer is not accepted (incoming)
If it's suppressed due to BFD down or unspecified connection, we never know the real reason and just say "no AF activated" which is misleading. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_network.c')
-rw-r--r--bgpd/bgp_network.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 4bcb41b8dc..1f4f4d52a2 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -389,6 +389,23 @@ static void bgp_socket_set_buffer_size(const int fd)
setsockopt_so_recvbuf(fd, bm->socket_buffer);
}
+static const char *bgp_peer_active2str(enum bgp_peer_active active)
+{
+ switch (active) {
+ case BGP_PEER_ACTIVE:
+ return "active";
+ case BGP_PEER_CONNECTION_UNSPECIFIED:
+ return "unspecified connection";
+ case BGP_PEER_BFD_DOWN:
+ return "BFD down";
+ case BGP_PEER_AF_UNCONFIGURED:
+ return "no AF activated";
+ }
+
+ assert(!"We should never get here this is a dev escape");
+ return "ERROR";
+}
+
/* Accept bgp connection. */
static void bgp_accept(struct event *thread)
{
@@ -400,6 +417,7 @@ static void bgp_accept(struct event *thread)
struct peer_connection *connection, *incoming;
char buf[SU_ADDRSTRLEN];
struct bgp *bgp = NULL;
+ enum bgp_peer_active active;
sockunion_init(&su);
@@ -508,7 +526,7 @@ static void bgp_accept(struct event *thread)
bgp_fsm_change_status(incoming, Active);
EVENT_OFF(incoming->t_start);
- if (peer_active(incoming)) {
+ if (peer_active(incoming) == BGP_PEER_ACTIVE) {
if (CHECK_FLAG(dynamic_peer->flags, PEER_FLAG_TIMER_DELAYOPEN))
BGP_EVENT_ADD(incoming, TCP_connection_open_w_delay);
else
@@ -559,10 +577,11 @@ static void bgp_accept(struct event *thread)
}
/* Check that at least one AF is activated for the peer. */
- if (!peer_active(connection)) {
+ active = peer_active(connection);
+ if (active != BGP_PEER_ACTIVE) {
if (bgp_debug_neighbor_events(peer))
- zlog_debug("%s - incoming conn rejected - no AF activated for peer",
- peer->host);
+ zlog_debug("%s - incoming conn rejected - %s", peer->host,
+ bgp_peer_active2str(active));
close(bgp_sock);
return;
}
@@ -662,7 +681,7 @@ static void bgp_accept(struct event *thread)
bgp_event_update(connection, TCP_connection_closed);
}
- if (peer_active(incoming)) {
+ if (peer_active(incoming) == BGP_PEER_ACTIVE) {
if (CHECK_FLAG(doppelganger->flags, PEER_FLAG_TIMER_DELAYOPEN))
BGP_EVENT_ADD(incoming, TCP_connection_open_w_delay);
else