]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/plist.c
Merge pull request #5628 from donaldsharp/rtm_getneigh
[mirror_frr.git] / lib / plist.c
index 2a97e1e5b2bfc57c51d8b6fdffe47f02afa60745..a0976cd6bdd976ed29da62c8c72a0461795d07c0 100644 (file)
@@ -218,7 +218,7 @@ static struct prefix_list *prefix_list_insert(afi_t afi, int orf,
        /* If name is made by all digit character.  We treat it as
           number. */
        for (number = 0, i = 0; i < strlen(name); i++) {
-               if (isdigit((int)name[i]))
+               if (isdigit((unsigned char)name[i]))
                        number = (number * 10) + (name[i] - '0');
                else
                        break;
@@ -750,6 +750,7 @@ enum prefix_list_type prefix_list_apply_which_prefix(
        if (pbest == NULL)
                return PREFIX_DENY;
 
+       pbest->hitcnt++;
        return pbest->type;
 }
 
@@ -998,22 +999,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 %" PRIu64 "\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 +1390,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",
@@ -1865,6 +1891,8 @@ int prefix_bgp_orf_set(char *name, afi_t afi, struct orf_prefix *orfp,
        if (!plist)
                return CMD_WARNING_CONFIG_FAILED;
 
+       apply_mask(&orfp->p);
+
        if (set) {
                pentry = prefix_list_entry_make(
                        &orfp->p, (permit ? PREFIX_PERMIT : PREFIX_DENY),
@@ -2059,6 +2087,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);