summaryrefslogtreecommitdiff
path: root/zebra/zebra_rnh.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2019-11-22 15:30:53 -0500
committerMark Stapp <mjs@voltanet.io>2019-12-04 08:13:52 -0500
commit0eb97b860dc94329cf9add9f8f3d3a2c7f539568 (patch)
tree4382d83b863bbec02b3df6adf9060e7686a7a814 /zebra/zebra_rnh.c
parentf3323df26e425515fdcadf3aa9bd336bb54780b3 (diff)
lib,zebra: use nhg_hash_entry pointer in route_entry
Replace the existing list of nexthops (via a nexthop_group struct) in the route_entry with a direct pointer to zebra's new shared group (from zebra_nhg.h). This allows more direct access to that shared group and the info it carries. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'zebra/zebra_rnh.c')
-rw-r--r--zebra/zebra_rnh.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 60e23cc4d4..9a6631a59a 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -384,7 +384,7 @@ static void zebra_rnh_clear_nexthop_rnh_filters(struct route_entry *re)
struct nexthop *nexthop;
if (re) {
- for (nexthop = re->ng->nexthop; nexthop;
+ for (nexthop = re->nhe->nhg->nexthop; nexthop;
nexthop = nexthop->next) {
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_RNH_FILTERED);
}
@@ -403,7 +403,7 @@ static int zebra_rnh_apply_nht_rmap(afi_t afi, struct zebra_vrf *zvrf,
route_map_result_t ret;
if (prn && re) {
- for (nexthop = re->ng->nexthop; nexthop;
+ for (nexthop = re->nhe->nhg->nexthop; nexthop;
nexthop = nexthop->next) {
ret = zebra_nht_route_map_check(
afi, proto, &prn->p, zvrf, re, nexthop);
@@ -688,7 +688,7 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,
/* Just being SELECTED isn't quite enough - must
* have an installed nexthop to be useful.
*/
- for (ALL_NEXTHOPS_PTR(re->ng, nexthop)) {
+ for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) {
if (rnh_nexthop_valid(re, nexthop))
break;
}
@@ -707,7 +707,8 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,
break;
if (re->type == ZEBRA_ROUTE_NHRP) {
- for (nexthop = re->ng->nexthop; nexthop;
+ for (nexthop = re->nhe->nhg->nexthop;
+ nexthop;
nexthop = nexthop->next)
if (nexthop->type
== NEXTHOP_TYPE_IFINDEX)
@@ -940,7 +941,7 @@ static void free_state(vrf_id_t vrf_id, struct route_entry *re,
return;
/* free RE and nexthops */
- nexthop_group_delete(&re->ng);
+ zebra_nhg_free(re->nhe);
XFREE(MTYPE_RE, re);
}
@@ -963,9 +964,11 @@ static void copy_state(struct rnh *rnh, struct route_entry *re,
state->metric = re->metric;
state->vrf_id = re->vrf_id;
state->status = re->status;
- state->ng = nexthop_group_new();
- route_entry_copy_nexthops(state, re->ng->nexthop);
+ state->nhe = zebra_nhg_alloc();
+ state->nhe->nhg = nexthop_group_new();
+
+ nexthop_group_copy(state->nhe->nhg, re->nhe->nhg);
rnh->state = state;
}
@@ -983,11 +986,12 @@ static int compare_state(struct route_entry *r1, struct route_entry *r2)
if (r1->metric != r2->metric)
return 1;
- if (nexthop_group_nexthop_num(r1->ng)
- != nexthop_group_nexthop_num(r2->ng))
+ if (nexthop_group_nexthop_num(r1->nhe->nhg)
+ != nexthop_group_nexthop_num(r2->nhe->nhg))
return 1;
- if (nexthop_group_hash(r1->ng) != nexthop_group_hash(r2->ng))
+ if (nexthop_group_hash(r1->nhe->nhg) !=
+ nexthop_group_hash(r2->nhe->nhg))
return 1;
return 0;
@@ -1037,7 +1041,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 (ALL_NEXTHOPS_PTR(re->ng, nh))
+ for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nh))
if (rnh_nexthop_valid(re, nh)) {
stream_putl(s, nh->vrf_id);
stream_putc(s, nh->type);
@@ -1137,7 +1141,7 @@ static void print_rnh(struct route_node *rn, struct vty *vty)
if (rnh->state) {
vty_out(vty, " resolved via %s\n",
zebra_route_string(rnh->state->type));
- for (nexthop = rnh->state->ng->nexthop; nexthop;
+ for (nexthop = rnh->state->nhe->nhg->nexthop; nexthop;
nexthop = nexthop->next)
print_nh(nexthop, vty);
} else