diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2020-10-03 10:45:32 +0200 |
---|---|---|
committer | David Ahern <dsahern@gmail.com> | 2020-10-11 20:10:09 -0600 |
commit | 781201284923f503472099446648b2db4caffddd (patch) | |
tree | 08b0d6a5df8ccc30858c2d8143eaeea402851bf5 /genl | |
parent | 91c54917cd36e329cbcbb571ec2a1ed40d4c6bac (diff) | |
download | iproute2-781201284923f503472099446648b2db4caffddd.tar.gz |
genl: ctrl: print op -> policy idx mapping
Newer kernels can dump per-op policies, so print out the new
mapping attribute to indicate which op has which policy.
v2:
* print out both do/dump policy idx
v3:
* fix userspace API which renumbered after patch rebasing
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David Ahern <dsahern@gmail.com>
Diffstat (limited to 'genl')
-rw-r--r-- | genl/ctrl.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/genl/ctrl.c b/genl/ctrl.c index 68099fe9..549bc663 100644 --- a/genl/ctrl.c +++ b/genl/ctrl.c @@ -162,6 +162,33 @@ 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]) { + struct rtattr *ptb[CTRL_ATTR_POLICY_DUMP_MAX + 1]; + struct rtattr *pattrs = RTA_DATA(pos); + int plen = RTA_PAYLOAD(pos); + + parse_rtattr_flags(ptb, CTRL_ATTR_POLICY_DUMP_MAX, + pattrs, plen, NLA_F_NESTED); + + fprintf(fp, " op %d policies:", + pos->rta_type & ~NLA_F_NESTED); + + if (ptb[CTRL_ATTR_POLICY_DO]) { + __u32 *v = RTA_DATA(ptb[CTRL_ATTR_POLICY_DO]); + + fprintf(fp, " do=%d", *v); + } + + if (ptb[CTRL_ATTR_POLICY_DUMP]) { + __u32 *v = RTA_DATA(ptb[CTRL_ATTR_POLICY_DUMP]); + + fprintf(fp, " dump=%d", *v); + } + } + } if (tb[CTRL_ATTR_POLICY]) nl_print_policy(tb[CTRL_ATTR_POLICY], fp); |