Skip to content

Commit 8156765

Browse files
committed
bgpd: Add no rpki command
To delete the whole RPKI section. Signed-off-by: Donatas Abraitis <[email protected]>
1 parent 2af4827 commit 8156765

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

bgpd/bgp_rpki.c

+25
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static int add_ssh_cache(const char *host, const unsigned int port,
120120
#endif
121121
static struct rtr_socket *create_rtr_socket(struct tr_socket *tr_socket);
122122
static struct cache *find_cache(const uint8_t preference);
123+
static void rpki_delete_all_cache_nodes(void);
123124
static int add_tcp_cache(const char *host, const char *port,
124125
const uint8_t preference, const char *bindaddr);
125126
static void print_record(const struct pfx_record *record, struct vty *vty,
@@ -276,6 +277,17 @@ static struct cache *find_cache(const uint8_t preference)
276277
return NULL;
277278
}
278279

280+
static void rpki_delete_all_cache_nodes(void)
281+
{
282+
struct listnode *cache_node, *cache_next;
283+
struct cache *cache;
284+
285+
for (ALL_LIST_ELEMENTS(cache_list, cache_node, cache_next, cache)) {
286+
rtr_mgr_remove_group(rtr_config, cache->preference);
287+
listnode_delete(cache_list, cache);
288+
}
289+
}
290+
279291
static void print_record(const struct pfx_record *record, struct vty *vty,
280292
json_object *json)
281293
{
@@ -1055,6 +1067,17 @@ DEFUN_NOSH (rpki,
10551067
return CMD_SUCCESS;
10561068
}
10571069

1070+
DEFPY (no_rpki,
1071+
no_rpki_cmd,
1072+
"no rpki",
1073+
NO_STR
1074+
"Enable rpki and enter rpki configuration mode\n")
1075+
{
1076+
rpki_delete_all_cache_nodes();
1077+
stop();
1078+
return CMD_SUCCESS;
1079+
}
1080+
10581081
DEFUN (bgp_rpki_start,
10591082
bgp_rpki_start_cmd,
10601083
"rpki start",
@@ -1662,6 +1685,8 @@ static void install_cli_commands(void)
16621685
install_default(RPKI_NODE);
16631686
install_element(CONFIG_NODE, &rpki_cmd);
16641687
install_element(ENABLE_NODE, &rpki_cmd);
1688+
install_element(CONFIG_NODE, &no_rpki_cmd);
1689+
16651690

16661691
install_element(ENABLE_NODE, &bgp_rpki_start_cmd);
16671692
install_element(ENABLE_NODE, &bgp_rpki_stop_cmd);

0 commit comments

Comments
 (0)