On 11 Nov 2020, at 23:19, Matteo Croce wrote:

On Wed, Nov 11, 2020 at 4:13 PM Eelco Chaudron <[email protected]> wrote:

<SNIP>

@@ -1108,6 +1110,38 @@ format_odp_check_pkt_len_action(struct ds *ds, const struct nlattr *attr,
                            portno_names);
     ds_put_cstr(ds, "))");
 }
+static void
+format_dec_ttl_action(struct ds *ds,const struct nlattr *attr,
+                      const struct hmap *portno_names OVS_UNUSED)
+{
+    const struct nlattr *nla_acts = NULL;
+    bool is_dp_netdev = false;
+
+    if (attr->nla_len == 4) {
+        is_dp_netdev = true;
+    } else {
+        nla_acts = nl_attr_get(attr);
+        if (nla_acts->nla_type != 1) {
+            is_dp_netdev = true;
+        }
+    }
+
+    ds_put_cstr(ds,"dec_ttl(ttl<=1(");
+    if (is_dp_netdev) {

Isn't it possible to encode the user and kernel actions in the same way?

Guess this is a rhetorical question, as you wrote the code :)

But to answer it. I think something went wrong with the kernel side implementation, and it's adding an "OVS_DEC_TTL_ATTR_ACTION" attribute when reporting back the flows. I guess it's too late to fix this on the kernel side as it has been included in the main tree.

What I will do on the next release is at least fix up the above statement to look like this:

@@ -1121,7 +1121,7 @@ format_dec_ttl_action(struct ds *ds,const struct nlattr *attr,
         is_dp_netdev = true;
     } else {
         nla_acts = nl_attr_get(attr);
-        if (nla_acts->nla_type != 1) {
+        if (nla_acts->nla_type != OVS_DEC_TTL_ATTR_ACTION) {
             is_dp_netdev = true;
         }
     }

If you have another view, please share it…

+        if (attr->nla_len == 4) {
+            ds_put_format(ds, "drop");
+        } else {
+ format_odp_actions(ds, nla_acts, nla_acts->nla_len, portno_names);
+        }
+    } else {
+        int len = nl_attr_get_size(attr);
+
+        len -= nl_attr_len_pad(nla_acts, len);
+        nla_acts = nl_attr_next(nla_acts);
+        format_odp_actions(ds, nla_acts, len, portno_names);
+    }
+    ds_put_format(ds, "))");
+}

 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
@@ -1256,7 +1290,11 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
     case OVS_ACTION_ATTR_DROP:
         ds_put_cstr(ds, "drop");
         break;
+    case OVS_ACTION_ATTR_DEC_TTL:
+        format_dec_ttl_action(ds, a, portno_names);
+        break;
     case OVS_ACTION_ATTR_UNSPEC:
+    case OVS_ACTION_ATTR_ADD_MPLS:
     case __OVS_ACTION_ATTR_MAX:
     default:
         format_generic_odp_action(ds, a);
@@ -2498,6 +2536,23 @@ parse_odp_action__(struct parse_odp_context *context, const char *s,
             return n + 1;
         }
     }
+    {
+        if (!strncmp(s, "dec_ttl(ttl<=1(", 15)) {
+            size_t actions_ofs;
+            int n = 15;
+
+            actions_ofs = nl_msg_start_nested(actions,
+ OVS_ACTION_ATTR_DEC_TTL);
+            int retval = parse_action_list(context, s + n, actions);
+            if (retval < 0) {
+                return retval;
+            }
+
+            n += retval;
+            nl_msg_end_nested(actions, actions_ofs);
+            return n + 1;
+        }
+    }

<SNIP>

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to