diff mbox series

[ovs-dev,branch-2.8,1/1] tc flower: reorder tunnel encap/decap actions

Message ID 1516893801-13983-1-git-send-email-john.hurley@netronome.com
State Accepted
Headers show
Series [ovs-dev,branch-2.8,1/1] tc flower: reorder tunnel encap/decap actions | expand

Commit Message

John Hurley Jan. 25, 2018, 3:23 p.m. UTC
The tc_flower conversion struct does not consider the order of actions.
If an OvS rule matches on a tunnel (decap) and outputs to a new tunnel,
the netlink conversion to TC will add the set tunnel key action before the
unset, leading to an incorrect TC rule. This patch reorders the netlink
generation to ensure a decap is done before an encap if both exist.

Patch was committed to master. Backport to branch 2.8 requested by Simon
Horman.

Signed-off-by: John Hurley <john.hurley@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 lib/tc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Simon Horman Jan. 26, 2018, 8:04 a.m. UTC | #1
On Thu, Jan 25, 2018 at 03:23:21PM +0000, John Hurley wrote:
> The tc_flower conversion struct does not consider the order of actions.
> If an OvS rule matches on a tunnel (decap) and outputs to a new tunnel,
> the netlink conversion to TC will add the set tunnel key action before the
> unset, leading to an incorrect TC rule. This patch reorders the netlink
> generation to ensure a decap is done before an encap if both exist.
> 
> Patch was committed to master. Backport to branch 2.8 requested by Simon
> Horman.
> 
> Signed-off-by: John Hurley <john.hurley@netronome.com>
> Reviewed-by: Simon Horman <simon.horman@netronome.com>

Thanks John, applied to branch-2.8.
diff mbox series

Patch

diff --git a/lib/tc.c b/lib/tc.c
index 5c36d0d..6f8cd1b 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -921,6 +921,11 @@  nl_msg_put_flower_acts(struct ofpbuf *request, struct tc_flower *flower)
     {
         uint16_t act_index = 1;
 
+        if (flower->tunnel.tunnel) {
+            act_offset = nl_msg_start_nested(request, act_index++);
+            nl_msg_put_act_tunnel_key_release(request);
+            nl_msg_end_nested(request, act_offset);
+        }
         if (flower->set.set) {
             act_offset = nl_msg_start_nested(request, act_index++);
             nl_msg_put_act_tunnel_key_set(request, flower->set.id,
@@ -931,11 +936,6 @@  nl_msg_put_flower_acts(struct ofpbuf *request, struct tc_flower *flower)
                                           flower->set.tp_dst);
             nl_msg_end_nested(request, act_offset);
         }
-        if (flower->tunnel.tunnel) {
-            act_offset = nl_msg_start_nested(request, act_index++);
-            nl_msg_put_act_tunnel_key_release(request);
-            nl_msg_end_nested(request, act_offset);
-        }
         if (flower->vlan_pop) {
             act_offset = nl_msg_start_nested(request, act_index++);
             nl_msg_put_act_pop_vlan(request);