]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
link_xfrm: if_id must be non zero
authorAntony Antony <antony.antony@secunet.com>
Mon, 14 Mar 2022 08:52:26 +0000 (09:52 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 15 Mar 2022 18:35:03 +0000 (11:35 -0700)
Since kernel upstream commit
8dce43919566 ("xfrm: interface with if_id 0 should return error")
if_id must be non zero.

Fix the usage and return error for if_id 0.

Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/link_xfrm.c

index 7dbfb13f88d685cb0590f2be24e333a635abf1e9..f6c961e6e4bebc3343665ba5b277e549e7bd9010 100644 (file)
@@ -19,7 +19,7 @@ static void xfrm_print_help(struct link_util *lu, int argc, char **argv,
        fprintf(f,
                "Usage: ... %-4s dev [ PHYS_DEV ] [ if_id IF-ID ]\n"
                "\n"
-               "Where: IF-ID := { 0x0..0xffffffff }\n",
+               "Where: IF-ID := { 0x1..0xffffffff }\n",
                lu->id);
 }
 
@@ -39,6 +39,8 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv,
                        NEXT_ARG();
                        if (get_u32(&if_id, *argv, 0))
                                invarg("if_id value is invalid", *argv);
+                       else if (!if_id)
+                               invarg("if_id value is invalid", *argv);
                        else
                                addattr32(n, 1024, IFLA_XFRM_IF_ID, if_id);
                } else {
@@ -48,6 +50,9 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv,
                argc--; argv++;
        }
 
+       if (!if_id)
+               missarg("IF_ID");
+
        if (link)
                addattr32(n, 1024, IFLA_XFRM_LINK, link);