diff mbox series

[iproute2-next] link_xfrm: if_id must be non zero

Message ID 3510490c98d5d9245c172648806af31a2be97aad.1647247604.git.antony.antony@secunet.com (mailing list archive)
State Accepted
Delegated to: Stephen Hemminger
Headers show
Series [iproute2-next] link_xfrm: if_id must be non zero | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Antony Antony March 14, 2022, 8:52 a.m. UTC
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>
---
 ip/link_xfrm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--
2.30.2
diff mbox series

Patch

diff --git a/ip/link_xfrm.c b/ip/link_xfrm.c
index 7dbfb13f..f6c961e6 100644
--- a/ip/link_xfrm.c
+++ b/ip/link_xfrm.c
@@ -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);