netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2,v2 0/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall
@ 2020-07-09  6:29 Eyal Birger
  2020-07-09  6:29 ` [PATCH iproute2,v2 1/2] ip xfrm: update man page on setting/printing XFRMA_IF_ID in states/policies Eyal Birger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eyal Birger @ 2020-07-09  6:29 UTC (permalink / raw)
  To: stephen, netdev; +Cc: Eyal Birger

Allow getting/deleting policies which contain an xfrm interface ID.

First patch fixes the man page with regards to the original addition
of IF-ID in ip xfrm operations.

---

v1 -> v2: update man page

Eyal Birger (2):
  ip xfrm: update man page on setting/printing XFRMA_IF_ID in
    states/policies
  ip xfrm: policy: support policies with IF_ID in get/delete/deleteall

 ip/xfrm_policy.c   | 17 ++++++++++++++++-
 man/man8/ip-xfrm.8 | 10 ++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH iproute2,v2 1/2] ip xfrm: update man page on setting/printing XFRMA_IF_ID in states/policies
  2020-07-09  6:29 [PATCH iproute2,v2 0/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall Eyal Birger
@ 2020-07-09  6:29 ` Eyal Birger
  2020-07-09  6:29 ` [PATCH iproute2,v2 2/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall Eyal Birger
  2020-07-13 15:52 ` [PATCH iproute2,v2 0/2] " Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Eyal Birger @ 2020-07-09  6:29 UTC (permalink / raw)
  To: stephen, netdev; +Cc: Eyal Birger

In commit aed63ae1acb9 ("ip xfrm: support setting/printing XFRMA_IF_ID attribute in states/policies")
I added the ability to set/print the xfrm interface ID without updating
the man page.

Fixes: aed63ae1acb9 ("ip xfrm: support setting/printing XFRMA_IF_ID attribute in states/policies")
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
---
 man/man8/ip-xfrm.8 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/man/man8/ip-xfrm.8 b/man/man8/ip-xfrm.8
index f99f30bb..d717205d 100644
--- a/man/man8/ip-xfrm.8
+++ b/man/man8/ip-xfrm.8
@@ -61,6 +61,8 @@ ip-xfrm \- transform configuration
 .IR EXTRA-FLAG-LIST " ]"
 .RB "[ " output-mark
 .IR OUTPUT-MARK " ]"
+.RB "[ " if_id
+.IR IF-ID " ]"
 
 .ti -8
 .B "ip xfrm state allocspi"
@@ -238,6 +240,8 @@ ip-xfrm \- transform configuration
 .IR PRIORITY " ]"
 .RB "[ " flag
 .IR FLAG-LIST " ]"
+.RB "[ " if_id
+.IR IF-ID " ]"
 .RI "[ " LIMIT-LIST " ] [ " TMPL-LIST " ]"
 
 .ti -8
@@ -561,6 +565,10 @@ used to match xfrm policies and states
 used to set the output mark to influence the routing
 of the packets emitted by the state
 
+.TP
+.I IF-ID
+xfrm interface identifier used to in both xfrm policies and states
+
 .sp
 .PP
 .TS
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH iproute2,v2 2/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall
  2020-07-09  6:29 [PATCH iproute2,v2 0/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall Eyal Birger
  2020-07-09  6:29 ` [PATCH iproute2,v2 1/2] ip xfrm: update man page on setting/printing XFRMA_IF_ID in states/policies Eyal Birger
@ 2020-07-09  6:29 ` Eyal Birger
  2020-07-13 15:52 ` [PATCH iproute2,v2 0/2] " Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Eyal Birger @ 2020-07-09  6:29 UTC (permalink / raw)
  To: stephen, netdev; +Cc: Eyal Birger

The XFRMA_IF_ID attribute is set in policies for them to be
associated with an XFRM interface (4.19+).

Add support for getting/deleting policies with this attribute.

For supporting 'deleteall' the XFRMA_IF_ID attribute needs to be
explicitly copied.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
---
 ip/xfrm_policy.c   | 17 ++++++++++++++++-
 man/man8/ip-xfrm.8 |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index d3c706d3..7cc00e7c 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -59,6 +59,7 @@ static void usage(void)
 		"	[ if_id IF_ID ] [ LIMIT-LIST ] [ TMPL-LIST ]\n"
 		"Usage: ip xfrm policy { delete | get } { SELECTOR | index INDEX } dir DIR\n"
 		"	[ ctx CTX ] [ mark MARK [ mask MASK ] ] [ ptype PTYPE ]\n"
+		"	[ if_id IF_ID ]\n"
 		"Usage: ip xfrm policy { deleteall | list } [ nosock ] [ SELECTOR ] [ dir DIR ]\n"
 		"	[ index INDEX ] [ ptype PTYPE ] [ action ACTION ] [ priority PRIORITY ]\n"
 		"	[ flag FLAG-LIST ]\n"
@@ -582,6 +583,8 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete,
 		struct xfrm_user_sec_ctx sctx;
 		char    str[CTX_BUF_SIZE];
 	} ctx = {};
+	bool is_if_id_set = false;
+	__u32 if_id = 0;
 
 	while (argc > 0) {
 		if (strcmp(*argv, "dir") == 0) {
@@ -619,7 +622,11 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete,
 
 			NEXT_ARG();
 			xfrm_policy_ptype_parse(&upt.type, &argc, &argv);
-
+		} else if (strcmp(*argv, "if_id") == 0) {
+			NEXT_ARG();
+			if (get_u32(&if_id, *argv, 0))
+				invarg("IF_ID value is invalid", *argv);
+			is_if_id_set = true;
 		} else {
 			if (selp)
 				invarg("unknown", *argv);
@@ -669,6 +676,9 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete,
 			  (void *)&ctx, ctx.sctx.len);
 	}
 
+	if (is_if_id_set)
+		addattr32(&req.n, sizeof(req.buf), XFRMA_IF_ID, if_id);
+
 	if (rtnl_talk(&rth, &req.n, answer) < 0)
 		exit(2);
 
@@ -767,6 +777,11 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg)
 		}
 	}
 
+	if (tb[XFRMA_IF_ID]) {
+		addattr32(new_n, xb->size, XFRMA_IF_ID,
+			  rta_getattr_u32(tb[XFRMA_IF_ID]));
+	}
+
 	xb->offset += new_n->nlmsg_len;
 	xb->nlmsg_count++;
 
diff --git a/man/man8/ip-xfrm.8 b/man/man8/ip-xfrm.8
index d717205d..aa28db49 100644
--- a/man/man8/ip-xfrm.8
+++ b/man/man8/ip-xfrm.8
@@ -259,6 +259,8 @@ ip-xfrm \- transform configuration
 .IR MASK " ] ]"
 .RB "[ " ptype
 .IR PTYPE " ]"
+.RB "[ " if_id
+.IR IF-ID " ]"
 
 .ti -8
 .BR ip " [ " -4 " | " -6 " ] " "xfrm policy" " { " deleteall " | " list " }"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2,v2 0/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall
  2020-07-09  6:29 [PATCH iproute2,v2 0/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall Eyal Birger
  2020-07-09  6:29 ` [PATCH iproute2,v2 1/2] ip xfrm: update man page on setting/printing XFRMA_IF_ID in states/policies Eyal Birger
  2020-07-09  6:29 ` [PATCH iproute2,v2 2/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall Eyal Birger
@ 2020-07-13 15:52 ` Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2020-07-13 15:52 UTC (permalink / raw)
  To: Eyal Birger; +Cc: netdev

On Thu,  9 Jul 2020 09:29:46 +0300
Eyal Birger <eyal.birger@gmail.com> wrote:

> Allow getting/deleting policies which contain an xfrm interface ID.
> 
> First patch fixes the man page with regards to the original addition
> of IF-ID in ip xfrm operations.
> 
> ---
> 
> v1 -> v2: update man page
> 
> Eyal Birger (2):
>   ip xfrm: update man page on setting/printing XFRMA_IF_ID in
>     states/policies
>   ip xfrm: policy: support policies with IF_ID in get/delete/deleteall
> 
>  ip/xfrm_policy.c   | 17 ++++++++++++++++-
>  man/man8/ip-xfrm.8 | 10 ++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-13 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09  6:29 [PATCH iproute2,v2 0/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall Eyal Birger
2020-07-09  6:29 ` [PATCH iproute2,v2 1/2] ip xfrm: update man page on setting/printing XFRMA_IF_ID in states/policies Eyal Birger
2020-07-09  6:29 ` [PATCH iproute2,v2 2/2] ip xfrm: policy: support policies with IF_ID in get/delete/deleteall Eyal Birger
2020-07-13 15:52 ` [PATCH iproute2,v2 0/2] " Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).