@@ -148,7 +148,7 @@ additionalProperties: False
name:
type: string
type: &attr-type
- enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+ enum: [ unused, pad, flag, binary, u8, u16, be16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
description: Documentation of the attribute.
@@ -119,7 +119,7 @@ additionalProperties: False
name:
type: string
type:
- enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string ]
+ enum: [ u8, u16, be16, u32, u64, s8, s16, s32, s64, string ]
len:
$ref: '#/$defs/len-or-define'
# End genetlink-legacy
@@ -171,7 +171,7 @@ additionalProperties: False
name:
type: string
type: &attr-type
- enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+ enum: [ unused, pad, flag, binary, u8, u16, be16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
description: Documentation of the attribute.
@@ -121,7 +121,7 @@ additionalProperties: False
name:
type: string
type: &attr-type
- enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+ enum: [ unused, pad, flag, binary, u8, u16, be16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
description: Documentation of the attribute.
@@ -81,6 +81,9 @@ from .nlspec import SpecFamily
def as_u16(self):
return struct.unpack("H", self.raw)[0]
+ def as_be16(self):
+ return struct.unpack(">H", self.raw)[0]
+
def as_u32(self):
return struct.unpack("I", self.raw)[0]
@@ -334,6 +337,8 @@ genl_family_name_to_id = None
attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue)
elif attr["type"] == 'flag':
attr_payload = b''
+ elif attr["type"] == 'be16':
+ attr_payload = struct.pack(">H", int(value))
elif attr["type"] == 'u32':
attr_payload = struct.pack("I", int(value))
elif attr["type"] == 'string':
@@ -371,6 +376,8 @@ genl_family_name_to_id = None
decoded = subdict
elif attr_spec['type'] == 'u8':
decoded = attr.as_u8()
+ elif attr_spec['type'] == 'be16':
+ decoded = attr.as_be16()
elif attr_spec['type'] == 'u32':
decoded = attr.as_u32()
elif attr_spec['type'] == 'u64':
Used by ethtool spec. Signed-off-by: Stanislav Fomichev <sdf@google.com> --- Documentation/netlink/genetlink-c.yaml | 2 +- Documentation/netlink/genetlink-legacy.yaml | 4 ++-- Documentation/netlink/genetlink.yaml | 2 +- tools/net/ynl/lib/ynl.py | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-)