When updating a route's referenced NHE, accept a NULL value
as valid and clear out the pointer in the struct.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
int zebra_nhg_re_update_ref(struct route_entry *re, struct nhg_hash_entry *new)
{
struct nhg_hash_entry *old = NULL;
+ int ret = 0;
- if (!new)
- return -1;
+ if (new == NULL) {
+ re->ng = NULL;
+ goto done;
+ }
if (re->nhe_id != new->id) {
old = zebra_nhg_lookup_id(re->nhe_id);
zebra_nhg_decrement_ref(old);
}
- return 0;
+done:
+ return ret;
}
/* Convert a nhe into a group array */