All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: netdev@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>, David Ahern <dsahern@gmail.com>
Subject: [PATCH] genl: ctrl: print op -> policy idx mapping
Date: Fri,  2 Oct 2020 12:26:09 +0200	[thread overview]
Message-ID: <20201002102609.224150-1-johannes@sipsolutions.net> (raw)

Newer kernels can dump per-op policies, so print out the new
mapping attribute to indicate which op has which policy.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 genl/ctrl.c                    | 10 ++++++++++
 include/uapi/linux/genetlink.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/genl/ctrl.c b/genl/ctrl.c
index 68099fe97f1a..c62212b40fa3 100644
--- a/genl/ctrl.c
+++ b/genl/ctrl.c
@@ -162,6 +162,16 @@ static int print_ctrl(struct rtnl_ctrl_data *ctrl,
 		__u32 *ma = RTA_DATA(tb[CTRL_ATTR_MAXATTR]);
 		fprintf(fp, " max attribs: %d ",*ma);
 	}
+	if (tb[CTRL_ATTR_OP_POLICY]) {
+		const struct rtattr *pos;
+
+		rtattr_for_each_nested(pos, tb[CTRL_ATTR_OP_POLICY]) {
+			__u32 *v = RTA_DATA(pos);
+
+			fprintf(fp, " op %d has policy %d",
+				pos->rta_type, *v);
+		}
+	}
 	if (tb[CTRL_ATTR_POLICY])
 		nl_print_policy(tb[CTRL_ATTR_POLICY], fp);
 
diff --git a/include/uapi/linux/genetlink.h b/include/uapi/linux/genetlink.h
index 7c6c390c48ee..adb59b9fb9a3 100644
--- a/include/uapi/linux/genetlink.h
+++ b/include/uapi/linux/genetlink.h
@@ -64,6 +64,8 @@ enum {
 	CTRL_ATTR_OPS,
 	CTRL_ATTR_MCAST_GROUPS,
 	CTRL_ATTR_POLICY,
+	CTRL_ATTR_OP,
+	CTRL_ATTR_OP_POLICY,
 	__CTRL_ATTR_MAX,
 };
 
-- 
2.26.2


             reply	other threads:[~2020-10-02 10:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 10:26 Johannes Berg [this message]
2020-10-02 14:29 ` [PATCH] genl: ctrl: print op -> policy idx mapping David Ahern
2020-10-02 14:39   ` Johannes Berg
2020-10-02 18:01     ` David Ahern
2020-10-02 19:06       ` Johannes Berg

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=20201002102609.224150-1-johannes@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=dsahern@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.