From: Benjamin Poirier Date: Mon, 11 Dec 2023 14:07:15 +0000 (-0500) Subject: bridge: vni: Fix duplicate group and remote error messages X-Git-Tag: v6.7.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b8c01b4058eff19e88da4dfa0f598a9c24a8d3b;p=thirdparty%2Fiproute2.git bridge: vni: Fix duplicate group and remote error messages 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 Tested-by: Petr Machata Signed-off-by: Benjamin Poirier Acked-by: Stephen Hemminger Signed-off-by: Stephen Hemminger --- diff --git a/bridge/vni.c b/bridge/vni.c index 33e50d18c..56def2f79 100644 --- a/bridge/vni.c +++ b/bridge/vni.c @@ -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) {