All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>, netdev@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH] genl: ctrl: print op -> policy idx mapping
Date: Fri, 2 Oct 2020 11:01:04 -0700	[thread overview]
Message-ID: <661566db-8fb2-85a2-3147-821c4cb26a1f@gmail.com> (raw)
In-Reply-To: <58172ec0f7e74c63206121bf6d8f02481f47ee5a.camel@sipsolutions.net>

On 10/2/20 7:39 AM, Johannes Berg wrote:
> On Fri, 2020-10-02 at 07:29 -0700, David Ahern wrote:
>> On 10/2/20 3:26 AM, Johannes Berg wrote:
>>> 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);
>>
>> did you look at pretty printing the op and type? I suspect only numbers
>> are going to cause a lot of staring at header files while counting to
>> decipher number to text.
> 
> I didn't really, but it's also rather tricky?
> 
> The policy index can't be pretty printed anyway, it's literally an
> ephemeral index that's valid only within that dump operation. Not that a
> next one might be different, but if you change the kernel it may well
> be.
> 
> Pretty-printing the op would mean maintaining all those strings in the
> policy (or so) in the kernel? That seems like a _lot_ of memory usage
> (as well as new code), just for this?

does not have to be in the kernel. Usability is important. Since you
have this compiled and easy to test, what is an example of the output
for this dump?


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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=661566db-8fb2-85a2-3147-821c4cb26a1f@gmail.com \
    --to=dsahern@gmail.com \
    --cc=johannes@sipsolutions.net \
    --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.