diff options
| author | Mark Stapp <mjs@voltanet.io> | 2020-04-14 10:45:09 -0400 | 
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2020-04-16 12:07:54 -0400 | 
| commit | 4e0b5b31b795815e853ec665e651743b280dfc9d (patch) | |
| tree | 31aa3e036e43575eb21711b9397da42bb84f2a08 /zebra/zserv.c | |
| parent | 260616d55d96fab302c678ee78e0a58ca60b0aa1 (diff) | |
lib,zebra: add a session id for zapi sessions
Distinguish zapi sessions, for daemons who use more than one,
by adding a session id. The tuple of proto + instance is not
adequate to support clients who use multiple zapi sessions.
Include the id in the client show output if it's present. Add
a bit of info about this to the developer doc.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'zebra/zserv.c')
| -rw-r--r-- | zebra/zserv.c | 24 | 
1 files changed, 19 insertions, 5 deletions
diff --git a/zebra/zserv.c b/zebra/zserv.c index 740e7c43c7..8a1ed115a7 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -889,6 +889,8 @@ static void zebra_show_client_detail(struct vty *vty, struct zserv *client)  	vty_out(vty, "Client: %s", zebra_route_string(client->proto));  	if (client->instance)  		vty_out(vty, " Instance: %u", client->instance); +	if (client->session_id) +		vty_out(vty, " [%u]", client->session_id);  	vty_out(vty, "\n");  	vty_out(vty, "------------------------ \n"); @@ -995,11 +997,16 @@ static void zebra_show_stale_client_detail(struct vty *vty,  	time_t uptime;  	struct client_gr_info *info = NULL;  	struct zserv *s = NULL; - -	if (client->instance) -		vty_out(vty, " Instance: %d", client->instance); +	bool first_p = true;  	TAILQ_FOREACH (info, &client->gr_info_queue, gr_info) { +		if (first_p) { +			if (client->instance) +				vty_out(vty, " Instance: %u", client->instance); +			if (client->session_id) +				vty_out(vty, " [%u]", client->session_id); +			first_p = false; +		}  		vty_out(vty, "VRF : %s\n", vrf_id_to_name(info->vrf_id));  		vty_out(vty, "Capabilities : ");  		switch (info->capabilities) { @@ -1070,19 +1077,26 @@ static void zebra_show_client_brief(struct vty *vty, struct zserv *client)  		client->v6_route_del_cnt);  } -struct zserv *zserv_find_client(uint8_t proto, unsigned short instance) +struct zserv *zserv_find_client_session(uint8_t proto, unsigned short instance, +					uint32_t session_id)  {  	struct listnode *node, *nnode;  	struct zserv *client;  	for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) { -		if (client->proto == proto && client->instance == instance) +		if (client->proto == proto && client->instance == instance && +		    client->session_id == session_id)  			return client;  	}  	return NULL;  } +struct zserv *zserv_find_client(uint8_t proto, unsigned short instance) +{ +	return zserv_find_client_session(proto, instance, 0); +} +  /* This command is for debugging purpose. */  DEFUN (show_zebra_client,         show_zebra_client_cmd,  | 
