Skip to contentSkip to conversation

link_xfrm: don't forcce to set phydev

PATCH In review Nicolas Dichtel 2 participants 2 messages Sep 16, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 link_xfrm: don't forcce to set phydev

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
---
 ip/link_xfrm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
ip/link_xfrm.c +2 -6
index 7a3285b42045..a28f308d5610 100644
@@ -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;
 }
Signature · 1 line
2.21.0
Acked-by on v1 1/1
#1 lore raw
Signature · 13 lines
Please be advised that this email may contain confidential information. 
If you are not the intended recipient, please notify us by email by 
replying to the sender and delete this message. The sender disclaims that 
the content of this email constitutes an offer to enter into, or the 
acceptance of, any agreement; provided that the foregoing does not 
invalidate the binding effect of any digital or other electronic 
reproduction of a manual signature that is included in any attachment.


 
<https://twitter.com/arroyo_networks>   
<https://www.linkedin.com/company/arroyo-networks>   
<https://www.github.com/ArroyoNetworks>