Subject: Re: [PATCH ethtool-next v2 2/2] netlink: add netlink handler for get rss (-x)

From: Jakub Kicinski <[email-masked]>
Date: Thu, 22 Dec 2022 18:02:19 -0800

On Thu, 22 Dec 2022 22:57:19 +0000 Mogilappagari, Sudheer wrote:
> Will use "RSS hash-key' as key name and array. 

rss-hash-key ?

> Output in hex bytes like [ be,c3,13,... ] will be better
> I fell but it needs below changes. Without below changes
> output looks ["be", "c3", "13"...].  Will send out 
> v3 (with below changes as additional patch) unless there 
> is an objection. 

Hex would be great, but AFAIR JSON does not support hex :(
Imagine dealing with this in python, or bash. Do you really
want the values to be strings? They will have to get converted 
manually to integers. So I think just making them integers is
best, JSON is for machines not for looking at...

> +++ b/json_print.c
> void print_hex(enum output_type type, unsigned int hex)
>  {
>         if (_IS_JSON_CONTEXT(type)) {
> -               SPRINT_BUF(b1);
> -               snprintf(b1, sizeof(b1), "%x", hex);
>                 if (key)
> -                       jsonw_string_field(_jw, key, b1);
> +                       jsonw_xint_field(_jw, key, hex);
>                 else
> -                       jsonw_string(_jw, b1);
> +                       jsonw_xint(_jw, hex);
>         } else if (_IS_FP_CONTEXT(type)) {
>                 fprintf(stdout, fmt, hex);
>         }