mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 11:44:16 +00:00
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>
This commit is contained in:
parent
1420189c11
commit
a42d490ac2
@ -51,6 +51,9 @@
|
||||
#include "bgpd/bgp_routemap_nb.h"
|
||||
#include "bgpd/bgp_community_alias.h"
|
||||
|
||||
DEFINE_HOOK(bgp_hook_config_write_vrf, (struct vty *vty, struct vrf *vrf),
|
||||
(vty, vrf));
|
||||
|
||||
#ifdef ENABLE_BGP_VNC
|
||||
#include "bgpd/rfapi/rfapi_backend.h"
|
||||
#endif
|
||||
@ -344,9 +347,29 @@ static int bgp_vrf_disable(struct vrf *vrf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bgp_vrf_config_write(struct vty *vty)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
|
||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||
if (vrf->vrf_id == VRF_DEFAULT) {
|
||||
vty_out(vty, "!\n");
|
||||
continue;
|
||||
}
|
||||
vty_out(vty, "vrf %s\n", vrf->name);
|
||||
|
||||
hook_call(bgp_hook_config_write_vrf, vty, vrf);
|
||||
|
||||
vty_out(vty, "exit-vrf\n!\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bgp_vrf_init(void)
|
||||
{
|
||||
vrf_init(bgp_vrf_new, bgp_vrf_enable, bgp_vrf_disable, bgp_vrf_delete);
|
||||
vrf_cmd_init(bgp_vrf_config_write);
|
||||
}
|
||||
|
||||
static void bgp_vrf_terminate(void)
|
||||
|
@ -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;
|
||||
|
||||
/* assume default vrf */
|
||||
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;
|
||||
|
||||
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;
|
||||
|
@ -34,6 +34,9 @@
|
||||
|
||||
#include "lib/bfd.h"
|
||||
|
||||
DECLARE_HOOK(bgp_hook_config_write_vrf, (struct vty *vty, struct vrf *vrf),
|
||||
(vty, vrf));
|
||||
|
||||
#define BGP_MAX_HOSTNAME 64 /* Linux max, is larger than most other sys */
|
||||
#define BGP_PEER_MAX_HASH_SIZE 16384
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user