diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2014-05-19 23:15:02 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2014-05-19 23:25:46 +0200 |
commit | 5f9adb5d26d3af31b00c02084468e9f92b461b01 (patch) | |
tree | 640a6c4e855697777f672c384c37fffd5ae72d07 /bgpd | |
parent | ef0b0c3e95a1f30d6f338100c689feef8ad5cd6e (diff) | |
download | quagga-5f9adb5d26d3af31b00c02084468e9f92b461b01.tar.bz2 quagga-5f9adb5d26d3af31b00c02084468e9f92b461b01.tar.xz |
bgpd: factor out eBGP multihop check
The check for an eBGP multihop configuration is unwieldy; factor it out
into a separate function.
[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')
-rw-r--r-- | bgpd/bgpd.c | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 5e2a5e19..afd0dbd2 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4409,14 +4409,42 @@ peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi) } return 0; } - + +static int is_ebgp_multihop_configured (struct peer *peer) +{ + struct peer_group *group; + struct listnode *node, *nnode; + struct peer *peer1; + + if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) + { + group = peer->group; + if (group->conf->ttl != 1) + return 1; + + for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) + { + if (peer1->sort == BGP_PEER_IBGP) + continue; + + if (peer1->ttl != 1) + return 1; + } + } + else + { + if (peer->ttl != 1) + return 1; + } + return 0; +} + /* Set # of hops between us and BGP peer. */ int peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops) { struct peer_group *group; struct listnode *node, *nnode; - struct peer *peer1; int ret; zlog_debug ("peer_ttl_security_hops_set: set gtsm_hops to %d for %s", gtsm_hops, peer->host); @@ -4432,32 +4460,16 @@ peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops) mess of this configuration parameter, and OpenBGPD got it right. */ - if (peer->gtsm_hops == 0) { - if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) - { - group = peer->group; - if (group->conf->ttl != 1) - return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; - - for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) - { - if (peer1->sort == BGP_PEER_IBGP) - continue; + if (peer->gtsm_hops == 0) + { + if (is_ebgp_multihop_configured (peer)) + return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; - if (peer1->ttl != 1) - return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; - } - } - else - { - if (peer->ttl != 1) - return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; - } - /* specify MAXTTL on outgoing packets */ - ret = peer_ebgp_multihop_set (peer, MAXTTL); - if (ret != 0) - return ret; - } + /* specify MAXTTL on outgoing packets */ + ret = peer_ebgp_multihop_set (peer, MAXTTL); + if (ret != 0) + return ret; + } peer->gtsm_hops = gtsm_hops; |