netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] genl: ctrl: print op -> policy idx mapping
@ 2020-10-02 10:26 Johannes Berg
  2020-10-02 14:29 ` David Ahern
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2020-10-02 10:26 UTC (permalink / raw)
  To: netdev; +Cc: Jakub Kicinski, David Ahern

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


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

end of thread, other threads:[~2020-10-02 19:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 10:26 [PATCH] genl: ctrl: print op -> policy idx mapping Johannes Berg
2020-10-02 14:29 ` David Ahern
2020-10-02 14:39   ` Johannes Berg
2020-10-02 18:01     ` David Ahern
2020-10-02 19:06       ` Johannes Berg

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).