From: Donatas Abraitis Date: Fri, 24 May 2019 06:22:09 +0000 (+0300) Subject: plist: Delete prefix-list by sequence number X-Git-Tag: frr-7.1~5^2 X-Git-Url: https://git.proxmox.com/?p=mirror_frr.git;a=commitdiff_plain;h=31b4b606a8288d8dd150ee06852adb103a5777c9 plist: Delete prefix-list by sequence number Signed-off-by: Donatas Abraitis --- diff --git a/lib/plist.c b/lib/plist.c index 2a97e1e5b..9957ff1f5 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -998,22 +998,36 @@ static int vty_prefix_list_uninstall(struct vty *vty, afi_t afi, return CMD_SUCCESS; } - /* We must have, at a minimum, both the type and prefix here */ - if ((typestr == NULL) || (prefix == NULL)) { - vty_out(vty, "%% Both prefix and type required\n"); - return CMD_WARNING_CONFIG_FAILED; - } - /* Check sequence number. */ if (seq) seqnum = (int64_t)atol(seq); + /* Sequence number specified, but nothing else. */ + if (seq && typestr == NULL && prefix == NULL && ge == NULL + && le == NULL) { + pentry = prefix_seq_check(plist, seqnum); + + if (pentry == NULL) { + vty_out(vty, + "%% Can't find prefix-list %s with sequence number %lu\n", + name, seqnum); + return CMD_WARNING_CONFIG_FAILED; + } + + prefix_list_entry_delete(plist, pentry, 1); + return CMD_SUCCESS; + } + /* ge and le number */ if (ge) genum = atoi(ge); if (le) lenum = atoi(le); + /* We must have, at a minimum, both the type and prefix here */ + if ((typestr == NULL) || (prefix == NULL)) + return CMD_WARNING_CONFIG_FAILED; + /* Check of filter type. */ if (strncmp("permit", typestr, 1) == 0) type = PREFIX_PERMIT; @@ -1375,6 +1389,17 @@ DEFPY (no_ip_prefix_list, action, dest, ge_str, le_str); } +DEFPY(no_ip_prefix_list_seq, no_ip_prefix_list_seq_cmd, + "no ip prefix-list WORD seq (1-4294967295)", + NO_STR IP_STR PREFIX_LIST_STR + "Name of a prefix list\n" + "sequence number of an entry\n" + "Sequence number\n") +{ + return vty_prefix_list_uninstall(vty, AFI_IP, prefix_list, seq_str, + NULL, NULL, NULL, NULL); +} + DEFPY (no_ip_prefix_list_all, no_ip_prefix_list_all_cmd, "no ip prefix-list WORD", @@ -2059,6 +2084,7 @@ static void prefix_list_init_ipv4(void) install_element(CONFIG_NODE, &ip_prefix_list_cmd); install_element(CONFIG_NODE, &no_ip_prefix_list_cmd); + install_element(CONFIG_NODE, &no_ip_prefix_list_seq_cmd); install_element(CONFIG_NODE, &no_ip_prefix_list_all_cmd); install_element(CONFIG_NODE, &ip_prefix_list_description_cmd);