diff options
Diffstat (limited to 'zebra/zebra_rnh.c')
| -rw-r--r-- | zebra/zebra_rnh.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index e92cd8bb8a..c3781888b1 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -178,11 +178,15 @@ void zebra_free_rnh(struct rnh *rnh) XFREE(MTYPE_RNH, rnh); } -void zebra_delete_rnh(struct rnh *rnh, rnh_type_t type) +static void zebra_delete_rnh(struct rnh *rnh, rnh_type_t type) { struct route_node *rn; - if (!rnh || (rnh->flags & ZEBRA_NHT_DELETED) || !(rn = rnh->node)) + if (!list_isempty(rnh->client_list) + || !list_isempty(rnh->zebra_pseudowire_list)) + return; + + if ((rnh->flags & ZEBRA_NHT_DELETED) || !(rn = rnh->node)) return; if (IS_ZEBRA_DEBUG_NHT) { @@ -233,9 +237,7 @@ void zebra_remove_rnh_client(struct rnh *rnh, struct zserv *client, rnh_str(rnh, buf, sizeof(buf)), type); } listnode_delete(rnh->client_list, client); - if (list_isempty(rnh->client_list) - && list_isempty(rnh->zebra_pseudowire_list)) - zebra_delete_rnh(rnh, type); + zebra_delete_rnh(rnh, type); } /* XXX move this utility function elsewhere? */ @@ -291,9 +293,7 @@ void zebra_deregister_rnh_pseudowire(vrf_id_t vrf_id, struct zebra_pw *pw) listnode_delete(rnh->zebra_pseudowire_list, pw); pw->rnh = NULL; - if (list_isempty(rnh->client_list) - && list_isempty(rnh->zebra_pseudowire_list)) - zebra_delete_rnh(rnh, RNH_NEXTHOP_TYPE); + zebra_delete_rnh(rnh, RNH_NEXTHOP_TYPE); } /* Apply the NHT route-map for a client to the route (and nexthops) @@ -528,8 +528,7 @@ static void zebra_rnh_process_pbr_tables(int family, */ static bool rnh_nexthop_valid(const struct nexthop *nh) { - return ((CHECK_FLAG(nh->flags, NEXTHOP_FLAG_FIB) - || CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE)) + return (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_FIB) && CHECK_FLAG(nh->flags, NEXTHOP_FLAG_ACTIVE)); } @@ -581,8 +580,7 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, int family, /* Just being SELECTED isn't quite enough - must * have an installed nexthop to be useful. */ - for (nexthop = re->ng.nexthop; nexthop; - nexthop = nexthop->next) { + for (ALL_NEXTHOPS(re->ng, nexthop)) { if (rnh_nexthop_valid(nexthop)) break; } @@ -915,7 +913,7 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type, num = 0; nump = stream_get_endp(s); stream_putc(s, 0); - for (nh = re->ng.nexthop; nh; nh = nh->next) + for (ALL_NEXTHOPS(re->ng, nh)) if (rnh_nexthop_valid(nh)) { stream_putl(s, nh->vrf_id); stream_putc(s, nh->type); |
