Mailing List Archive

[PATCHv2] bgp: add bgp_isvalid_nexthop helper and additional NHT zebra checks (also restores check from original patch)
---
bgpd/bgp_nht.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index b5d830e..171cb20 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -52,6 +52,13 @@ static int make_prefix(int afi, struct bgp_info *ri, struct prefix *p);
static void path_nh_map(struct bgp_info *path, struct bgp_nexthop_cache *bnc,
int keep);

+static int
+bgp_isvalid_nexthop (struct bgp_nexthop_cache *bnc)
+{
+ return (bgp_zebra_num_connects() == 0 ||
+ (bnc && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID)));
+}
+
int
bgp_find_nexthop (struct bgp_info *path, int connected)
{
@@ -63,8 +70,7 @@ bgp_find_nexthop (struct bgp_info *path, int connected)
if (connected && !(CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)))
return 0;

- return (bgp_zebra_num_connects() == 0 ||
- CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID));
+ return (bgp_isvalid_nexthop(bnc));
}

static void
@@ -194,7 +200,7 @@ bgp_find_or_add_nexthop (afi_t afi, struct bgp_info *ri, struct peer *peer,
else if (peer)
bnc->nht_info = (void *)peer; /* NHT peer reference */

- return (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID));
+ return (bgp_isvalid_nexthop(bnc));
}

void
@@ -497,7 +503,7 @@ evaluate_paths (struct bgp_nexthop_cache *bnc)
* reachable/unreachable.
*/
if ((CHECK_FLAG(path->flags, BGP_INFO_VALID) ? 1 : 0) !=
- (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) ? 1 : 0))
+ (bgp_isvalid_nexthop(bnc) ? 1 : 0))
{
if (CHECK_FLAG (path->flags, BGP_INFO_VALID))
{
@@ -514,7 +520,7 @@ evaluate_paths (struct bgp_nexthop_cache *bnc)
}

/* Copy the metric to the path. Will be used for bestpath computation */
- if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) && bnc->metric)
+ if (bgp_isvalid_nexthop(bnc) && bnc->metric)
(bgp_info_extra_get(path))->igpmetric = bnc->metric;
else if (path->extra)
path->extra->igpmetric = 0;
--
2.1.3


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev