bgp: ignore NHT when bgpd has never connected to zebra

This commit is contained in:
Lou Berger 2016-10-07 09:44:42 -04:00 committed by Donald Sharp
parent 229dedb0c6
commit afbb1c59a3
3 changed files with 17 additions and 1 deletions

View File

@ -41,6 +41,7 @@
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_nht.h"
#include "bgpd/bgp_fsm.h"
#include "bgpd/bgp_zebra.h"
extern struct zclient *zclient;
@ -234,7 +235,8 @@ bgp_find_or_add_nexthop (struct bgp *bgp, afi_t afi, struct bgp_info *ri,
else if (peer)
bnc->nht_info = (void *)peer;
return (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID));
return (bgp_zebra_num_connects() == 0 ||
CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID));
}
void

View File

@ -109,6 +109,8 @@ bgp_install_info_to_zebra (struct bgp *bgp)
return 1;
}
int zclient_num_connects;
/* Router-id update message from zebra. */
static int
bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length,
@ -2087,6 +2089,8 @@ bgp_zebra_connected (struct zclient *zclient)
{
struct bgp *bgp;
zclient_num_connects++; /* increment even if not responding */
/* At this point, we may or may not have BGP instances configured, but
* we're only interested in the default VRF (others wouldn't have learnt
* the VRF from Zebra yet.)
@ -2109,6 +2113,8 @@ bgp_zebra_connected (struct zclient *zclient)
void
bgp_zebra_init (struct thread_master *master)
{
zclient_num_connects = 0;
/* Set default values. */
zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_BGP, 0);
@ -2143,3 +2149,9 @@ bgp_zebra_destroy(void)
zclient_free(zclient);
zclient = NULL;
}
int
bgp_zebra_num_connects(void)
{
return zclient_num_connects;
}

View File

@ -62,4 +62,6 @@ extern struct interface *if_lookup_by_ipv6 (struct in6_addr *, ifindex_t, vrf_id
extern struct interface *if_lookup_by_ipv6_exact (struct in6_addr *, ifindex_t, vrf_id_t);
#endif /* HAVE_IPV6 */
extern int bgp_zebra_num_connects(void);
#endif /* _QUAGGA_BGP_ZEBRA_H */