Commit c7815abb authored by Adrian Moreno's avatar Adrian Moreno Committed by Jakub Kicinski

selftests: openvswitch: add userspace parsing

The userspace action lacks parsing support plus it contains a bug in the
name of one of its attributes.

This patch makes userspace action work.
Reviewed-by: default avatarAaron Conole <aconole@redhat.com>
Signed-off-by: default avatarAdrian Moreno <amorenoz@redhat.com>
Link: https://patch.msgid.link/20240704085710.353845-9-amorenoz@redhat.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 60ccf62d
...@@ -589,13 +589,27 @@ class ovsactions(nla): ...@@ -589,13 +589,27 @@ class ovsactions(nla):
print_str += "userdata=" print_str += "userdata="
for f in self.get_attr("OVS_USERSPACE_ATTR_USERDATA"): for f in self.get_attr("OVS_USERSPACE_ATTR_USERDATA"):
print_str += "%x." % f print_str += "%x." % f
if self.get_attr("OVS_USERSPACE_ATTR_TUN_PORT") is not None: if self.get_attr("OVS_USERSPACE_ATTR_EGRESS_TUN_PORT") is not None:
print_str += "egress_tun_port=%d" % self.get_attr( print_str += "egress_tun_port=%d" % self.get_attr(
"OVS_USERSPACE_ATTR_TUN_PORT" "OVS_USERSPACE_ATTR_EGRESS_TUN_PORT"
) )
print_str += ")" print_str += ")"
return print_str return print_str
def parse(self, actstr):
attrs_desc = (
("pid", "OVS_USERSPACE_ATTR_PID", int),
("userdata", "OVS_USERSPACE_ATTR_USERDATA",
lambda x: list(bytearray.fromhex(x))),
("egress_tun_port", "OVS_USERSPACE_ATTR_EGRESS_TUN_PORT", int)
)
attrs, actstr = parse_attrs(actstr, attrs_desc)
for attr in attrs:
self["attrs"].append(attr)
return actstr
def dpstr(self, more=False): def dpstr(self, more=False):
print_str = "" print_str = ""
...@@ -843,6 +857,12 @@ class ovsactions(nla): ...@@ -843,6 +857,12 @@ class ovsactions(nla):
self["attrs"].append(["OVS_ACTION_ATTR_PSAMPLE", psampleact]) self["attrs"].append(["OVS_ACTION_ATTR_PSAMPLE", psampleact])
parsed = True parsed = True
elif parse_starts_block(actstr, "userspace(", False):
uact = self.userspace()
actstr = uact.parse(actstr[len("userspace(") : ])
self["attrs"].append(["OVS_ACTION_ATTR_USERSPACE", uact])
parsed = True
actstr = actstr[strspn(actstr, ", ") :] actstr = actstr[strspn(actstr, ", ") :]
while parencount > 0: while parencount > 0:
parencount -= 1 parencount -= 1
......
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