netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Egerer <thomas.egerer@secunet.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <netdev@vger.kernel.org>
Subject: [PATCH iproute2-resend 1/3] xfrm_policy: Add filter option for socket policies
Date: Thu, 2 Nov 2017 14:13:24 +0100	[thread overview]
Message-ID: <024790dc-0493-75f5-44e4-777c793e63bd@secunet.com> (raw)
In-Reply-To: <20171101220508.5be2176f@shemminger-XPS-13-9360>

Listing policies on systems with a lot of socket policies can be
confusing due to the number of returned polices. Even if socket polices
are not of interest, they cannot be filtered. This patch adds an option
to filter all socket policies from the output.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
---
 ip/xfrm.h        | 1 +
 ip/xfrm_policy.c | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ip/xfrm.h b/ip/xfrm.h
index 54d80ce..8566d63 100644
--- a/ip/xfrm.h
+++ b/ip/xfrm.h
@@ -90,6 +90,7 @@ struct xfrm_filter {
 	__u8 action_mask;
 	__u32 priority_mask;
 	__u8 policy_flags_mask;
+	__u8 filter_socket;
 
 	__u8 ptype;
 	__u8 ptype_mask;
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 98460a0..7d2139e 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -58,7 +58,7 @@ static void usage(void)
 	fprintf(stderr, "        [ LIMIT-LIST ] [ TMPL-LIST ]\n");
 	fprintf(stderr, "Usage: ip xfrm policy { delete | get } { SELECTOR | index INDEX } dir DIR\n");
 	fprintf(stderr, "        [ ctx CTX ] [ mark MARK [ mask MASK ] ] [ ptype PTYPE ]\n");
-	fprintf(stderr, "Usage: ip xfrm policy { deleteall | list } [ SELECTOR ] [ dir DIR ]\n");
+	fprintf(stderr, "Usage: ip xfrm policy { deleteall | list } [ nosock ] [ SELECTOR ] [ dir DIR ]\n");
 	fprintf(stderr, "        [ index INDEX ] [ ptype PTYPE ] [ action ACTION ] [ priority PRIORITY ]\n");
 	fprintf(stderr, "        [ flag FLAG-LIST ]\n");
 	fprintf(stderr, "Usage: ip xfrm policy flush [ ptype PTYPE ]\n");
@@ -403,6 +403,9 @@ static int xfrm_policy_filter_match(struct xfrm_userpolicy_info *xpinfo,
 	if ((xpinfo->dir^filter.xpinfo.dir)&filter.dir_mask)
 		return 0;
 
+	if (filter.filter_socket && (xpinfo->dir >= XFRM_POLICY_MAX))
+		return 0;
+
 	if ((ptype^filter.ptype)&filter.ptype_mask)
 		return 0;
 
@@ -806,6 +809,9 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
 
 			filter.policy_flags_mask = XFRM_FILTER_MASK_FULL;
 
+		} else if (strcmp(*argv, "nosock") == 0) {
+			/* filter all socket-based policies */
+			filter.filter_socket = 1;
 		} else {
 			if (selp)
 				invarg("unknown", *argv);
-- 
2.6.4

  parent reply	other threads:[~2017-11-02 13:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-30 18:11 [PATCH iproute2 3/3] xfrm_{state,policy}: Allow to deleteall polices/states with marks Thomas Egerer
2017-10-31 17:13 ` Stephen Hemminger
2017-11-01  9:52   ` Thomas Egerer
2017-11-01 21:05     ` Stephen Hemminger
2017-11-02 13:13       ` [PATCH iproute2-resend 0/3] *** SUBJECT HERE *** Thomas Egerer
2017-11-07  2:14         ` Stephen Hemminger
2017-11-02 13:13       ` Thomas Egerer [this message]
2017-11-02 13:13       ` [PATCH iproute2-resend 2/3] xfrm_policy: Do not attempt to deleteall a socket policy Thomas Egerer
2017-11-02 13:13       ` [PATCH iproute2-resend 3/3] xfrm_{state,policy}: Allow to deleteall polices/states with marks Thomas Egerer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=024790dc-0493-75f5-44e4-777c793e63bd@secunet.com \
    --to=thomas.egerer@secunet.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).