773311
From a069dc4106bc641cbc8596e90b95308950b0bffa Mon Sep 17 00:00:00 2001
773311
From: Numan Siddique <numans@ovn.org>
773311
Date: Tue, 12 May 2020 14:21:33 +0530
773311
Subject: [PATCH] pinctrl: Fix icmp6 packet corruption issue
773311
773311
The commit f792b1a00b43("Fix ACL reject action for UDP packets.")
773311
didn't updated the 'struct ip6_hdr' pointer after calling
773311
dp_packet_put(), as dp_packet_put() can reallocate memory making the
773311
old references to packet pointers invalid.
773311
773311
This patch fixes this issue.
773311
773311
Fixes: f792b1a00b43("Fix ACL reject action for UDP packets.")
773311
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1834655
773311
Acked-by: Dumitru Ceara <dceara@redhat.com>
773311
Signed-off-by: Numan Siddique <numans@ovn.org>
773311
---
773311
 controller/pinctrl.c | 4 ++--
773311
 tests/system-ovn.at  | 2 +-
773311
 2 files changed, 3 insertions(+), 3 deletions(-)
773311
773311
diff --git a/controller/pinctrl.c b/controller/pinctrl.c
773311
index 6b0ac3483..d976ec82b 100644
773311
--- a/controller/pinctrl.c
773311
+++ b/controller/pinctrl.c
773311
@@ -1570,8 +1570,6 @@ pinctrl_handle_icmp(struct rconn *swconn, const struct flow *ip_flow,
773311
         }
773311
         ih->icmp6_base.icmp6_cksum = 0;
773311
 
773311
-        nh = dp_packet_l3(&packet);
773311
-
773311
         /* RFC 4443: 3.1.
773311
          *
773311
          * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
773311
@@ -1594,9 +1592,11 @@ pinctrl_handle_icmp(struct rconn *swconn, const struct flow *ip_flow,
773311
         }
773311
 
773311
         dp_packet_put(&packet, in_ip, in_ip_len);
773311
+        nh = dp_packet_l3(&packet);
773311
         nh->ip6_plen = htons(ICMP6_DATA_HEADER_LEN + in_ip_len);
773311
 
773311
         icmpv6_csum = packet_csum_pseudoheader6(dp_packet_l3(&packet));
773311
+        ih = dp_packet_l4(&packet);
773311
         ih->icmp6_base.icmp6_cksum = csum_finish(
773311
             csum_continue(icmpv6_csum, ih,
773311
                           in_ip_len + ICMP6_DATA_HEADER_LEN));
773311
diff --git a/tests/system-ovn.at b/tests/system-ovn.at
773311
index 9a5ef1ec3..9ae6c6b1f 100644
773311
--- a/tests/system-ovn.at
773311
+++ b/tests/system-ovn.at
773311
@@ -3967,7 +3967,7 @@ OVS_WAIT_UNTIL([
773311
 NS_CHECK_EXEC([sw0-p1-rej], [tcpdump -n -c 1 -i sw0-p1-rej udp port 90 > sw0-p1-rej-udp.pcap &], [0])
773311
 NS_CHECK_EXEC([sw0-p1-rej], [tcpdump -n -c 1 -i sw0-p1-rej icmp > sw0-p1-rej-icmp.pcap &], [0])
773311
 
773311
-echo "foo" > foo
773311
+printf '.%.0s' {1..100} > foo
773311
 OVS_WAIT_UNTIL([
773311
     ip netns exec sw0-p1-rej nc -u 10.0.0.4 90 < foo
773311
     c=$(cat sw0-p1-rej-icmp.pcap | grep \
773311
-- 
773311
2.26.2
773311