diff mbox series

[ovs-dev] netdev-tc-offloads: mask ip_proto for pedit in ipv4/6 header and tcp/udp header

Message ID 1609749307-10085-1-git-send-email-wenxu@ucloud.cn
State New
Headers show
Series [ovs-dev] netdev-tc-offloads: mask ip_proto for pedit in ipv4/6 header and tcp/udp header | expand

Commit Message

wenxu Jan. 4, 2021, 8:35 a.m. UTC
From: wenxu <wenxu@ucloud.cn>

In the tc flower the pedit ipv4/6 header and tcp/udp header should
always mask the ip_proto. So it should set the mask before the
prio selection and it make the right prio selected in the non-support
multi_mask_per_prio kernel.

For case a rule with action dec_ttl. The flower now do't set the mask
of ip_proto and select the prio base on current masks. Then in the
tc_replace_filter it will mask the ip proto for pedit ip header action.

When the flow changs only with strip the action dec_ttl. The old tc rule
will be delete and the new one with the same prio (no ip_proto mask) and
install in the non multi_mask_per_prio kernel, it will be reject for
Invalid Arguement. because the current prio in kernel install rule with mask

Signed-off-by: wenxu <wenxu@ucloud.cn>
 lib/netdev-offload-tc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series


diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c
index 717a987..bfb62c0 100644
--- a/lib/netdev-offload-tc.c
+++ b/lib/netdev-offload-tc.c
@@ -1802,6 +1802,17 @@  netdev_tc_flow_put(struct netdev *netdev, struct match *match,
+    if (flower.rewrite.rewrite) {
+        if (flower.rewrite.mask.tcp_src || flower.rewrite.mask.tcp_dst ||
+            flower.rewrite.mask.udp_src || flower.rewrite.mask.udp_dst ||
+            !is_all_zeros(&flower.rewrite.mask.ipv4,
+                          sizeof(flower.rewrite.mask.ipv4)) ||
+            !is_all_zeros(&flower.rewrite.mask.ipv6,
+                          sizeof(flower.rewrite.mask.ipv6))) {
+            flower.mask.ip_proto = UINT8_MAX;
+        }
+    }
     if ((chain || recirc_act) && !info->recirc_id_shared_with_tc) {
         VLOG_ERR_RL(&error_rl, "flow_put: recirc_id sharing not supported");
         return EOPNOTSUPP;