@@ -89,6 +89,9 @@ static void format_u128(struct ds *ds, const ovs_u128 *value,
const ovs_u128 *mask, bool verbose);
static int scan_u128(const char *s, ovs_u128 *value, ovs_u128 *mask);
+static int parse_odp_action(const char *s, const struct simap *port_names,
+ struct ofpbuf *actions);
+
/* Returns one the following for the action with the given OVS_ACTION_ATTR_*
* 'type':
*
@@ -1561,6 +1564,26 @@ find_end:
}
static int
+parse_action_list(const char *s, const struct simap *port_names,
+ struct ofpbuf *actions)
+{
+ int n = 0;
+
+ while (s[n] != ')') {
+ int retval = 0;
+
+ n += strspn(s + n, delimiters);
+ retval = parse_odp_action(s + n, port_names, actions);
+ if (retval < 0) {
+ return retval;
+ }
+ n += retval;
+ }
+
+ return n;
+}
+
+static int
parse_odp_action(const char *s, const struct simap *port_names,
struct ofpbuf *actions)
{
@@ -1700,20 +1723,11 @@ parse_odp_action(const char *s, const struct simap *port_names,
actions_ofs = nl_msg_start_nested(actions,
OVS_SAMPLE_ATTR_ACTIONS);
- for (;;) {
- int retval;
-
- n += strspn(s + n, delimiters);
- if (s[n] == ')') {
- break;
- }
+ int retval = parse_action_list(s + n, port_names, actions);
+ if (retval < 0)
+ return retval;
- retval = parse_odp_action(s + n, port_names, actions);
- if (retval < 0) {
- return retval;
- }
- n += retval;
- }
+ n += retval;
nl_msg_end_nested(actions, actions_ofs);
nl_msg_end_nested(actions, sample_ofs);
@@ -1722,6 +1736,22 @@ parse_odp_action(const char *s, const struct simap *port_names,
}
{
+ if (!strncmp(s, "clone(", 6)) {
+ size_t actions_ofs;
+ int n = 6;
+
+ actions_ofs = nl_msg_start_nested(actions, OVS_ACTION_ATTR_CLONE);
+ int retval = parse_action_list(s + n, port_names, actions);
+ if (retval < 0) {
+ return retval;
+ }
+ n += retval;
+ nl_msg_end_nested(actions, actions_ofs);
+ return n + 1;
+ }
+ }
+
+ {
uint32_t port;
int n;
@@ -333,6 +333,8 @@ ct(commit,nat(src=fe80::20c:29ff:fe88:1-fe80::20c:29ff:fe88:a18b,random))
ct(commit,nat(src=[[fe80::20c:29ff:fe88:1]]-[[fe80::20c:29ff:fe88:a18b]]:255-4096,random))
ct(commit,helper=ftp,nat(src=10.1.1.240-10.1.1.255))
trunc(100)
+clone(1)
+clone(clone(push_vlan(vid=12,pcp=0),2),1)
])
AT_CHECK_UNQUOTED([ovstest test-odp parse-actions < actions.txt], [0],
[`cat actions.txt`
When adding userspace datapath clone action, the corresponding odp actions parser and unit tests were missing. This patch adds them. Reported-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Andy Zhou <azhou@ovn.org> --- Note: back port to branch-2.7 --- lib/odp-util.c | 56 +++++++++++++++++++++++++++++++++++++++++++------------- tests/odp.at | 2 ++ 2 files changed, 45 insertions(+), 13 deletions(-)