ebb439
From b829ad716daf393925c5404953e0a2212c4d350a Mon Sep 17 00:00:00 2001
ebb439
From: Numan Siddique <numans@ovn.org>
ebb439
Date: Fri, 16 Oct 2020 15:45:30 +0530
ebb439
Subject: [PATCH 5/5] ovn-trace: Handle IPv6 packets for tcp_reset action.
ebb439
ebb439
tcp_reset action can be used for both IPv4 and IPv6 TCP packets, but ovn-trace
ebb439
was not handling IPv6.
ebb439
ebb439
Reported-by: Dumitru Ceara <dceara@redhat.com>
ebb439
Acked-by: Mark Michelson <mmichels@redhat.com>
ebb439
Acked-by: Dumitru Ceara <dceara@redhat.com>
ebb439
Signed-off-by: Numan Siddique <numans@ovn.org>
ebb439
ebb439
(cherry-picked from upstream master commit 29b3fd650b99c0928951c4d537176c4924243cc4)
ebb439
ebb439
Change-Id: I27b9a79b2091cc8980854387d18421fd6f6fcb78
ebb439
---
ebb439
 utilities/ovn-trace.c | 57 +++++++++++++++++++++++++++++++++++++++----
ebb439
 1 file changed, 52 insertions(+), 5 deletions(-)
ebb439
ebb439
diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c
ebb439
index ad33f8e36..5d54c0fd8 100644
ebb439
--- a/utilities/ovn-trace.c
ebb439
+++ b/utilities/ovn-trace.c
ebb439
@@ -1700,11 +1700,11 @@ execute_icmp6(const struct ovnact_nest *on,
ebb439
 }
ebb439
 
ebb439
 static void
ebb439
-execute_tcp_reset(const struct ovnact_nest *on,
ebb439
-                  const struct ovntrace_datapath *dp,
ebb439
-                  const struct flow *uflow, uint8_t table_id,
ebb439
-                  bool loopback, enum ovnact_pipeline pipeline,
ebb439
-                  struct ovs_list *super)
ebb439
+execute_tcp4_reset(const struct ovnact_nest *on,
ebb439
+                   const struct ovntrace_datapath *dp,
ebb439
+                   const struct flow *uflow, uint8_t table_id,
ebb439
+                   bool loopback, enum ovnact_pipeline pipeline,
ebb439
+                   struct ovs_list *super)
ebb439
 {
ebb439
     struct flow tcp_flow = *uflow;
ebb439
 
ebb439
@@ -1733,6 +1733,53 @@ execute_tcp_reset(const struct ovnact_nest *on,
ebb439
                   table_id, pipeline, &node->subs);
ebb439
 }
ebb439
 
ebb439
+static void
ebb439
+execute_tcp6_reset(const struct ovnact_nest *on,
ebb439
+                   const struct ovntrace_datapath *dp,
ebb439
+                   const struct flow *uflow, uint8_t table_id,
ebb439
+                   bool lookback, enum ovnact_pipeline pipeline,
ebb439
+                   struct ovs_list *super)
ebb439
+{
ebb439
+    struct flow tcp_flow = *uflow;
ebb439
+
ebb439
+    /* Update fields for TCP segment. */
ebb439
+    if (lookback) {
ebb439
+        tcp_flow.dl_dst = uflow->dl_src;
ebb439
+        tcp_flow.dl_src = uflow->dl_dst;
ebb439
+        tcp_flow.ipv6_dst = uflow->ipv6_src;
ebb439
+        tcp_flow.ipv6_src = uflow->ipv6_dst;
ebb439
+    } else {
ebb439
+        tcp_flow.dl_dst = uflow->dl_dst;
ebb439
+        tcp_flow.dl_src = uflow->dl_src;
ebb439
+        tcp_flow.ipv6_dst = uflow->ipv6_dst;
ebb439
+        tcp_flow.ipv6_src = uflow->ipv6_src;
ebb439
+    }
ebb439
+    tcp_flow.nw_proto = IPPROTO_TCP;
ebb439
+    tcp_flow.nw_ttl = 255;
ebb439
+    tcp_flow.tp_src = uflow->tp_src;
ebb439
+    tcp_flow.tp_dst = uflow->tp_dst;
ebb439
+    tcp_flow.tcp_flags = htons(TCP_RST);
ebb439
+
ebb439
+    struct ovntrace_node *node = ovntrace_node_append(
ebb439
+        super, OVNTRACE_NODE_TRANSFORMATION, "tcp_reset");
ebb439
+
ebb439
+    trace_actions(on->nested, on->nested_len, dp, &tcp_flow,
ebb439
+                  table_id, pipeline, &node->subs);
ebb439
+}
ebb439
+
ebb439
+static void
ebb439
+execute_tcp_reset(const struct ovnact_nest *on,
ebb439
+                  const struct ovntrace_datapath *dp,
ebb439
+                  const struct flow *uflow, uint8_t table_id,
ebb439
+                  bool lookback, enum ovnact_pipeline pipeline,
ebb439
+                  struct ovs_list *super)
ebb439
+{
ebb439
+    if (get_dl_type(uflow) == htons(ETH_TYPE_IP)) {
ebb439
+        execute_tcp4_reset(on, dp, uflow, table_id, lookback, pipeline, super);
ebb439
+    } else {
ebb439
+        execute_tcp6_reset(on, dp, uflow, table_id, lookback, pipeline, super);
ebb439
+    }
ebb439
+}
ebb439
 static void
ebb439
 execute_reject(const struct ovnact_nest *on,
ebb439
                const struct ovntrace_datapath *dp,
ebb439
-- 
ebb439
2.26.2
ebb439