Blob Blame History Raw
From 7f60417ae6c7438565a21d5aee0bb8ae0b3a9b68 Mon Sep 17 00:00:00 2001
Message-Id: <7f60417ae6c7438565a21d5aee0bb8ae0b3a9b68.1585835882.git.me@lorenzobianconi.net>
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date: Tue, 24 Mar 2020 20:33:27 +0100
Subject: [PATCH] controller: use LLA IPv6 address as NS source address

Use router LLA IPv6 address as IPv6 source address for Neighbor
Solicitation packets

Fixes: c0bf32d72 ("Manage ARP process locally in a DVR scenario")
Change-Id: Iafa26f4b3c20e181bd5b54a357d468ce61b589b6
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
Signed-off-by: Lorenzo Bianconi <me@lorenzobianconi.net>
---
 controller/pinctrl.c |  4 +++-
 tests/ovn.at         | 15 +++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -4563,9 +4563,11 @@ pinctrl_handle_nd_ns(struct rconn *swcon
 
     uint64_t packet_stub[128 / 8];
     struct dp_packet packet;
+    struct in6_addr ipv6_src;
     dp_packet_use_stub(&packet, packet_stub, sizeof packet_stub);
 
-    compose_nd_ns(&packet, ip_flow->dl_src, &ip_flow->ipv6_src,
+    in6_generate_lla(ip_flow->dl_src, &ipv6_src);
+    compose_nd_ns(&packet, ip_flow->dl_src, &ipv6_src,
                   &ip_flow->ipv6_dst);
 
     /* Reload previous packet metadata and set actions from userdata. */
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -11280,13 +11280,13 @@ options:rxq_pcap=${pcap_file}-rx.pcap
 # This function sends ipv6 packet
 test_ipv6() {
     local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5
-    local dst_mcast_mac=$6 mcast_node_ip=$7 nd_target=$8
+    local dst_mcast_mac=$6 mcast_node_ip=$7 nd_target=$8 nd_src_ip=$9
 
     local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}
     packet=${packet}8000000000000000
 
     src_mac=000002010204
-    expected_packet=${dst_mcast_mac}${src_mac}86dd6000000000203aff${src_ip}
+    expected_packet=${dst_mcast_mac}${src_mac}86dd6000000000203aff${nd_src_ip}
     expected_packet=${expected_packet}${mcast_node_ip}8700XXXX00000000
     expected_packet=${expected_packet}${nd_target}0101${src_mac}
 
@@ -11298,6 +11298,7 @@ test_ipv6() {
 src_mac=506400000002
 dst_mac=00000000af01
 src_ip=aef0000000000000526400fffe000002
+nd_src_ip=fe80000000000000020002fffe010204
 dst_ip=20010db800010000020002fffe010205
 dst_mcast_mac=3333ff010205
 mcast_node_ip=ff0200000000000000000001ff010205
@@ -11305,7 +11306,7 @@ nd_target=20010db800010000020002fffe0102
 # Send an IPv6 packet. Generated IPv6 Neighbor solicitation packet
 # should be received by the ports attached to br-phys.
 test_ipv6 1 $src_mac $dst_mac $src_ip $dst_ip $dst_mcast_mac \
-$mcast_node_ip $nd_target
+$mcast_node_ip $nd_target $nd_src_ip
 
 OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys_n1-tx.pcap | cut -d " " -f1)])
 OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys-tx.pcap | cut -d " " -f1)])
@@ -11338,7 +11339,7 @@ dst_mcast_mac=3333ff011305
 mcast_node_ip=ff0200000000000000000001ff011305
 nd_target=20010db800010000020002fffe011305
 test_ipv6 1 $src_mac $dst_mac $src_ip $dst_ip $dst_mcast_mac \
-$mcast_node_ip $nd_target
+$mcast_node_ip $nd_target $nd_src_ip
 
 OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys_n1-tx.pcap | cut -d " " -f1)])
 OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys-tx.pcap | cut -d " " -f1)])
@@ -14262,7 +14263,7 @@ send_na() {
 get_nd() {
     local eth_src=$1 src_ip=$2 dst_ip=$3 ta=$4
     local ip6_hdr=6000000000203aff${src_ip}${dst_ip}
-    request=3333ff000010${eth_src}86dd${ip6_hdr}8700357600000000${ta}0101${eth_src}
+    request=3333ff000010${eth_src}86dd${ip6_hdr}870051f400000000${ta}0101${eth_src}
 
     echo $request
 }
@@ -14325,6 +14326,8 @@ router_mac1=000002010203
 router_ip=$(ip_to_hex 172 16 1 1)
 router_ip6=20020000000000000000000000000001
 
+nd_src_ip6=fe80000000000000020002fffe010203
+
 dst_mac=001122334455
 dst_ip=$(ip_to_hex 172 16 1 10)
 dst_ip6=20020000000000000000000000000010
@@ -14342,7 +14345,7 @@ nd_ip=ff0200000000000000000001ff000010
 ip6_hdr=6000000000083afe${src_ip6}${dst_ip6}
 
 send_icmp6_packet 1 1 $src_mac $router_mac0 $src_ip6 $dst_ip6
-echo $(get_nd $router_mac1 $src_ip6 $nd_ip $dst_ip6) >> expected
+echo $(get_nd $router_mac1 $nd_src_ip6 $nd_ip $dst_ip6) >> expected
 echo "${dst_mac}${router_mac1}86dd${ip6_hdr}8000dcb662f00001" >> expected
 send_na 2 1 $dst_mac $router_mac1 $dst_ip6 $router_ip6