]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Set the TTL for the correct socket 14483/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 25 Sep 2023 14:07:56 +0000 (17:07 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 25 Sep 2023 19:25:32 +0000 (22:25 +0300)
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>
bgpd/bgp_network.c

index f322de76833fad845fdd7eb464a4b1eada8c8c2f..d831c6a781ae80280b60d4e3300f7df915223a8d 100644 (file)
@@ -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));