diff options
author | Sri Mohana Singamsetty <srimohans@gmail.com> | 2019-08-20 18:07:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-20 18:07:54 +0200 |
commit | d1c6230236d0f9c90db1e48b396446e02893e2cc (patch) | |
tree | 9614c120d08fa03b62644c230f0ae6ad19d8b4fe /bgpd | |
parent | Merge pull request #4848 from donaldsharp/spelling_errors (diff) | |
parent | bgpd: Display peer info in NHT output (diff) | |
download | frr-d1c6230236d0f9c90db1e48b396446e02893e2cc.tar.xz frr-d1c6230236d0f9c90db1e48b396446e02893e2cc.zip |
Merge pull request #4846 from vivek-cumulus/rfc-5549-gua-fix-ra
Fix nexthop reg and RA enable for IPv4 route exchange using GUA IPv6 peering
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_fsm.c | 36 | ||||
-rw-r--r-- | bgpd/bgp_nexthop.c | 13 |
2 files changed, 35 insertions, 14 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 4348e6b24..c9c6fc157 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -96,6 +96,21 @@ static int bgp_holdtime_timer(struct thread *); /* BGP FSM functions. */ static int bgp_start(struct peer *); +/* Register peer with NHT */ +static int bgp_peer_reg_with_nht(struct peer *peer) +{ + int connected = 0; + + if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 + && !CHECK_FLAG(peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) + && !bgp_flag_check(peer->bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) + connected = 1; + + return bgp_find_or_add_nexthop( + peer->bgp, peer->bgp, family2afi(peer->su.sa.sa_family), + NULL, peer, connected); +} + static void peer_xfer_stats(struct peer *peer_dst, struct peer *peer_src) { /* Copy stats over. These are only the pre-established state stats */ @@ -293,6 +308,11 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) if (from_peer) peer_xfer_stats(peer, from_peer); + /* Register peer for NHT. This is to allow RAs to be enabled when + * needed, even on a passive connection. + */ + bgp_peer_reg_with_nht(peer); + bgp_reads_on(peer); bgp_writes_on(peer); thread_add_timer_msec(bm->master, bgp_process_packet, peer, 0, @@ -1382,7 +1402,6 @@ static int bgp_connect_fail(struct peer *peer) int bgp_start(struct peer *peer) { int status; - int connected = 0; bgp_peer_conf_if_to_su_update(peer); @@ -1439,17 +1458,10 @@ int bgp_start(struct peer *peer) return -1; } - /* Register to be notified on peer up */ - if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 - && !CHECK_FLAG(peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) - && !bgp_flag_check(peer->bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) - connected = 1; - else - connected = 0; - - if (!bgp_find_or_add_nexthop(peer->bgp, peer->bgp, - family2afi(peer->su.sa.sa_family), NULL, - peer, connected)) { + /* Register peer for NHT. If next hop is already resolved, proceed + * with connection setup, else wait. + */ + if (!bgp_peer_reg_with_nht(peer)) { if (bgp_zebra_num_connects()) { if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [FSM] Waiting for NHT", diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index a8c507832..812f0ce16 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -680,17 +680,23 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail, continue; for (rn = bgp_table_top(table[afi]); rn; rn = bgp_route_next(rn)) { + struct peer *peer; + bnc = bgp_node_get_bgp_nexthop_info(rn); if (!bnc) continue; + peer = (struct peer *)bnc->nht_info; if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID)) { vty_out(vty, - " %s valid [IGP metric %d], #paths %d\n", + " %s valid [IGP metric %d], #paths %d", inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf)), bnc->metric, bnc->path_count); + if (peer) + vty_out(vty, ", peer %s", peer->host); + vty_out(vty, "\n"); if (!detail) continue; @@ -698,10 +704,13 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail, bgp_show_nexthops_detail(vty, bgp, bnc); } else { - vty_out(vty, " %s invalid\n", + vty_out(vty, " %s invalid", inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf))); + if (peer) + vty_out(vty, ", peer %s", peer->host); + vty_out(vty, "\n"); if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) vty_out(vty, " Must be Connected\n"); |