Skip to content

Commit c7815ab

Browse files
amorenozkuba-moo
authored andcommitted
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: Aaron Conole <[email protected]> Signed-off-by: Adrian Moreno <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 60ccf62 commit c7815ab

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tools/testing/selftests/net/openvswitch/ovs-dpctl.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,27 @@ def dpstr(self, more=False):
589589
print_str += "userdata="
590590
for f in self.get_attr("OVS_USERSPACE_ATTR_USERDATA"):
591591
print_str += "%x." % f
592-
if self.get_attr("OVS_USERSPACE_ATTR_TUN_PORT") is not None:
592+
if self.get_attr("OVS_USERSPACE_ATTR_EGRESS_TUN_PORT") is not None:
593593
print_str += "egress_tun_port=%d" % self.get_attr(
594-
"OVS_USERSPACE_ATTR_TUN_PORT"
594+
"OVS_USERSPACE_ATTR_EGRESS_TUN_PORT"
595595
)
596596
print_str += ")"
597597
return print_str
598598

599+
def parse(self, actstr):
600+
attrs_desc = (
601+
("pid", "OVS_USERSPACE_ATTR_PID", int),
602+
("userdata", "OVS_USERSPACE_ATTR_USERDATA",
603+
lambda x: list(bytearray.fromhex(x))),
604+
("egress_tun_port", "OVS_USERSPACE_ATTR_EGRESS_TUN_PORT", int)
605+
)
606+
607+
attrs, actstr = parse_attrs(actstr, attrs_desc)
608+
for attr in attrs:
609+
self["attrs"].append(attr)
610+
611+
return actstr
612+
599613
def dpstr(self, more=False):
600614
print_str = ""
601615

@@ -843,6 +857,12 @@ def parse(self, actstr):
843857
self["attrs"].append(["OVS_ACTION_ATTR_PSAMPLE", psampleact])
844858
parsed = True
845859

860+
elif parse_starts_block(actstr, "userspace(", False):
861+
uact = self.userspace()
862+
actstr = uact.parse(actstr[len("userspace(") : ])
863+
self["attrs"].append(["OVS_ACTION_ATTR_USERSPACE", uact])
864+
parsed = True
865+
846866
actstr = actstr[strspn(actstr, ", ") :]
847867
while parencount > 0:
848868
parencount -= 1

0 commit comments

Comments
 (0)