diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-09-19 16:37:14 +0200 | 
|---|---|---|
| committer | Louis Scalbert <louis.scalbert@6wind.com> | 2024-01-18 13:23:36 +0100 | 
| commit | a42d490ac2eac007a5730b19118f34f18a68e439 (patch) | |
| tree | f350122ab0cfc99e86ebe54e332ea6e3e7ad6ba5 /bgpd/bgp_rpki.c | |
| parent | 1420189c11e52f8ff306de5d3d0e6a81293e54a9 (diff) | |
bgpd: show per vrf rpki configuration in show run
Show per VRF RPKI configuration in "show run".
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'bgpd/bgp_rpki.c')
| -rw-r--r-- | bgpd/bgp_rpki.c | 58 | 
1 files changed, 45 insertions, 13 deletions
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index f2778b0d94..9a056678ae 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -50,6 +50,8 @@ DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE_GROUP, "BGP RPKI Cache server group");  DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_RTRLIB, "BGP RPKI RTRLib");  DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_REVALIDATE, "BGP RPKI Revalidation"); +#define STR_SEPARATOR 10 +  #define POLLING_PERIOD_DEFAULT 3600  #define EXPIRE_INTERVAL_DEFAULT 7200  #define RETRY_INTERVAL_DEFAULT 600 @@ -109,6 +111,8 @@ struct rpki_vrf {  static struct rpki_vrf *find_rpki_vrf(const char *vrfname);  static int bgp_rpki_vrf_update(struct vrf *vrf, bool enabled); +static int bgp_rpki_write_vrf(struct vty *vty, struct vrf *vrf); +static int bgp_rpki_hook_write_vrf(struct vty *vty, struct vrf *vrf);  static int bgp_rpki_write_debug(struct vty *vty, bool running);  static int start(struct rpki_vrf *rpki_vrf);  static void stop(struct rpki_vrf *rpki_vrf); @@ -852,6 +856,7 @@ static int bgp_rpki_module_init(void)  	hook_register(frr_early_fini, bgp_rpki_fini);  	hook_register(bgp_hook_config_write_debug, &bgp_rpki_write_debug);  	hook_register(bgp_hook_vrf_update, &bgp_rpki_vrf_update); +	hook_register(bgp_hook_config_write_vrf, &bgp_rpki_hook_write_vrf);  	return 0;  } @@ -1449,14 +1454,34 @@ static int bgp_rpki_write_debug(struct vty *vty, bool running)  	return 0;  } -static int config_write(struct vty *vty) +static int bgp_rpki_hook_write_vrf(struct vty *vty, struct vrf *vrf) +{ +	int ret; + +	ret = bgp_rpki_write_vrf(vty, vrf); +	if (ret == ERROR) +		return 0; +	return ret; +} + +static int bgp_rpki_write_vrf(struct vty *vty, struct vrf *vrf)  {  	struct listnode *cache_node;  	struct cache *cache; -	struct rpki_vrf *rpki_vrf; +	struct rpki_vrf *rpki_vrf = NULL; +	char sep[STR_SEPARATOR]; +	vrf_id_t vrf_id = VRF_DEFAULT; + +	if (!vrf) { +		rpki_vrf = find_rpki_vrf(NULL); +		snprintf(sep, sizeof(sep), "%s", ""); +	} else if (vrf->vrf_id != VRF_DEFAULT) { +		rpki_vrf = find_rpki_vrf(vrf->name); +		snprintf(sep, sizeof(sep), "%s", " "); +		vrf_id = vrf->vrf_id; +	} else +		return ERROR; -	/* assume default vrf */ -	rpki_vrf = find_rpki_vrf(NULL);  	if (!rpki_vrf)  		return ERROR; @@ -1467,17 +1492,18 @@ static int config_write(struct vty *vty)  		/* do not display the default config values */  		return 0; -	vty_out(vty, "!\n"); -	vty_out(vty, "rpki\n"); +	if (vrf_id == VRF_DEFAULT) +		vty_out(vty, "%s!\n", sep); +	vty_out(vty, "%srpki\n", sep);  	if (rpki_vrf->polling_period != POLLING_PERIOD_DEFAULT) -		vty_out(vty, " rpki polling_period %d\n", +		vty_out(vty, "%s rpki polling_period %d\n", sep,  			rpki_vrf->polling_period);  	if (rpki_vrf->retry_interval != RETRY_INTERVAL_DEFAULT) -		vty_out(vty, " rpki retry_interval %d\n", +		vty_out(vty, "%s rpki retry_interval %d\n", sep,  			rpki_vrf->retry_interval);  	if (rpki_vrf->expire_interval != EXPIRE_INTERVAL_DEFAULT) -		vty_out(vty, " rpki expire_interval %d\n", +		vty_out(vty, "%s rpki expire_interval %d\n", sep,  			rpki_vrf->expire_interval);  	for (ALL_LIST_ELEMENTS_RO(rpki_vrf->cache_list, cache_node, cache)) { @@ -1488,8 +1514,8 @@ static int config_write(struct vty *vty)  #endif  		case TCP:  			tcp_config = cache->tr_config.tcp_config; -			vty_out(vty, " rpki cache %s %s ", tcp_config->host, -				tcp_config->port); +			vty_out(vty, "%s rpki cache %s %s ", sep, +				tcp_config->host, tcp_config->port);  			if (tcp_config->bindaddr)  				vty_out(vty, "source %s ",  					tcp_config->bindaddr); @@ -1497,7 +1523,7 @@ static int config_write(struct vty *vty)  #if defined(FOUND_SSH)  		case SSH:  			ssh_config = cache->tr_config.ssh_config; -			vty_out(vty, " rpki cache %s %u %s %s %s ", +			vty_out(vty, "%s rpki cache %s %u %s %s %s ", sep,  				ssh_config->host, ssh_config->port,  				ssh_config->username,  				ssh_config->client_privkey_path, @@ -1515,11 +1541,17 @@ static int config_write(struct vty *vty)  		vty_out(vty, "preference %hhu\n", cache->preference);  	} -	vty_out(vty, "exit\n"); + +	vty_out(vty, "%sexit\n%s", sep, vrf_id == VRF_DEFAULT ? "!\n" : "");  	return 1;  } +static int config_write(struct vty *vty) +{ +	return bgp_rpki_write_vrf(vty, NULL); +} +  static struct rpki_vrf *get_rpki_vrf(const char *vrfname)  {  	struct rpki_vrf *rpki_vrf = NULL;  | 
