]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: distribute-list ipv6 can be (un)configured 3294/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 8 Nov 2018 13:33:19 +0000 (14:33 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 9 Nov 2018 08:43:22 +0000 (09:43 +0100)
ipv6 distribute-list name picked up was not the correct one. the
parameter number is modified accordingly.
Also, the unconfiguration of distribute-list ipv6 was conflicting with
other daemon, thus making impossible the unconfigration. The command has
been split to be specific to ipv6 distribute-list.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
lib/distribute.c

index 0f1d666aeb9ae3d1c98ee911671c705acec25cb5..96979163323480b3a78a64a04bfb1fe40c357b4b 100644 (file)
@@ -299,16 +299,15 @@ DEFUN (ipv6_distribute_list,
                ifname = argv[argc - 1]->arg;
 
        /* Get interface name corresponding distribute list. */
-       distfn(ifname, type, argv[1 + prefix]->arg);
+       distfn(ifname, type, argv[2 + prefix]->arg);
 
        return CMD_SUCCESS;
 }
 
 DEFUN (no_distribute_list,
        no_distribute_list_cmd,
-       "no [ipv6] distribute-list [prefix] WORD <in|out> [WORD]",
+       "no distribute-list [prefix] WORD <in|out> [WORD]",
        NO_STR
-       "IPv6\n"
        "Filter networks in routing updates\n"
        "Specify a prefix\n"
        "Access-list name\n"
@@ -316,20 +315,53 @@ DEFUN (no_distribute_list,
        "Filter outgoing routing updates\n"
        "Interface name\n")
 {
-       int ipv6 = strmatch(argv[1]->text, "ipv6");
-       int prefix = (argv[2 + ipv6]->type == WORD_TKN) ? 1 : 0;
+       int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0;
 
-       int idx_alname = 2 + ipv6 + prefix;
+       int idx_alname = 2 + prefix;
        int idx_disttype = idx_alname + 1;
+       enum distribute_type type =
+               argv[idx_disttype]->arg[0] == 'i' ?
+               DISTRIBUTE_V4_IN : DISTRIBUTE_V4_OUT;
 
-       /* Check of distribute list type. */
-       enum distribute_type distin =
-               (ipv6) ? DISTRIBUTE_V6_IN : DISTRIBUTE_V4_IN;
-       enum distribute_type distout =
-               (ipv6) ? DISTRIBUTE_V6_OUT : DISTRIBUTE_V4_OUT;
+       /* Set appropriate function call */
+       int (*distfn)(const char *, enum distribute_type,
+                     const char *) =
+               prefix ? &distribute_list_prefix_unset : &distribute_list_unset;
+
+       /* if interface is present, get name */
+       const char *ifname = NULL;
+       if (argv[argc - 1]->type == VARIABLE_TKN)
+               ifname = argv[argc - 1]->arg;
+       /* Get interface name corresponding distribute list. */
+       int ret = distfn(ifname, type, argv[2 + prefix]->arg);
+
+       if (!ret) {
+               vty_out(vty, "distribute list doesn't exist\n");
+               return CMD_WARNING_CONFIG_FAILED;
+       }
+       return CMD_SUCCESS;
+}
+
+DEFUN (no_ipv6_distribute_list,
+       no_ipv6_distribute_list_cmd,
+       "no ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
+       NO_STR
+       "IPv6\n"
+       "Filter networks in routing updates\n"
+       "Specify a prefix\n"
+       "Access-list name\n"
+       "Filter incoming routing updates\n"
+       "Filter outgoing routing updates\n"
+       "Interface name\n")
+{
+       int prefix = (argv[3]->type == WORD_TKN) ? 1 : 0;
+
+       int idx_alname = 3 + prefix;
+       int idx_disttype = idx_alname + 1;
 
        enum distribute_type type =
-               argv[idx_disttype]->arg[0] == 'i' ? distin : distout;
+               argv[idx_disttype]->arg[0] == 'i' ?
+               DISTRIBUTE_V6_IN : DISTRIBUTE_V6_OUT;
 
        /* Set appropriate function call */
        int (*distfn)(const char *, enum distribute_type, const char *) =
@@ -337,10 +369,11 @@ DEFUN (no_distribute_list,
 
        /* if interface is present, get name */
        const char *ifname = NULL;
+
        if (argv[argc - 1]->type == VARIABLE_TKN)
                ifname = argv[argc - 1]->arg;
        /* Get interface name corresponding distribute list. */
-       int ret = distfn(ifname, type, argv[2 + prefix]->arg);
+       int ret = distfn(ifname, type, argv[3 + prefix]->arg);
 
        if (!ret) {
                vty_out(vty, "distribute list doesn't exist\n");
@@ -535,6 +568,7 @@ void distribute_list_init(int node)
        /* install v6 */
        if (node == RIPNG_NODE) {
                install_element(RIPNG_NODE, &ipv6_distribute_list_cmd);
+               install_element(RIPNG_NODE, &no_ipv6_distribute_list_cmd);
        }
 
        /* TODO: install v4 syntax command for v6 only protocols. */