mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-26 23:23:35 +00:00
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>
This commit is contained in:
parent
a23b92a8b0
commit
ebf1110cd7
@ -600,6 +600,7 @@ const char *const peer_down_str[] = {
|
|||||||
"Socket Error",
|
"Socket Error",
|
||||||
"Admin. shutdown (RTT)",
|
"Admin. shutdown (RTT)",
|
||||||
"Suppress Fib Turned On or Off",
|
"Suppress Fib Turned On or Off",
|
||||||
|
"Router ID is missing",
|
||||||
};
|
};
|
||||||
|
|
||||||
static void bgp_graceful_restart_timer_off(struct peer_connection *connection,
|
static void bgp_graceful_restart_timer_off(struct peer_connection *connection,
|
||||||
|
@ -568,7 +568,7 @@ static void bgp_accept(struct event *thread)
|
|||||||
|
|
||||||
/* Do not try to reconnect if the peer reached maximum
|
/* Do not try to reconnect if the peer reached maximum
|
||||||
* prefixes, restart timer is still running or the peer
|
* 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_PEER_START_SUPPRESSED(peer1)) {
|
||||||
if (bgp_debug_neighbor_events(peer1)) {
|
if (bgp_debug_neighbor_events(peer1)) {
|
||||||
@ -585,6 +585,14 @@ static void bgp_accept(struct event *thread)
|
|||||||
return;
|
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))
|
if (bgp_debug_neighbor_events(peer1))
|
||||||
zlog_debug("[Event] connection from %s fd %d, active peer status %d fd %d",
|
zlog_debug("[Event] connection from %s fd %d, active peer status %d fd %d",
|
||||||
inet_sutop(&su, buf), bgp_sock, connection1->status,
|
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));
|
assert(!CHECK_FLAG(connection->thread_flags, PEER_THREAD_READS_ON));
|
||||||
ifindex_t ifindex = 0;
|
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 (peer->conf_if && BGP_CONNECTION_SU_UNSPEC(connection)) {
|
||||||
if (bgp_debug_neighbor_events(peer))
|
if (bgp_debug_neighbor_events(peer))
|
||||||
zlog_debug("Peer address not learnt: Returning from connect");
|
zlog_debug("Peer address not learnt: Returning from connect");
|
||||||
|
@ -1768,6 +1768,7 @@ struct peer {
|
|||||||
#define PEER_DOWN_SOCKET_ERROR 34U /* Some socket error happened */
|
#define PEER_DOWN_SOCKET_ERROR 34U /* Some socket error happened */
|
||||||
#define PEER_DOWN_RTT_SHUTDOWN 35U /* Automatically shutdown due to RTT */
|
#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_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
|
* Remember to update peer_down_str in bgp_fsm.c when you add
|
||||||
* a new value to the last_reset reason
|
* a new value to the last_reset reason
|
||||||
|
Loading…
Reference in New Issue
Block a user