summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2023-09-25 17:07:56 +0300
committerDonatas Abraitis <donatas@opensourcerouting.org>2023-09-25 22:25:32 +0300
commit2853f14d0591122c8a31765b29b6c499d54c1c7c (patch)
tree3528194dbc8770db28e1d195e7674d0bd07dc40c
parent1c829fac8e034e9fc7f3ce778b853c9e62c825aa (diff)
bgpd: Set the TTL for the correct socket
When we accept a connection, we try to set TTL for the socket, but the socket is not yet created/assigned and we are trying to set it on the wrong socket fd. ``` [Event] connection from 127.0.0.1 fd 25, active peer status 3 fd -1 can't set sockopt IP_TTL 255 to socket -1 bgp_set_socket_ttl: Can't set TxTTL on peer (rtrid 0.0.0.0) socket, err = 9 Unable to set min/max TTL on peer 127.0.0.1, Continuing ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
-rw-r--r--bgpd/bgp_network.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index f322de7683..d831c6a781 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -588,12 +588,6 @@ static void bgp_accept(struct event *thread)
peer_delete(peer1->doppelganger);
}
- if (bgp_set_socket_ttl(peer1->connection) < 0)
- if (bgp_debug_neighbor_events(peer1))
- zlog_debug(
- "[Event] Unable to set min/max TTL on peer %s, Continuing",
- peer1->host);
-
peer = peer_create(&su, peer1->conf_if, peer1->bgp, peer1->local_as,
peer1->as, peer1->as_type, NULL, false, NULL);
@@ -617,6 +611,12 @@ static void bgp_accept(struct event *thread)
peer->doppelganger = peer1;
peer1->doppelganger = peer;
connection->fd = bgp_sock;
+
+ if (bgp_set_socket_ttl(connection) < 0)
+ if (bgp_debug_neighbor_events(peer))
+ zlog_debug("[Event] Unable to set min/max TTL on peer %s, Continuing",
+ peer->host);
+
frr_with_privs(&bgpd_privs) {
vrf_bind(peer->bgp->vrf_id, bgp_sock,
bgp_get_bound_name(peer->connection));