Commit 2813ca8d authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'add-support-for-encoding-multi-attr-to-ynl'

Alessandro Marcolini says:

====================
Add support for encoding multi-attr to ynl

This patchset add the support for encoding multi-attr attributes, making
it possible to use ynl with qdisc which have this kind of attributes
(e.g: taprio, ets).

Patch 1 corrects two docstrings in nlspec.py
Patch 2 adds the multi-attr attribute to taprio entry
Patch 3 adds the support for encoding multi-attr

Some examples of what is now possible with the ynl cli:

- Add a taprio qdisc

  --do newqdisc --create --json '{
  "family":1, "ifindex":4, "handle":65536, "parent":4294967295, "info":0,
   "kind":"taprio",
   "stab":{
       "base": {
         "cell-log": 0,
         "size-log": 0,
         "cell-align": 0,
         "overhead": 31,
         "linklayer": 0,
         "mpu": 0,
         "mtu": 0,
         "tsize": 0
       }
   },
   "options":{
       "priomap": {
           "num-tc": 3,
           "prio-tc-map": "01010101010101010101010101010101",
           "hw": 0,
           "count": "0100010002000000000000000000000000000000000000000000000000000000",
           "offset": "0100020003000000000000000000000000000000000000000000000000000000"
       },
       "sched-clockid":11,
       "sched-entry-list": {"entry": [
           {"index":0, "cmd":0, "gate-mask":1, "interval":300000},
           {"index":1, "cmd":0, "gate-mask":2, "interval":300000},
           {"index":2, "cmd":0, "gate-mask":4, "interval":400000} ]
       },
       "sched-base-time":1528743495910289987, "flags": 1
   }
  }'

- Add an ets qdisc

--create --json '{
"family":1, "ifindex":4, "handle":65536, "parent":4294967295, "kind":"ets",
"options":{
    "nbands":6,
    "nstrict":3,
    "quanta":{
        "quanta-band": [3500, 3000, 2500]
    },
    "priomap":{
        "priomap-band":[0, 1, 1, 1, 2, 3, 4, 5]
    }
}
}'
====================

Link: https://lore.kernel.org/r/cover.1706962013.git.alessandromarcolini99@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 6cc9c6fb b9bcfc3b
......@@ -3376,6 +3376,7 @@ attribute-sets:
name: entry
type: nest
nested-attributes: tc-taprio-sched-entry
multi-attr: true
-
name: tc-taprio-sched-entry
attributes:
......
......@@ -144,7 +144,7 @@ class SpecEnumSet(SpecElement):
class SpecAttr(SpecElement):
""" Single Netlink atttribute type
""" Single Netlink attribute type
Represents a single attribute type within an attr space.
......@@ -308,10 +308,9 @@ class SpecSubMessage(SpecElement):
class SpecSubMessageFormat(SpecElement):
""" Netlink sub-message definition
""" Netlink sub-message format definition
Represents a set of sub-message formats for polymorphic nlattrs
that contain type-specific sub messages.
Represents a single format for a sub-message.
Attributes:
value attribute value to match against type selector
......
......@@ -444,6 +444,13 @@ class YnlFamily(SpecFamily):
except KeyError:
raise Exception(f"Space '{space}' has no attribute '{name}'")
nl_type = attr.value
if attr.is_multi and isinstance(value, list):
attr_payload = b''
for subvalue in value:
attr_payload += self._add_attr(space, name, subvalue, search_attrs)
return attr_payload
if attr["type"] == 'nest':
nl_type |= Netlink.NLA_F_NESTED
attr_payload = b''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment