]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
link_xfrm: don't force to set phydev
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Mon, 16 Sep 2019 15:36:27 +0000 (17:36 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 17 Sep 2019 15:26:21 +0000 (17:26 +0200)
Since linux commit 22d6552f827e ("xfrm interface: fix management of
phydev"), phydev is not mandatory anymore.

Note that it also could be useful before the above commit to not force the
user to put a phydev (the kernel was checking it anyway).
For example, it was useful to not set it in case of x-netns, because the
phydev is not available in the current netns:

Before the patch:
$ ip netns add foo
$ ip link add xfrm1 type xfrm dev eth1 if_id 1
$ ip link set xfrm1 netns foo
$ ip -n foo link set xfrm1 type xfrm dev eth1 if_id 2
Cannot find device "eth1"
$ ip -n foo link set xfrm1 type xfrm if_id 2
must specify physical device

Fixes: 286446c1e8c7 ("ip: support for xfrm interfaces")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Matt Ellison <matt@arroyo.io>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/link_xfrm.c

index 7a3285b420456130e14d4705bab1a05e29281211..a28f308d56104e9af6f21494629f93122a16e4c1 100644 (file)
@@ -17,7 +17,7 @@ static void xfrm_print_help(struct link_util *lu, int argc, char **argv,
                            FILE *f)
 {
        fprintf(f,
-               "Usage: ... %-4s dev PHYS_DEV [ if_id IF-ID ]\n"
+               "Usage: ... %-4s dev [ PHYS_DEV ] [ if_id IF-ID ]\n"
                "\n"
                "Where: IF-ID := { 0x0..0xffffffff }\n",
                lu->id);
@@ -46,12 +46,8 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv,
                argc--; argv++;
        }
 
-       if (link) {
+       if (link)
                addattr32(n, 1024, IFLA_XFRM_LINK, link);
-       } else {
-               fprintf(stderr, "must specify physical device\n");
-               return -1;
-       }
 
        return 0;
 }