From: Aaron Conole <aconole@redhat.com>
To: netdev@vger.kernel.org
Cc: dev@openvswitch.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Pravin B Shelar <pshelar@ovn.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Shuah Khan <shuah@kernel.org>,
Adrian Moreno <amorenoz@redhat.com>,
Stefano Brivio <sbrivio@redhat.com>,
Ilya Maximets <i.maximets@ovn.org>
Subject: [RFC net-next 2/7] selftests: openvswitch: Refactor actions parsing.
Date: Thu, 13 Jun 2024 14:13:28 -0400 [thread overview]
Message-ID: <20240613181333.984810-3-aconole@redhat.com> (raw)
In-Reply-To: <20240613181333.984810-1-aconole@redhat.com>
Until recently, the ovs-dpctl utility was used with a limited actions set
and didn't need to have support for multiple similar actions. However,
when adding support for tunnels, it will be important to support multiple
set() actions in a single flow. When printing these actions, the existing
code will be unable to print all of the sets - it will only print the
first.
Refactor this code to be easier to read and support multiple actions of the
same type in an action list.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
.../selftests/net/openvswitch/ovs-dpctl.py | 45 ++++++++++---------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py
index 56f6bd162d3e..73768f3af6e5 100644
--- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py
+++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py
@@ -439,32 +439,30 @@ class ovsactions(nla):
def dpstr(self, more=False):
print_str = ""
- for field in self.nla_map:
+ for field in self["attrs"]:
if field[1] == "none" or self.get_attr(field[0]) is None:
continue
if print_str != "":
print_str += ","
- if field[1] == "uint32":
- if field[0] == "OVS_ACTION_ATTR_OUTPUT":
- print_str += "%d" % int(self.get_attr(field[0]))
- elif field[0] == "OVS_ACTION_ATTR_RECIRC":
- print_str += "recirc(0x%x)" % int(self.get_attr(field[0]))
- elif field[0] == "OVS_ACTION_ATTR_TRUNC":
- print_str += "trunc(%d)" % int(self.get_attr(field[0]))
- elif field[0] == "OVS_ACTION_ATTR_DROP":
- print_str += "drop(%d)" % int(self.get_attr(field[0]))
- elif field[1] == "flag":
- if field[0] == "OVS_ACTION_ATTR_CT_CLEAR":
- print_str += "ct_clear"
- elif field[0] == "OVS_ACTION_ATTR_POP_VLAN":
- print_str += "pop_vlan"
- elif field[0] == "OVS_ACTION_ATTR_POP_ETH":
- print_str += "pop_eth"
- elif field[0] == "OVS_ACTION_ATTR_POP_NSH":
- print_str += "pop_nsh"
- elif field[0] == "OVS_ACTION_ATTR_POP_MPLS":
- print_str += "pop_mpls"
+ if field[0] == "OVS_ACTION_ATTR_OUTPUT":
+ print_str += "%d" % int(self.get_attr(field[0]))
+ elif field[0] == "OVS_ACTION_ATTR_RECIRC":
+ print_str += "recirc(0x%x)" % int(self.get_attr(field[0]))
+ elif field[0] == "OVS_ACTION_ATTR_TRUNC":
+ print_str += "trunc(%d)" % int(self.get_attr(field[0]))
+ elif field[0] == "OVS_ACTION_ATTR_DROP":
+ print_str += "drop(%d)" % int(self.get_attr(field[0]))
+ elif field[0] == "OVS_ACTION_ATTR_CT_CLEAR":
+ print_str += "ct_clear"
+ elif field[0] == "OVS_ACTION_ATTR_POP_VLAN":
+ print_str += "pop_vlan"
+ elif field[0] == "OVS_ACTION_ATTR_POP_ETH":
+ print_str += "pop_eth"
+ elif field[0] == "OVS_ACTION_ATTR_POP_NSH":
+ print_str += "pop_nsh"
+ elif field[0] == "OVS_ACTION_ATTR_POP_MPLS":
+ print_str += "pop_mpls"
else:
datum = self.get_attr(field[0])
if field[0] == "OVS_ACTION_ATTR_CLONE":
@@ -472,7 +470,10 @@ class ovsactions(nla):
print_str += datum.dpstr(more)
print_str += ")"
else:
- print_str += datum.dpstr(more)
+ try:
+ print_str += datum.dpstr(more)
+ except:
+ print_str += "{ATTR: %s not decoded}" % field[0]
return print_str
--
2.45.1
next prev parent reply other threads:[~2024-06-13 18:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 18:13 [RFC net-next 0/7] selftests: net: Switch pmtu.sh to use the internal ovs script Aaron Conole
2024-06-13 18:13 ` [RFC net-next 1/7] selftests: openvswitch: Support explicit tunnel port creation Aaron Conole
2024-06-16 16:25 ` [ovs-dev] " Simon Horman
2024-06-17 17:03 ` Aaron Conole
2024-06-13 18:13 ` Aaron Conole [this message]
2024-06-16 16:29 ` [ovs-dev] [RFC net-next 2/7] selftests: openvswitch: Refactor actions parsing Simon Horman
2024-06-13 18:13 ` [RFC net-next 3/7] selftests: openvswitch: Add set() and set_masked() support Aaron Conole
2024-06-16 16:29 ` [ovs-dev] " Simon Horman
2024-06-17 12:18 ` Adrián Moreno
2024-06-17 17:07 ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 4/7] selftests: openvswitch: Add support for tunnel() key Aaron Conole
2024-06-16 16:27 ` [ovs-dev] " Simon Horman
2024-06-17 17:56 ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 5/7] selftests: openvswitch: Support implicit ipv6 arguments Aaron Conole
2024-06-16 16:28 ` [ovs-dev] " Simon Horman
2024-06-17 17:03 ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 6/7] selftests: net: Use the provided dpctl rather than the vswitchd for tests Aaron Conole
2024-06-13 20:37 ` Stefano Brivio
2024-06-14 15:53 ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 7/7] selftests: net: add config for openvswitch Aaron Conole
2024-06-16 16:30 ` [ovs-dev] " Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240613181333.984810-3-aconole@redhat.com \
--to=aconole@redhat.com \
--cc=amorenoz@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=edumazet@google.com \
--cc=i.maximets@ovn.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pshelar@ovn.org \
--cc=sbrivio@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).