diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2014-05-19 22:52:04 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2014-05-19 23:25:46 +0200 |
commit | ef0b0c3e95a1f30d6f338100c689feef8ad5cd6e (patch) | |
tree | 9848b1d05c2e1424e464cac41be51f32d7b87d78 /bgpd/bgp_network.c | |
parent | 8da8689d91a6436c17aca5000b1426aaea47e23c (diff) | |
download | quagga-ef0b0c3e95a1f30d6f338100c689feef8ad5cd6e.tar.bz2 quagga-ef0b0c3e95a1f30d6f338100c689feef8ad5cd6e.tar.xz |
bgpd: factor out TTL setting
TTL/min TTL are set from both bgp_accept() and bgp_connect(). Factor
them out so the following change to enable iBGP GTSM becomes more
readable.
[DL: originally by Dinesh G Dutt <ddutt@cumulusnetworks.com>,
split off from the next commit]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_network.c')
-rw-r--r-- | bgpd/bgp_network.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index d86db3c8..93bb1d9b 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -145,6 +145,16 @@ bgp_update_sock_send_buffer_size (int fd) } } +static void +bgp_set_socket_ttl (struct peer *peer, int bgp_sock) +{ + if (peer->sort == BGP_PEER_EBGP) { + sockopt_ttl (peer->su.sa.sa_family, bgp_sock, peer->ttl); + if (peer->gtsm_hops) + sockopt_minttl (peer->su.sa.sa_family, bgp_sock, MAXTTL + 1 - peer->gtsm_hops); + } +} + /* Accept bgp connection. */ static int bgp_accept (struct thread *thread) @@ -198,12 +208,7 @@ bgp_accept (struct thread *thread) return -1; } - /* In case of peer is EBGP, we should set TTL for this connection. */ - if (peer1->sort == BGP_PEER_EBGP) { - sockopt_ttl (peer1->su.sa.sa_family, bgp_sock, peer1->ttl); - if (peer1->gtsm_hops) - sockopt_minttl (peer1->su.sa.sa_family, bgp_sock, MAXTTL + 1 - peer1->gtsm_hops); - } + bgp_set_socket_ttl (peer1, bgp_sock); /* Make dummy peer until read Open packet. */ if (BGP_DEBUG (events, EVENTS)) @@ -336,12 +341,7 @@ bgp_connect (struct peer *peer) /* Set socket send buffer size */ bgp_update_sock_send_buffer_size(peer->fd); - /* If we can get socket for the peer, adjest TTL and make connection. */ - if (peer->sort == BGP_PEER_EBGP) { - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); - if (peer->gtsm_hops) - sockopt_minttl (peer->su.sa.sa_family, peer->fd, MAXTTL + 1 - peer->gtsm_hops); - } + bgp_set_socket_ttl (peer, peer->fd); sockopt_reuseaddr (peer->fd); sockopt_reuseport (peer->fd); |