Commit eee2e03c authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'netlink-specs-add-ynl-spec-for-ovs_flow'

Donald Hunter says:

====================
netlink: specs: add ynl spec for ovs_flow

Add a ynl specification for ovs_flow. The spec is sufficient to dump ovs
flows but some attrs have been left as binary blobs because ynl doesn't
support C arrays in struct definitions yet.

Patches 1-3 add features for genetlink-legacy specs
Patch 4 is the ovs_flow netlink spec
====================

Link: https://lore.kernel.org/r/20230527133107.68161-1-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 45402f04 93b230b5
......@@ -124,6 +124,12 @@ properties:
$ref: '#/$defs/len-or-define'
byte-order:
enum: [ little-endian, big-endian ]
doc:
description: Documentation for the struct member attribute.
type: string
enum:
description: Name of the enum type used for the attribute.
type: string
# End genetlink-legacy
attribute-sets:
......
This diff is collapsed.
......@@ -228,11 +228,13 @@ class SpecStructMember(SpecElement):
Attributes:
type string, type of the member attribute
byte_order string or None for native byte order
enum string, name of the enum definition
"""
def __init__(self, family, yaml):
super().__init__(family, yaml)
self.type = yaml['type']
self.byte_order = yaml.get('byte-order')
self.enum = yaml.get('enum')
class SpecStruct(SpecElement):
......
......@@ -412,7 +412,11 @@ class YnlFamily(SpecFamily):
def _decode_binary(self, attr, attr_spec):
if attr_spec.struct_name:
decoded = attr.as_struct(self.consts[attr_spec.struct_name])
members = self.consts[attr_spec.struct_name]
decoded = attr.as_struct(members)
for m in members:
if m.enum:
self._decode_enum(decoded, m)
elif attr_spec.sub_type:
decoded = attr.as_c_array(attr_spec.sub_type)
else:
......@@ -541,7 +545,7 @@ class YnlFamily(SpecFamily):
if op.fixed_header:
fixed_header_members = self.consts[op.fixed_header].members
for m in fixed_header_members:
value = vals.pop(m.name)
value = vals.pop(m.name) if m.name in vals else 0
format = NlAttr.get_format(m.type, m.byte_order)
msg += format.pack(value)
for name, value in vals.items():
......
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