diff options
author | Stephen Worley <sworley@cumulusnetworks.com> | 2020-05-20 21:41:18 +0200 |
---|---|---|
committer | Stephen Worley <sworley@cumulusnetworks.com> | 2020-09-28 18:40:59 +0200 |
commit | 24db1a7b9a289993439a8975558b53d6910adb5c (patch) | |
tree | 8068aad93519669db7de8a5fea6b5d1d687d7627 /zebra/zebra_nhg.c | |
parent | zebra: inc/dec refcount on add/del NHG proto (diff) | |
download | frr-24db1a7b9a289993439a8975558b53d6910adb5c.tar.xz frr-24db1a7b9a289993439a8975558b53d6910adb5c.zip |
zebra: handle proto NHG uninstall client disconnect
Add code to handle proto-based NHG uninstalling after
the owning client disconnects.
This is handled the same way as rib_score_proto() but for now
we are ignoring instance.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_nhg.c')
-rw-r--r-- | zebra/zebra_nhg.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index d4d31d3ea..407af2902 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -2813,3 +2813,40 @@ struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id) return nhe; } +struct nhg_score_proto_iter { + int type; + unsigned long found; +}; + +static void zebra_nhg_score_proto_entry(struct hash_bucket *bucket, void *arg) +{ + struct nhg_hash_entry *nhe; + struct nhg_score_proto_iter *iter; + + nhe = (struct nhg_hash_entry *)bucket->data; + iter = arg; + + /* Needs to match type and outside zebra ID space */ + if (nhe->type == iter->type && nhe->id >= ZEBRA_NHG_PROTO_LOWER) { + if (IS_ZEBRA_DEBUG_NHG_DETAIL) + zlog_debug( + "%s: found nhe %p (%u), vrf %d, type %s after client disconnect", + __func__, nhe, nhe->id, nhe->vrf_id, + zebra_route_string(nhe->type)); + + /* This should be the last ref if we remove client routes too */ + zebra_nhg_decrement_ref(nhe); + } +} + +/* Remove specific by proto NHGs */ +unsigned long zebra_nhg_score_proto(int type) +{ + struct nhg_score_proto_iter iter = {}; + + iter.type = type; + + hash_iterate(zrouter.nhgs_id, zebra_nhg_score_proto_entry, &iter); + + return iter.found; +} |