doc/netlink/specs: Add vlan support
Subsystems (3)
v2 cover doc/netlink/specs: Add vlan support
Add vlan support in rt_link spec.
Hangbin Liu (2):
ynl: support hex display_hint for integer doc/netlink/specs: Add vlan attr in rt_link spec
Documentation/netlink/specs/rt_link.yaml | 83 +++++++++++++++++++++++- tools/net/ynl/lib/ynl.py | 5 +- 2 files changed, 86 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 ynl: support hex display_hint for integer
Some times it would be convenient to read the integer as hex, like mask values.
--- tools/net/ynl/lib/ynl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/net/ynl/lib/ynl.py +4 -1
@@ -819,7 +819,10 @@ class YnlFamily(SpecFamily): if display_hint == 'mac': formatted = ':'.join('%02x' % b for b in raw) elif display_hint == 'hex': - formatted = bytes.hex(raw, ' ') + if isinstance(raw, int): + formatted = hex(raw) + else: + formatted = bytes.hex(raw, ' ') elif display_hint in [ 'ipv4', 'ipv6' ]: formatted = format(ipaddress.ip_address(raw)) elif display_hint == 'uuid':
Signature · 1 line
2.43.0
Re: [PATCHv2 net-next 1/2] ynl: support hex display_hint for integer
Quoted 5 lines · Hangbin Liu
Some times it would be convenient to read the integer as hex, like mask values.
Suggested-by Donald Hunter <[email protected]>Signed-off-by Hangbin Liu <[email protected]>
PATCH v2 2/2 doc/netlink/specs: Add vlan attr in rt_link spec
In reply to Hangbin LiuWith command:
# ./tools/net/ynl/cli.py \
--spec Documentation/netlink/specs/rt_link.yaml \
--do getlink --json '{"ifname": "eno1.2"}' --output-json | \
jq -C '.linkinfo'Before:
Exception: No message format for 'vlan' in sub-message spec 'linkinfo-data-msg'
After:
{
"kind": "vlan",
"data": {
"protocol": "8021Q",
"id": 2,
"flag": {
"flags": [
"reorder-hdr"
],
"mask": "0xffffffff"
} }
}
v2:
- Add eth-protocols definitions, but only include vlan protocols (Donald Hunter)
- Set protocol to big-endian (Donald Hunter)
- Add display-hint for vlan flag mask (Donald Hunter)
--- Documentation/netlink/specs/rt_link.yaml | 83 +++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-)
Documentation/netlink/specs/rt_link.yaml +82 -1
@@ -50,7 +50,16 @@ definitions: name: dormant - name: echo - + - + name: eth-protocols + type: enum + entries: + - + name: 8021Q + value: 33024 + - + name: 8021AD + value: 34984 - name: rtgenmsg type: struct
@@ -729,6 +738,43 @@ definitions: - name: filter-mask type: u32 + - + name: ifla-vlan-flags + type: struct + members: + - + name: flags + type: u32 + enum: vlan-flags + enum-as-flags: true + - + name: mask + type: u32 + display-hint: hex + - + name: vlan-flags + type: flags + entries: + - + name: reorder-hdr + - + name: gvrp + - + name: loose-binding + - + name: mvrp + - + name: bridge-binding + - + name: ifla-vlan-qos-mapping + type: struct + members: + - + name: from + type: u32 + - + name: to + type: u32 attribute-sets:
@@ -1507,6 +1553,38 @@ attribute-sets: - name: num-disabled-queues type: u32 + - + name: linkinfo-vlan-attrs + name-prefix: ifla-vlan- + attributes: + - + name: id + type: u16 + - + name: flag + type: binary + struct: ifla-vlan-flags + - + name: egress-qos + type: nest + nested-attributes: ifla-vlan-qos + - + name: ingress-qos + type: nest + nested-attributes: ifla-vlan-qos + - + name: protocol + type: u16 + enum: eth-protocols + byte-order: big-endian + - + name: ifla-vlan-qos + name-prefix: ifla-vlan-qos + attributes: + - + name: mapping + type: binary + struct: ifla-vlan-qos-mapping - name: linkinfo-vrf-attrs name-prefix: ifla-vrf-
@@ -1666,6 +1744,9 @@ sub-messages: - value: tun attribute-set: linkinfo-tun-attrs + - + value: vlan + attribute-set: linkinfo-vlan-attrs - value: vrf attribute-set: linkinfo-vrf-attrs
Signature · 1 line
2.43.0
Donald Hunter
maintainerRe: [PATCHv2 net-next 2/2] doc/netlink/specs: Add vlan attr in rt_link spec
Documentation/netlink/specs/rt_link.yaml definitions: · line 54
Quoted 12 lines · Hangbin Liu
Documentation/netlink/specs/rt_link.yaml +2
-1@@ -50,7 +50,16 @@ definitions: name: dormant - name: echo - + - + name: eth-protocols
I think this should be called vlan-protocols since the enum only contains valid vlan protocol values.
Documentation/netlink/specs/rt_link.yaml definitions: · line 58
Quoted 4 lines
Documentation/netlink/specs/rt_link.yaml +4
-0+ type: enum + entries: + - + name: 8021Q
The convention with YNL specs is to use lower case for names and let e.g. ynl-gen-c convert to upper case for the C domain. So these should be '8021q' and '8021ad'.
Quoted 28 lines
Documentation/netlink/specs/rt_link.yaml +21
-0+ value: 33024 + - + name: 8021AD + value: 34984 - name: rtgenmsg type: struct@@ -729,6 +738,43 @@ definitions: - name: filter-mask type: u32 + - + name: ifla-vlan-flags + type: struct + members: + - + name: flags + type: u32 + enum: vlan-flags + enum-as-flags: true + - + name: mask + type: u32 + display-hint: hex + - + name: vlan-flags + type: flags + entries:
Documentation/netlink/specs/rt_link.yaml definitions: · line 767
Quoted 10 lines
Documentation/netlink/specs/rt_link.yaml +10
-0+ - + name: reorder-hdr + - + name: gvrp + - + name: loose-binding + - + name: mvrp + - + name: bridge-binding
Nit: when you specify entries by name only, you can use the abbreviated form:
- reorder-hdr
- gvrp
- loose-binding
- mvrp
- bridge-binding
Quoted 22 lines
Documentation/netlink/specs/rt_link.yaml +15
-0+ - + name: ifla-vlan-qos-mapping + type: struct + members: + - + name: from + type: u32 + - + name: to + type: u32 attribute-sets:@@ -1507,6 +1553,38 @@ attribute-sets: - name: num-disabled-queues type: u32 + - + name: linkinfo-vlan-attrs + name-prefix: ifla-vlan- + attributes: + -
Documentation/netlink/specs/rt_link.yaml attribute-sets: · line 1570
Quoted 10 lines
Documentation/netlink/specs/rt_link.yaml +10
-0+ name: id + type: u16 + - + name: flag + type: binary + struct: ifla-vlan-flags + - + name: egress-qos + type: nest + nested-attributes: ifla-vlan-qos
I _think_ this needs 'multi-attr: true'
https://elixir.bootlin.com/linux/latest/source/net/8021q/vlan_netlink.c#L120
Documentation/netlink/specs/rt_link.yaml attribute-sets: · line 1574
Quoted 4 lines
Documentation/netlink/specs/rt_link.yaml +4
-0+ - + name: ingress-qos + type: nest + nested-attributes: ifla-vlan-qos
Same for ingress-qos.
Quoted 26 lines
Documentation/netlink/specs/rt_link.yaml +16
-0+ - + name: protocol + type: u16 + enum: eth-protocols + byte-order: big-endian + - + name: ifla-vlan-qos + name-prefix: ifla-vlan-qos + attributes: + - + name: mapping + type: binary + struct: ifla-vlan-qos-mapping - name: linkinfo-vrf-attrs name-prefix: ifla-vrf-@@ -1666,6 +1744,9 @@ sub-messages: - value: tun attribute-set: linkinfo-tun-attrs + - + value: vlan + attribute-set: linkinfo-vlan-attrs - value: vrf attribute-set: linkinfo-vrf-attrs
Jakub Kicinski
maintainerRe: [PATCHv2 net-next 2/2] doc/netlink/specs: Add vlan attr in rt_link spec
In reply to Hangbin LiuQuoted 2 lines · On Tue, 26 Mar 2024 10:43:25 +0800 Hangbin Liu wrote:
Signed-off-by Hangbin Liu <[email protected]>
nit: please add a "---" line here so that the changelog is not part of the commit after we apply it with git am.
Quoted 5 lines
v2:
- Add eth-protocols definitions, but only include vlan protocols (Donald Hunter)
- Set protocol to big-endian (Donald Hunter)
- Add display-hint for vlan flag mask (Donald Hunter)
---