Skip to content

Commit

Permalink
Merge pull request #4846 from vivek-cumulus/rfc-5549-gua-fix-ra
Browse files Browse the repository at this point in the history
Fix nexthop reg and RA enable for IPv4 route exchange using GUA IPv6 peering
  • Loading branch information
srimohans authored Aug 20, 2019
2 parents 8d3c0d3 + 5408e68 commit d1c6230
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
36 changes: 24 additions & 12 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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",
Expand Down
13 changes: 11 additions & 2 deletions bgpd/bgp_nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,28 +680,37 @@ 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;

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");
Expand Down

0 comments on commit d1c6230

Please sign in to comment.