[ovs-dev] OVN: add unit test for TCPv6 port unreachable support
diff mbox series

Message ID 9dff500f12e3d6c6068241f342a57e705af31e60.1531148310.git.lorenzo.bianconi@redhat.com
State Accepted
Headers show
Series
  • [ovs-dev] OVN: add unit test for TCPv6 port unreachable support
Related show

Commit Message

Lorenzo Bianconi July 9, 2018, 3:02 p.m. UTC
Add unit test for the TCP reset segment sent by OVN logical router when
it receives an IPv6 TCP segment directed to the router's IP address since
the logical router doesn't accept any TCP traffic

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 tests/ovn.at | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Ben Pfaff July 9, 2018, 10:21 p.m. UTC | #1
On Mon, Jul 09, 2018 at 05:02:34PM +0200, Lorenzo Bianconi wrote:
> Add unit test for the TCP reset segment sent by OVN logical router when
> it receives an IPv6 TCP segment directed to the router's IP address since
> the logical router doesn't accept any TCP traffic
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

Thanks!  I applied this to master.

Patch
diff mbox series

diff --git a/tests/ovn.at b/tests/ovn.at
index 0185317e2..d1a8967dd 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -10454,6 +10454,26 @@  test_tcp_syn_packet() {
     as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet
 }
 
+# test_tcp6_packet INPORT HV ETH_SRC ETH_DST IPV6_SRC IPV6_ROUTER TCP_SPORT TCP_DPORT TCP_CHKSUM EXP_TCP_RST_CHKSUM
+#
+# Causes a packet to be received on INPORT of the hypervisor HV. The packet is a TCP syn segment with
+# ETH_SRC, ETH_DST, IPV6_SRC, IPV6_ROUTER, TCP_SPORT, TCP_DPORT and TCP_CHKSUM as specified.
+# EXP_TCP_RST_CHKSUM is the tcp checksums of the tcp reset segment generated by OVN logical router
+test_tcp6_packet() {
+    local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_router=$6
+    local tcp_sport=$7 tcp_dport=$8 tcp_chksum=$9
+    local exp_tcp_rst_chksum=${10}
+    shift 10
+
+    local ip6_hdr=60000000001406ff${ipv6_src}${ipv6_router}
+    local packet=${eth_dst}${eth_src}86dd${ip6_hdr}${tcp_sport}${tcp_dport}000000010000000050027210${tcp_chksum}0000
+
+    local reply=${eth_src}${eth_dst}86dd60000000001406fe${ipv6_router}${ipv6_src}${tcp_dport}${tcp_sport}000000000000000150040000${exp_tcp_rst_chksum}0000
+    echo $reply >> vif$inport.expected
+
+    as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet
+}
+
 # test_ip6_packet INPORT HV ETH_SRC ETH_DST IPV6_SRC IPV6_DST IPV6_PROTO IPV6_LEN DATA EXP_ICMP_CODE EXP_ICMP_CHKSUM
 #
 # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv6
@@ -10516,6 +10536,7 @@  OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [vif1.expected])
 
 test_tcp_syn_packet 2 2 000000000002 00000000ff02 $(ip_to_hex 192 168 2 1) $(ip_to_hex 192 168 2 254) 0000 8b40 3039 0000 7bae 4486
 test_ip6_packet 2 2 000000000002 00000000ff02 20010db8000200000000000000000011 20010db8000200000000000000000001 84 0004 01020304 0103 627e
+test_tcp6_packet 2 2 000000000002 00000000ff02 20010db8000200000000000000000011 20010db8000200000000000000000001 8b40 3039 0000 4486
 OVN_CHECK_PACKETS([hv2/vif2-tx.pcap], [vif2.expected])
 
 OVN_CLEANUP([hv1], [hv2])