Commit a4126f90 authored by Aaron Conole's avatar Aaron Conole Committed by Jakub Kicinski

selftests: openvswitch: Add set() and set_masked() support.

These will be used in upcoming commits to set specific attributes for
interacting with tunnels.  Since set() will use the key parsing routine, we
also make sure to prepend it with an open paren, for the action parsing to
properly understand it.
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Tested-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarAaron Conole <aconole@redhat.com>
Link: https://patch.msgid.link/20240625172245.233874-4-aconole@redhat.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 37de65a7
...@@ -284,7 +284,7 @@ class ovsactions(nla): ...@@ -284,7 +284,7 @@ class ovsactions(nla):
("OVS_ACTION_ATTR_UNSPEC", "none"), ("OVS_ACTION_ATTR_UNSPEC", "none"),
("OVS_ACTION_ATTR_OUTPUT", "uint32"), ("OVS_ACTION_ATTR_OUTPUT", "uint32"),
("OVS_ACTION_ATTR_USERSPACE", "userspace"), ("OVS_ACTION_ATTR_USERSPACE", "userspace"),
("OVS_ACTION_ATTR_SET", "none"), ("OVS_ACTION_ATTR_SET", "ovskey"),
("OVS_ACTION_ATTR_PUSH_VLAN", "none"), ("OVS_ACTION_ATTR_PUSH_VLAN", "none"),
("OVS_ACTION_ATTR_POP_VLAN", "flag"), ("OVS_ACTION_ATTR_POP_VLAN", "flag"),
("OVS_ACTION_ATTR_SAMPLE", "none"), ("OVS_ACTION_ATTR_SAMPLE", "none"),
...@@ -292,7 +292,7 @@ class ovsactions(nla): ...@@ -292,7 +292,7 @@ class ovsactions(nla):
("OVS_ACTION_ATTR_HASH", "none"), ("OVS_ACTION_ATTR_HASH", "none"),
("OVS_ACTION_ATTR_PUSH_MPLS", "none"), ("OVS_ACTION_ATTR_PUSH_MPLS", "none"),
("OVS_ACTION_ATTR_POP_MPLS", "flag"), ("OVS_ACTION_ATTR_POP_MPLS", "flag"),
("OVS_ACTION_ATTR_SET_MASKED", "none"), ("OVS_ACTION_ATTR_SET_MASKED", "ovskey"),
("OVS_ACTION_ATTR_CT", "ctact"), ("OVS_ACTION_ATTR_CT", "ctact"),
("OVS_ACTION_ATTR_TRUNC", "uint32"), ("OVS_ACTION_ATTR_TRUNC", "uint32"),
("OVS_ACTION_ATTR_PUSH_ETH", "none"), ("OVS_ACTION_ATTR_PUSH_ETH", "none"),
...@@ -469,6 +469,18 @@ class ovsactions(nla): ...@@ -469,6 +469,18 @@ class ovsactions(nla):
print_str += "clone(" print_str += "clone("
print_str += datum.dpstr(more) print_str += datum.dpstr(more)
print_str += ")" print_str += ")"
elif field[0] == "OVS_ACTION_ATTR_SET" or \
field[0] == "OVS_ACTION_ATTR_SET_MASKED":
print_str += "set"
field = datum
mask = None
if field[0] == "OVS_ACTION_ATTR_SET_MASKED":
print_str += "_masked"
field = datum[0]
mask = datum[1]
print_str += "("
print_str += field.dpstr(mask, more)
print_str += ")"
else: else:
try: try:
print_str += datum.dpstr(more) print_str += datum.dpstr(more)
...@@ -547,6 +559,25 @@ class ovsactions(nla): ...@@ -547,6 +559,25 @@ class ovsactions(nla):
self["attrs"].append(("OVS_ACTION_ATTR_CLONE", subacts)) self["attrs"].append(("OVS_ACTION_ATTR_CLONE", subacts))
actstr = actstr[parsedLen:] actstr = actstr[parsedLen:]
parsed = True parsed = True
elif parse_starts_block(actstr, "set(", False):
parencount += 1
k = ovskey()
actstr = actstr[len("set("):]
actstr = k.parse(actstr, None)
self["attrs"].append(("OVS_ACTION_ATTR_SET", k))
if not actstr.startswith(")"):
actstr = ")" + actstr
parsed = True
elif parse_starts_block(actstr, "set_masked(", False):
parencount += 1
k = ovskey()
m = ovskey()
actstr = actstr[len("set_masked("):]
actstr = k.parse(actstr, m)
self["attrs"].append(("OVS_ACTION_ATTR_SET_MASKED", [k, m]))
if not actstr.startswith(")"):
actstr = ")" + actstr
parsed = True
elif parse_starts_block(actstr, "ct(", False): elif parse_starts_block(actstr, "ct(", False):
parencount += 1 parencount += 1
actstr = actstr[len("ct(") :] actstr = actstr[len("ct(") :]
...@@ -1312,7 +1343,7 @@ class ovskey(nla): ...@@ -1312,7 +1343,7 @@ class ovskey(nla):
mask["attrs"].append([field[0], m]) mask["attrs"].append([field[0], m])
self["attrs"].append([field[0], k]) self["attrs"].append([field[0], k])
flowstr = flowstr[strspn(flowstr, "),") :] flowstr = flowstr[strspn(flowstr, "), ") :]
return flowstr return flowstr
......
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