mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-26 05:09:12 +00:00
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>
This commit is contained in:
parent
6fae63d2ba
commit
24db1a7b9a
@ -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;
|
||||
}
|
||||
|
||||
@ -285,6 +285,14 @@ struct nhg_hash_entry *zebra_nhg_proto_add(uint32_t id, int type,
|
||||
*/
|
||||
struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id);
|
||||
|
||||
/*
|
||||
* Remove specific by proto NHGs.
|
||||
*
|
||||
* Called after client disconnect.
|
||||
*
|
||||
*/
|
||||
unsigned long zebra_nhg_score_proto(int type);
|
||||
|
||||
/* Reference counter functions */
|
||||
extern void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe);
|
||||
extern void zebra_nhg_increment_ref(struct nhg_hash_entry *nhe);
|
||||
|
||||
@ -590,6 +590,7 @@ static void zserv_client_free(struct zserv *client)
|
||||
/* Close file descriptor. */
|
||||
if (client->sock) {
|
||||
unsigned long nroutes;
|
||||
unsigned long nnhgs;
|
||||
|
||||
close(client->sock);
|
||||
|
||||
@ -600,6 +601,13 @@ static void zserv_client_free(struct zserv *client)
|
||||
"client %d disconnected %lu %s routes removed from the rib",
|
||||
client->sock, nroutes,
|
||||
zebra_route_string(client->proto));
|
||||
|
||||
/* Not worrying about instance for now */
|
||||
nnhgs = zebra_nhg_score_proto(client->proto);
|
||||
zlog_notice(
|
||||
"client %d disconnected %lu %s nhgs removed from the rib",
|
||||
client->sock, nnhgs,
|
||||
zebra_route_string(client->proto));
|
||||
}
|
||||
client->sock = -1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user