lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Mon, 11 Mar 2024 18:08:45 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Donald Hunter <donald.hunter@...il.com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Jacob Keller <jacob.e.keller@...el.com>,
	Jiri Pirko <jiri@...nulli.us>
Subject: Re: [PATCH net-next] doc/netlink/specs: Add vlan attr in rt_link spec

Hi Donald,
On Fri, Mar 08, 2024 at 01:05:45PM +0000, Donald Hunter wrote:
> > Not sure if there is a proper way to show the mask and protocol
> 
> Using display-hint, e.g. display-hint: hex, is intended to tell the ynl
> cli to render output in a human readable way. Unfortunately it currently
> only works for binary attributes.
> 
> It can be done like this:
> 
>       -
>         name: mask
>         type: binary
>         len: 4
>         display-hint: hex
> 
> ./tools/net/ynl/cli.py \
> --spec Documentation/netlink/specs/rt_link.yaml \
> --do getlink --json '{"ifname": "wlan0.8"}' --output-json | jq -C '.linkinfo'
> {
>   "kind": "vlan",
>   "data": {
>     "protocol": 33024,
>     "id": 8,
>     "flag": {
>       "flags": [
>         "reorder-hdr"
>       ],
>       "mask": "ff ff ff ff"
>     }
>   }
> }
> 
> But it seems wrong to change the struct definition for this. We should
> patch ynl to support hex rendering of integers.

I only processed the numbers with hex display hint

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 2d7fdd903d9e..d92b8ef287a1 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -787,7 +787,11 @@ class YnlFamily(SpecFamily):
                 if m.enum:
                     value = self._decode_enum(value, m)
                 elif m.display_hint:
-                    value = self._formatted_string(value, m.display_hint)
+                    if m.type in {'u8', 'u16', 'u32', 'u64', 's32', 's64',
+                                  'uint', 'sint'} and m.display_hint == 'hex':
+                        value = hex(value)
+                    else:
+                        value = self._formatted_string(value, m.display_hint)
                 attrs[m.name] = value
         return attrs

And the output looks like:

{
  "kind": "vlan",
  "data": {
    "protocol": "8021q",
    "id": 2,
    "flag": {
      "flags": [
        "reorder-hdr"
      ],
      "mask": "0xffffffff"
    }
  }
}

Do you think if it is enough?

> 
> For the protocol, you'd need to add an enum of ethernet protocol
> numbers, from the info in include/uapi/linux/if_ether.h

Thanks, I will add VLAN protocols first.

Hangbin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ