]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: xfrm if_id -ve value is error
authorAntony Antony <antony@phenome.org>
Thu, 19 Dec 2019 14:18:03 +0000 (15:18 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 25 Dec 2019 20:38:13 +0000 (12:38 -0800)
if_id is u32, error on -ve values instead of setting to 0

after :
 ip link add ipsec1 type xfrm dev lo if_id -10
 Error: argument "-10" is wrong: if_id value is invalid

before : note xfrm if_id 0
 ip link add ipsec1 type xfrm dev lo if_id -10
 ip -d  link show dev ipsec1
 9: ipsec1@lo: <NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/none 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 1500
    xfrm if_id 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

Fixes: 286446c1e8c ("ip: support for xfrm interfaces")
Signed-off-by: Antony Antony <antony@phenome.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/link_xfrm.c

index a28f308d56104e9af6f21494629f93122a16e4c1..7dbfb13f88d685cb0590f2be24e333a635abf1e9 100644 (file)
@@ -37,7 +37,9 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv,
                                exit(nodev(*argv));
                } else if (!matches(*argv, "if_id")) {
                        NEXT_ARG();
-                       if (!get_u32(&if_id, *argv, 0))
+                       if (get_u32(&if_id, *argv, 0))
+                               invarg("if_id value is invalid", *argv);
+                       else
                                addattr32(n, 1024, IFLA_XFRM_IF_ID, if_id);
                } else {
                        xfrm_print_help(lu, argc, argv, stderr);