diff options
| author | Stephen Worley <sworley@cumulusnetworks.com> | 2020-05-20 15:41:18 -0400 |
|---|---|---|
| committer | Stephen Worley <sworley@cumulusnetworks.com> | 2020-09-28 12:40:59 -0400 |
| commit | 24db1a7b9a289993439a8975558b53d6910adb5c (patch) | |
| tree | 8068aad93519669db7de8a5fea6b5d1d687d7627 /zebra/zebra_nhg.c | |
| parent | 6fae63d2bab3e5ee9f83458e32f4292165ef6cb6 (diff) | |
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 d4d31d3ea2..407af2902d 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; +} |
