mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
zebra: Put NHE ref updating into a function
When the referenced NHE changes for a route_entry, use this function to handle it. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
parent
7f1abf7926
commit
144a1b34df
@ -1493,17 +1493,7 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re)
|
||||
|
||||
new_nhe = zebra_nhg_rib_find(0, &new_grp, re->vrf_id, rt_afi);
|
||||
|
||||
if (new_nhe && (re->nhe_id != new_nhe->id)) {
|
||||
struct nhg_hash_entry *old_nhe =
|
||||
zebra_nhg_lookup_id(re->nhe_id);
|
||||
|
||||
re->ng = new_nhe->nhg;
|
||||
re->nhe_id = new_nhe->id;
|
||||
|
||||
zebra_nhg_increment_ref(new_nhe);
|
||||
if (old_nhe)
|
||||
zebra_nhg_decrement_ref(old_nhe);
|
||||
}
|
||||
zebra_nhg_re_update_ref(re, new_nhe);
|
||||
}
|
||||
|
||||
if (curr_active) {
|
||||
@ -1532,6 +1522,27 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re)
|
||||
return curr_active;
|
||||
}
|
||||
|
||||
int zebra_nhg_re_update_ref(struct route_entry *re, struct nhg_hash_entry *new)
|
||||
{
|
||||
struct nhg_hash_entry *old = NULL;
|
||||
|
||||
if (!new)
|
||||
return -1;
|
||||
|
||||
if (re->nhe_id != new->id) {
|
||||
old = zebra_nhg_lookup_id(re->nhe_id);
|
||||
|
||||
re->ng = new->nhg;
|
||||
re->nhe_id = new->id;
|
||||
|
||||
zebra_nhg_increment_ref(new);
|
||||
if (old)
|
||||
zebra_nhg_decrement_ref(old);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Convert a nhe into a group array */
|
||||
uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp, struct nhg_hash_entry *nhe)
|
||||
{
|
||||
|
@ -229,6 +229,9 @@ void zebra_nhg_set_if(struct nhg_hash_entry *nhe, struct interface *ifp);
|
||||
|
||||
extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
|
||||
|
||||
extern int zebra_nhg_re_update_ref(struct route_entry *re,
|
||||
struct nhg_hash_entry *nhe);
|
||||
|
||||
extern uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp,
|
||||
struct nhg_hash_entry *nhe);
|
||||
|
||||
|
@ -2772,13 +2772,10 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
|
||||
XFREE(MTYPE_RE, re);
|
||||
return -1;
|
||||
}
|
||||
|
||||
re->nhe_id = nhe->id;
|
||||
}
|
||||
|
||||
/* Attach the re to the nhe's nexthop group */
|
||||
zebra_nhg_increment_ref(nhe);
|
||||
re->ng = nhe->nhg;
|
||||
zebra_nhg_re_update_ref(re, nhe);
|
||||
|
||||
/* Make it sure prefixlen is applied to the prefix. */
|
||||
apply_mask(p);
|
||||
|
Loading…
Reference in New Issue
Block a user