Timo - I find using 'ebgp multihop X' for a ibgp neighbor a bit confusing. Can we add a 'neighbor <X> multihop <Y>' alias?
thanks! donald On Tue, Jul 7, 2015 at 9:53 AM, Timo Teräs <[email protected]> wrote: > Allow setting ebgp-multihop for iBGP. It will basically only set > TTL for iBGP connections as the other features of ebgp-multihop > affect only eBGP. This improves compatibility with other > implementations that allow setting TTL for all connections. > Enabling this has similar reasoning as for enabling gtsm for ibgp > (see commit 5d804b439a4138c77). > > Change also to track configured value in ->ttl and ->gtsm_hops; > not the value set to sockopt. Instead, setting of socket's ttl > and minttl options are now merged to one function which calculates > it on demand. This greatly simplifies the code. > > Signed-off-by: Timo Teräs <[email protected]> > --- > bgpd/bgp_network.c | 58 ++++++------- > bgpd/bgp_network.h | 1 + > bgpd/bgp_nexthop.c | 2 +- > bgpd/bgp_route.c | 6 +- > bgpd/bgp_vty.c | 29 ++----- > bgpd/bgp_zebra.c | 13 ++- > bgpd/bgpd.c | 236 > +++++++++++------------------------------------------ > bgpd/bgpd.h | 6 +- > 8 files changed, 93 insertions(+), 258 deletions(-) > > diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c > index 9765096..47fd26e 100644 > --- a/bgpd/bgp_network.c > +++ b/bgpd/bgp_network.c > @@ -145,47 +145,39 @@ bgp_update_sock_send_buffer_size (int fd) > } > } > > -static void > +void > bgp_set_socket_ttl (struct peer *peer, int bgp_sock) > { > char buf[INET_ADDRSTRLEN]; > - int ret; > + int ret, ttl, minttl; > > - /* In case of peer is EBGP, we should set TTL for this connection. */ > - if (!peer->gtsm_hops && (peer_sort (peer) == BGP_PEER_EBGP)) > + if (bgp_sock < 0) > + return; > + > + if (peer->gtsm_hops) > { > - ret = sockopt_ttl (peer->su.sa.sa_family, bgp_sock, peer->ttl); > - if (ret) > - { > - zlog_err ("%s: Can't set TxTTL on peer (rtrid %s) socket, err = > %d", > - __func__, > - inet_ntop (AF_INET, &peer->remote_id, buf, > sizeof(buf)), > - errno); > - } > + ttl = 255; > + minttl = 256 - peer->gtsm_hops; > } > - else if (peer->gtsm_hops) > + else > { > - /* On Linux, setting minttl without setting ttl seems to mess with > the > - outgoing ttl. Therefore setting both. > - */ > - ret = sockopt_ttl (peer->su.sa.sa_family, bgp_sock, MAXTTL); > - if (ret) > - { > - zlog_err ("%s: Can't set TxTTL on peer (rtrid %s) socket, err = > %d", > - __func__, > - inet_ntop (AF_INET, &peer->remote_id, buf, > sizeof(buf)), > - errno); > - } > - ret = sockopt_minttl (peer->su.sa.sa_family, bgp_sock, > - MAXTTL + 1 - peer->gtsm_hops); > - if (ret) > - { > - zlog_err ("%s: Can't set MinTTL on peer (rtrid %s) socket, err = > %d", > - __func__, > - inet_ntop (AF_INET, &peer->remote_id, buf, > sizeof(buf)), > - errno); > - } > + ttl = peer_ttl (peer); > + minttl = 0; > } > + > + ret = sockopt_ttl (peer->su.sa.sa_family, bgp_sock, ttl); > + if (ret) > + zlog_err ("%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d", > + __func__, > + inet_ntop (AF_INET, &peer->remote_id, buf, sizeof(buf)), > + errno); > + > + ret = sockopt_minttl (peer->su.sa.sa_family, bgp_sock, minttl); > + if (ret && (errno != ENOTSUP || minttl)) > + zlog_err ("%s: Can't set MinTTL on peer (rtrid %s) socket, err = %d", > + __func__, > + inet_ntop (AF_INET, &peer->remote_id, buf, sizeof(buf)), > + errno); > } > > /* Accept bgp connection. */ > diff --git a/bgpd/bgp_network.h b/bgpd/bgp_network.h > index 1276843..31995ca 100644 > --- a/bgpd/bgp_network.h > +++ b/bgpd/bgp_network.h > @@ -28,6 +28,7 @@ extern void bgp_close (void); > extern int bgp_connect (struct peer *); > extern void bgp_getsockname (struct peer *); > > +extern void bgp_set_socket_ttl (struct peer *peer, int bgp_sock); > extern int bgp_md5_set (struct peer *); > > #endif /* _QUAGGA_BGP_NETWORK_H */ > diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c > index 2a23d25..e4098ad 100644 > --- a/bgpd/bgp_nexthop.c > +++ b/bgpd/bgp_nexthop.c > @@ -434,7 +434,7 @@ bgp_scan (afi_t afi, safi_t safi) > changed = 0; > metricchanged = 0; > > - if (bi->peer->sort == BGP_PEER_EBGP && bi->peer->ttl == 1 > + if (bi->peer->sort == BGP_PEER_EBGP && peer_ttl (bi->peer) > == 1 > && !CHECK_FLAG(bi->peer->flags, > PEER_FLAG_DISABLE_CONNECTED_CHECK)) > valid = bgp_nexthop_onlink (afi, bi->attr); > else > diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c > index aa02d66..c941e39 100644 > --- a/bgpd/bgp_route.c > +++ b/bgpd/bgp_route.c > @@ -2165,7 +2165,7 @@ bgp_update_main (struct peer *peer, struct prefix > *p, struct attr *attr, > { > /* If the peer is EBGP and nexthop is not on connected route, > discard it. */ > - if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 > + if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 > && ! bgp_nexthop_onlink (afi, &new_attr) > && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) > { > @@ -2304,7 +2304,7 @@ bgp_update_main (struct peer *peer, struct prefix > *p, struct attr *attr, > && safi == SAFI_UNICAST > && (peer->sort == BGP_PEER_IBGP > || peer->sort == BGP_PEER_CONFED > - || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) > + || (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) != 1) > || CHECK_FLAG (peer->flags, > PEER_FLAG_DISABLE_CONNECTED_CHECK))) > { > if (bgp_find_or_add_nexthop (afi, ri, NULL, NULL)) > @@ -2345,7 +2345,7 @@ bgp_update_main (struct peer *peer, struct prefix > *p, struct attr *attr, > && safi == SAFI_UNICAST > && (peer->sort == BGP_PEER_IBGP > || peer->sort == BGP_PEER_CONFED > - || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) > + || (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) != 1) > || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) > { > if (bgp_find_or_add_nexthop (afi, new, NULL, NULL)) > diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c > index 4c35f9c..23b3fcc 100644 > --- a/bgpd/bgp_vty.c > +++ b/bgpd/bgp_vty.c > @@ -217,9 +217,6 @@ bgp_vty_return (struct vty *vty, int ret) > case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: > str = "ebgp-multihop and ttl-security cannot be configured > together"; > break; > - case BGP_ERR_NO_IBGP_WITH_TTLHACK: > - str = "ttl-security only allowed for EBGP peers"; > - break; > } > if (str) > { > @@ -2879,7 +2876,7 @@ peer_ebgp_multihop_unset_vty (struct vty *vty, const > char *ip_str) > if (! peer) > return CMD_WARNING; > > - return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); > + return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, 0)); > } > > /* neighbor ebgp-multihop. */ > @@ -4201,7 +4198,7 @@ DEFUN (no_neighbor_ttl_security, > if (! peer) > return CMD_WARNING; > > - return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); > + return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, 0)); > } > > /* Address family configuration. */ > @@ -7558,6 +7555,7 @@ bgp_show_peer (struct vty *vty, struct peer *p) > char timebuf[BGP_UPTIME_LEN]; > afi_t afi; > safi_t safi; > + int ttl; > > bgp = p->bgp; > > @@ -7853,21 +7851,12 @@ bgp_show_peer (struct vty *vty, struct peer *p) > } > > /* EBGP Multihop and GTSM */ > - if (p->sort != BGP_PEER_IBGP) > - { > - if (p->gtsm_hops > 0) > - vty_out (vty, " External BGP neighbor may be up to %d hops > away.%s", > - p->gtsm_hops, VTY_NEWLINE); > - else if (p->ttl > 1) > - vty_out (vty, " External BGP neighbor may be up to %d hops > away.%s", > - p->ttl, VTY_NEWLINE); > - } > - else > - { > - if (p->gtsm_hops > 0) > - vty_out (vty, " Internal BGP neighbor may be up to %d hops > away.%s", > - p->gtsm_hops, VTY_NEWLINE); > - } > + ttl = p->gtsm_hops; > + if (! ttl) > + ttl = peer_ttl (p); > + vty_out (vty, " %s BGP neighbor may be up to %d hops away.%s", > + p->sort == BGP_PEER_IBGP ? "Internal" : "External", > + ttl, VTY_NEWLINE); > > /* Local address. */ > if (p->su_local) > diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c > index c17bf53..b822a6f 100644 > --- a/bgpd/bgp_zebra.c > +++ b/bgpd/bgp_zebra.c > @@ -171,11 +171,10 @@ bgp_interface_down (int command, struct zclient > *zclient, zebra_size_t length) > > for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) > { > - if ((peer->ttl != 1) && (peer->gtsm_hops != 1)) > - continue; > - > - if (ifp == peer->nexthop.ifp) > - BGP_EVENT_ADD (peer, BGP_Stop); > + if (peer->gtsm_hops != 1 && peer_ttl (peer) != 1) > + continue; > + if (ifp == peer->nexthop.ifp) > + BGP_EVENT_ADD (peer, BGP_Stop); > } > } > } > @@ -695,7 +694,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info > *info, struct bgp *bgp, sa > SET_FLAG (flags, ZEBRA_FLAG_INTERNAL); > } > > - if ((peer->sort == BGP_PEER_EBGP && peer->ttl != 1) > + if ((peer->sort == BGP_PEER_EBGP && peer_ttl (peer) != 1) > || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) > SET_FLAG (flags, ZEBRA_FLAG_INTERNAL); > > @@ -859,7 +858,7 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info > *info, safi_t safi) > SET_FLAG (flags, ZEBRA_FLAG_IBGP); > } > > - if ((peer->sort == BGP_PEER_EBGP && peer->ttl != 1) > + if ((peer->sort == BGP_PEER_EBGP && peer_ttl (peer) != 1) > || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) > SET_FLAG (flags, ZEBRA_FLAG_INTERNAL); > > diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c > index b92a89e..2e57108 100644 > --- a/bgpd/bgpd.c > +++ b/bgpd/bgpd.c > @@ -621,7 +621,8 @@ peer_global_config_reset (struct peer *peer) > { > peer->weight = 0; > peer->change_local_as = 0; > - peer->ttl = (peer_sort (peer) == BGP_PEER_IBGP ? 255 : 1); > + peer->ttl = 0; > + peer->gtsm_hops = 0; > if (peer->update_source) > { > sockunion_free (peer->update_source); > @@ -875,9 +876,6 @@ peer_create (union sockunion *su, struct bgp *bgp, > as_t local_as, > /* Last read and reset time set */ > peer->readtime = peer->resettime = bgp_clock (); > > - /* Default TTL set. */ > - peer->ttl = (peer->sort == BGP_PEER_IBGP) ? 255 : 1; > - > /* Make peer's address string. */ > sockunion2str (su, buf, SU_ADDRSTRLEN); > peer->host = XSTRDUP (MTYPE_BGP_PEER_HOST, buf); > @@ -907,7 +905,6 @@ peer_create_accept (struct bgp *bgp) > static void > peer_as_change (struct peer *peer, as_t as) > { > - bgp_peer_sort_t type; > struct peer *conf; > > /* Stop peer. */ > @@ -922,7 +919,6 @@ peer_as_change (struct peer *peer, as_t as) > else > BGP_EVENT_ADD (peer, BGP_Stop); > } > - type = peer_sort (peer); > peer->as = as; > > if (bgp_config_check (peer->bgp, BGP_CONFIG_CONFEDERATION) > @@ -945,12 +941,6 @@ peer_as_change (struct peer *peer, as_t as) > else > peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; > > - /* TTL reset */ > - if (peer_sort (peer) == BGP_PEER_IBGP) > - peer->ttl = 255; > - else if (type == BGP_PEER_IBGP) > - peer->ttl = 1; > - > /* reflector-client reset */ > if (peer_sort (peer) != BGP_PEER_IBGP) > { > @@ -1400,7 +1390,7 @@ peer_group_get (struct bgp *bgp, const char *name) > group->conf->host = XSTRDUP (MTYPE_BGP_PEER_HOST, name); > group->conf->group = group; > group->conf->as = 0; > - group->conf->ttl = 1; > + group->conf->ttl = 0; > group->conf->gtsm_hops = 0; > group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; > UNSET_FLAG (group->conf->config, PEER_CONFIG_TIMER); > @@ -1701,6 +1691,16 @@ peer_group_remote_as (struct bgp *bgp, const char > *group_name, as_t *as) > } > > int > +peer_ttl (struct peer *peer) > +{ > + if (peer->ttl) > + return peer->ttl; > + if (peer->gtsm_hops || peer->sort == BGP_PEER_IBGP) > + return 255; > + return 1; > +} > + > +int > peer_group_delete (struct peer_group *group) > { > struct bgp *bgp; > @@ -1834,10 +1834,6 @@ peer_group_bind (struct bgp *bgp, union sockunion > *su, > group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; > } > > - /* ebgp-multihop reset */ > - if (peer_sort (group->conf) == BGP_PEER_IBGP) > - group->conf->ttl = 255; > - > /* local-as reset */ > if (peer_sort (group->conf) != BGP_PEER_EBGP) > { > @@ -2736,30 +2732,15 @@ peer_ebgp_multihop_set (struct peer *peer, int ttl) > struct listnode *node, *nnode; > struct peer *peer1; > > - if (peer->sort == BGP_PEER_IBGP) > - return 0; > + if (peer->gtsm_hops != 0) > + return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; > > - /* see comment in peer_ttl_security_hops_set() */ > - if (ttl != MAXTTL) > + if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) > { > - if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) > - { > - group = peer->group; > - if (group->conf->gtsm_hops != 0) > - 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 (peer1->gtsm_hops != 0) > - return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; > - } > - } > - else > + group = peer->group; > + for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) > { > - if (peer->gtsm_hops != 0) > + if (peer1->gtsm_hops != 0) > return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; > } > } > @@ -2768,62 +2749,18 @@ peer_ebgp_multihop_set (struct peer *peer, int ttl) > > if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) > { > - if (peer->fd >= 0 && peer->sort != BGP_PEER_IBGP) > - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); > + bgp_set_socket_ttl (peer, peer->fd); > } > else > { > group = peer->group; > for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) > - { > - if (peer->sort == BGP_PEER_IBGP) > - continue; > - > - peer->ttl = group->conf->ttl; > - > - if (peer->fd >= 0) > - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); > - } > - } > - return 0; > -} > - > -int > -peer_ebgp_multihop_unset (struct peer *peer) > -{ > - struct peer_group *group; > - struct listnode *node, *nnode; > - > - if (peer->sort == BGP_PEER_IBGP) > - return 0; > - > - if (peer->gtsm_hops != 0 && peer->ttl != MAXTTL) > - return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; > - > - if (peer_group_active (peer)) > - peer->ttl = peer->group->conf->ttl; > - else > - peer->ttl = 1; > - > - if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) > - { > - if (peer->fd >= 0 && peer->sort != BGP_PEER_IBGP) > - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); > + { > + peer->ttl = ttl; > + bgp_set_socket_ttl (peer, peer->fd); > + } > } > - else > - { > - group = peer->group; > - for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) > - { > - if (peer->sort == BGP_PEER_IBGP) > - continue; > > - peer->ttl = 1; > - > - if (peer->fd >= 0) > - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); > - } > - } > return 0; > } > > @@ -4510,78 +4447,41 @@ 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 ((peer_sort(peer) != BGP_PEER_IBGP) && > - (group->conf->ttl != 1)) > - return 1; > - > - for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) > - { > - if ((peer_sort (peer1) != BGP_PEER_IBGP) && > - (peer1->ttl != 1)) > - return 1; > - } > - } > - else > - { > - if ((peer_sort(peer) != BGP_PEER_IBGP) && > - (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; > - int ret; > + struct peer *peer1; > > zlog_debug ("peer_ttl_security_hops_set: set gtsm_hops to %d for %s", > gtsm_hops, peer->host); > > - /* We cannot configure ttl-security hops when ebgp-multihop is already > - set. For non peer-groups, the check is simple. For peer-groups, > it's > - slightly messy, because we need to check both the peer-group > structure > - and all peer-group members for any trace of ebgp-multihop > configuration > - before actually applying the ttl-security rules. Cisco really made a > - mess of this configuration parameter, and OpenBGPD got it right. > - */ > - > - if (peer->gtsm_hops == 0) > - { > - if (is_ebgp_multihop_configured (peer)) > - return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; > + if (peer->ttl != 0) > + return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; > > - /* specify MAXTTL on outgoing packets */ > - /* Routine handles iBGP peers correctly */ > - ret = peer_ebgp_multihop_set (peer, MAXTTL); > - if (ret != 0) > - return ret; > + if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) > + { > + group = peer->group; > + for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) > + { > + if (peer1->ttl != 0) > + return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; > + } > } > - > + > peer->gtsm_hops = gtsm_hops; > > if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) > { > - if (peer->fd >= 0) > - sockopt_minttl (peer->su.sa.sa_family, peer->fd, MAXTTL + 1 - > gtsm_hops); > + bgp_set_socket_ttl (peer, peer->fd); > } > else > { > group = peer->group; > for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) > { > - peer->gtsm_hops = group->conf->gtsm_hops; > + peer->gtsm_hops = gtsm_hops; > > /* Change setting of existing peer > * established then change value (may break connectivity) > @@ -4590,9 +4490,7 @@ peer_ttl_security_hops_set (struct peer *peer, int > gtsm_hops) > */ > if (peer->status == Established) > { > - if (peer->fd >= 0 && peer->gtsm_hops != 0) > - sockopt_minttl (peer->su.sa.sa_family, peer->fd, > - MAXTTL + 1 - peer->gtsm_hops); > + bgp_set_socket_ttl (peer, peer->fd); > } > else if (peer->status < Established) > { > @@ -4607,42 +4505,6 @@ peer_ttl_security_hops_set (struct peer *peer, int > gtsm_hops) > } > > int > -peer_ttl_security_hops_unset (struct peer *peer) > -{ > - struct peer_group *group; > - struct listnode *node, *nnode; > - struct peer *opeer; > - > - zlog_debug ("peer_ttl_security_hops_unset: set gtsm_hops to zero for > %s", peer->host); > - > - /* if a peer-group member, then reset to peer-group default rather than > 0 */ > - if (peer_group_active (peer)) > - peer->gtsm_hops = peer->group->conf->gtsm_hops; > - else > - peer->gtsm_hops = 0; > - > - opeer = peer; > - if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) > - { > - if (peer->fd >= 0) > - sockopt_minttl (peer->su.sa.sa_family, peer->fd, 0); > - } > - else > - { > - group = peer->group; > - for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) > - { > - peer->gtsm_hops = 0; > - > - if (peer->fd >= 0) > - sockopt_minttl (peer->su.sa.sa_family, peer->fd, 0); > - } > - } > - > - return peer_ebgp_multihop_unset (opeer); > -} > - > -int > peer_clear (struct peer *peer) > { > if (! CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) > @@ -4945,19 +4807,13 @@ bgp_config_write_peer (struct vty *vty, struct bgp > *bgp, > ! CHECK_FLAG (g_peer->flags, PEER_FLAG_PASSIVE)) > vty_out (vty, " neighbor %s passive%s", addr, VTY_NEWLINE); > > - /* EBGP multihop. */ > - if (peer->sort != BGP_PEER_IBGP && peer->ttl != 1 && > - !(peer->gtsm_hops != 0 && peer->ttl == MAXTTL)) > - if (! peer_group_active (peer) || > - g_peer->ttl != peer->ttl) > - vty_out (vty, " neighbor %s ebgp-multihop %d%s", addr, peer->ttl, > - VTY_NEWLINE); > - > - /* ttl-security hops */ > - if (peer->gtsm_hops != 0) > - if (! peer_group_active (peer) || g_peer->gtsm_hops != > peer->gtsm_hops) > - vty_out (vty, " neighbor %s ttl-security hops %d%s", addr, > - peer->gtsm_hops, VTY_NEWLINE); > + /* TTL option */ > + if (peer->gtsm_hops && ! peer_group_active (peer)) > + vty_out (vty, " neighbor %s ttl-security hops %d%s", addr, > + peer->gtsm_hops, VTY_NEWLINE); > + else if (peer->ttl && ! peer_group_active (peer)) > + vty_out (vty, " neighbor %s ebgp-multihop %d%s", addr, peer->ttl, > + VTY_NEWLINE); > > /* disable-connected-check. */ > if (CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) > diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h > index 58d1eca..36c5f36 100644 > --- a/bgpd/bgpd.h > +++ b/bgpd/bgpd.h > @@ -828,9 +828,8 @@ enum bgp_clear_type > #define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS -28 > #define BGP_ERR_TCPSIG_FAILED -29 > #define BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK -30 > -#define BGP_ERR_NO_IBGP_WITH_TTLHACK -31 > +#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS -31 > #define BGP_ERR_MAX -32 > -#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS -33 > > extern struct bgp_master *bm; > > @@ -902,6 +901,7 @@ extern int peer_rsclient_active (struct peer *); > > extern int peer_remote_as (struct bgp *, union sockunion *, as_t *, > afi_t, safi_t); > extern int peer_group_remote_as (struct bgp *, const char *, as_t *); > +extern int peer_ttl (struct peer *peer); > extern int peer_delete (struct peer *peer); > extern int peer_group_delete (struct peer_group *); > extern int peer_group_remote_as_delete (struct peer_group *); > @@ -922,7 +922,6 @@ extern int peer_af_flag_unset (struct peer *, afi_t, > safi_t, u_int32_t); > extern int peer_af_flag_check (struct peer *, afi_t, safi_t, u_int32_t); > > extern int peer_ebgp_multihop_set (struct peer *, int); > -extern int peer_ebgp_multihop_unset (struct peer *); > > extern int peer_description_set (struct peer *, char *); > extern int peer_description_unset (struct peer *); > @@ -984,6 +983,5 @@ extern int peer_clear (struct peer *); > extern int peer_clear_soft (struct peer *, afi_t, safi_t, enum > bgp_clear_type); > > extern int peer_ttl_security_hops_set (struct peer *, int); > -extern int peer_ttl_security_hops_unset (struct peer *); > > #endif /* _QUAGGA_BGPD_H */ > -- > 2.4.5 > > > _______________________________________________ > Quagga-dev mailing list > [email protected] > https://lists.quagga.net/mailman/listinfo/quagga-dev
_______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
