]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bridge: vni: Fix duplicate group and remote error messages
authorBenjamin Poirier <bpoirier@nvidia.com>
Mon, 11 Dec 2023 14:07:15 +0000 (09:07 -0500)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 22 Dec 2023 17:54:23 +0000 (09:54 -0800)
Consider the following command with a duplicated "remote" argument:
$ bridge vni add vni 150 remote 10.0.0.1 remote 10.0.0.2 dev vxlan2
Error: argument "remote" is wrong: duplicate group

The error message is misleading because there is no "group" argument. Both
of the "group" and "remote" options specify a destination address and are
mutually exclusive so change the variable name and error messages
accordingly.

The result is:
$ ./bridge/bridge vni add vni 150 remote 10.0.0.1 remote 10.0.0.2 dev vxlan2
Error: duplicate "destination": "10.0.0.2" is the second value.

Fixes: 45cd32f9f7d5 ("bridge: vxlan device vnifilter support")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
bridge/vni.c

index 33e50d18c8ccee4a2b728cd63eaa9427d75eabb6..56def2f796dd001826163494c0cde149c0d88792 100644 (file)
@@ -92,7 +92,7 @@ static int vni_modify(int cmd, int argc, char **argv)
                .n.nlmsg_type = cmd,
                .tmsg.family = PF_BRIDGE,
        };
-       bool group_present = false;
+       bool daddr_present = false;
        inet_prefix daddr;
        char *vni = NULL;
        char *d = NULL;
@@ -107,19 +107,19 @@ static int vni_modify(int cmd, int argc, char **argv)
                                invarg("duplicate vni", *argv);
                        vni = *argv;
                } else if (strcmp(*argv, "group") == 0) {
-                       if (group_present)
-                               invarg("duplicate group", *argv);
                        NEXT_ARG();
+                       if (daddr_present)
+                               duparg("destination", *argv);
                        get_addr(&daddr, *argv, AF_UNSPEC);
                        if (!is_addrtype_inet_multi(&daddr))
                                invarg("invalid group address", *argv);
-                       group_present = true;
+                       daddr_present = true;
                } else if (strcmp(*argv, "remote") == 0) {
-                       if (group_present)
-                               invarg("duplicate group", *argv);
                        NEXT_ARG();
+                       if (daddr_present)
+                               duparg("destination", *argv);
                        get_addr(&daddr, *argv, AF_UNSPEC);
-                       group_present = true;
+                       daddr_present = true;
                } else {
                        if (strcmp(*argv, "help") == 0)
                                usage();
@@ -133,7 +133,7 @@ static int vni_modify(int cmd, int argc, char **argv)
        }
 
        parse_vni_filter(vni, &req.n, sizeof(req),
-                        (group_present ? &daddr : NULL));
+                        (daddr_present ? &daddr : NULL));
 
        req.tmsg.ifindex = ll_name_to_index(d);
        if (req.tmsg.ifindex == 0) {