[ovs-dev,v2,2/3] OVN: add buffering support for ipv6 packets
diff mbox series

Message ID a05723b4e3351a016ceb1b40ca2cf1d8a95083f7.1538487934.git.lorenzo.bianconi@redhat.com
State Changes Requested
Headers show
Series
  • add buffering support for IP packets
Related show

Commit Message

Lorenzo Bianconi Oct. 2, 2018, 1:59 p.m. UTC
Add buffering support for IPv6 packets that will be processed by
nd_ns {} action when L2 address is not discovered yet since
otherwise the packet will be substituted with a Neighbor Solicitation
frame and this will result in the lost of the first packet of the
connection

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 ovn/controller/pinctrl.c | 10 ++++++---
 tests/ovn.at             | 45 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 5f15e1696..325f92447 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -99,6 +99,7 @@  static void pinctrl_handle_put_nd_ra_opts(
     struct ofputil_packet_in *pin, struct ofpbuf *userdata,
     struct ofpbuf *continuation);
 static void pinctrl_handle_nd_ns(const struct flow *ip_flow,
+                                 struct dp_packet *pkt_in,
                                  const struct match *md,
                                  struct ofpbuf *userdata);
 static void init_ipv6_ras(void);
@@ -1376,7 +1377,8 @@  process_packet_in(const struct ofp_header *msg,
         break;
 
     case ACTION_OPCODE_ND_NS:
-        pinctrl_handle_nd_ns(&headers, &pin.flow_metadata, &userdata);
+        pinctrl_handle_nd_ns(&headers, &packet, &pin.flow_metadata,
+                             &userdata);
         break;
 
     case ACTION_OPCODE_ICMP:
@@ -2593,8 +2595,8 @@  pinctrl_handle_nd_na(const struct flow *ip_flow, const struct match *md,
 }
 
 static void
-pinctrl_handle_nd_ns(const struct flow *ip_flow, const struct match *md,
-                     struct ofpbuf *userdata)
+pinctrl_handle_nd_ns(const struct flow *ip_flow, struct dp_packet *pkt_in,
+                     const struct match *md, struct ofpbuf *userdata)
 {
     /* This action only works for IPv6 packets. */
     if (get_dl_type(ip_flow) != htons(ETH_TYPE_IPV6)) {
@@ -2603,6 +2605,8 @@  pinctrl_handle_nd_ns(const struct flow *ip_flow, const struct match *md,
         return;
     }
 
+    pinctrl_handle_bufferd_packets(ip_flow, pkt_in, md, false);
+
     uint64_t packet_stub[128 / 8];
     struct dp_packet packet;
     dp_packet_use_stub(&packet, packet_stub, sizeof packet_stub);
diff --git a/tests/ovn.at b/tests/ovn.at
index 23c2cabaf..e4fcc53b6 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -11278,6 +11278,16 @@  send_icmp_packet() {
     as hv$hv ovs-appctl netdev-dummy/receive hv$hv-vif$inport $packet
 }
 
+send_icmp6_packet() {
+    local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_dst=$6 ipv6_router=$7 exp_icmp_chksum=$8
+    shift 8
+
+    local ip6_hdr=6000000000083aff${ipv6_src}${ipv6_dst}
+    local packet=${eth_dst}${eth_src}86dd${ip6_hdr}8000dcb662f00001
+
+    as hv$hv ovs-appctl netdev-dummy/receive hv$hv-vif$inport $packet
+}
+
 get_arp_req() {
     local eth_src=$1 spa=$2 tpa=$3
     local request=ffffffffffff${eth_src}08060001080006040001${eth_src}${spa}000000000000${tpa}
@@ -11290,6 +11300,22 @@  send_arp_reply() {
     as hv$hv ovs-appctl netdev-dummy/receive hv${hv}-vif$inport $request
 }
 
+send_na() {
+    local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 src_ip=$5 dst_ip=$6
+    local ip6_hdr=6000000000203aff${src_ip}${dst_ip}
+    local request=${eth_dst}${eth_src}86dd${ip6_hdr}8800d78440000000${src_ip}0201${eth_src}
+
+    as hv$hv ovs-appctl netdev-dummy/receive hv${hv}-vif$inport $request
+}
+
+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}
+
+    echo $request
+}
+
 net_add n1
 
 sim_add hv1
@@ -11316,18 +11342,18 @@  ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1
 ovn-nbctl ls-add sw0
 ovn-nbctl ls-add sw1
 
-ovn-nbctl lrp-add lr0 sw0 00:00:01:01:02:03 192.168.1.1/24
+ovn-nbctl lrp-add lr0 sw0 00:00:01:01:02:03 192.168.1.1/24 2001::1/64
 ovn-nbctl lsp-add sw0 rp-sw0 -- set Logical_Switch_Port rp-sw0 \
     type=router options:router-port=sw0 \
     -- lsp-set-addresses rp-sw0 router
 
-ovn-nbctl lrp-add lr0 sw1 00:00:02:01:02:03 172.16.1.1/24
+ovn-nbctl lrp-add lr0 sw1 00:00:02:01:02:03 172.16.1.1/24 2002::1/64
 ovn-nbctl lsp-add sw1 rp-sw1 -- set Logical_Switch_Port rp-sw1 \
     type=router options:router-port=sw1 \
     -- lsp-set-addresses rp-sw1 router
 
 ovn-nbctl lsp-add sw0 sw0-p0 \
-    -- lsp-set-addresses sw0-p0 "f0:00:00:01:02:03 192.168.1.2"
+    -- lsp-set-addresses sw0-p0 "f0:00:00:01:02:03 192.168.1.2 2001::2"
 
 ovn-nbctl lsp-add sw1 sw1-p0 \
     -- lsp-set-addresses sw1-p0 unknown
@@ -11341,13 +11367,16 @@  ip_to_hex() {
 
 src_mac=f00000010203
 src_ip=$(ip_to_hex 192 168 1 2)
+src_ip6=20010000000000000000000000000002
 
 router_mac0=000001010203
 router_mac1=000002010203
 router_ip=$(ip_to_hex 172 16 1 1)
+router_ip6=20020000000000000000000000000001
 
 dst_mac=001122334455
 dst_ip=$(ip_to_hex 172 16 1 10)
+dst_ip6=20020000000000000000000000000010
 
 data=0800bee4391a0001
 
@@ -11358,5 +11387,15 @@  echo "${dst_mac}${router_mac1}08004500001c00004000fe010100${src_ip}${dst_ip}${da
 
 OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
 
+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 "${dst_mac}${router_mac1}86dd${ip6_hdr}8000dcb662f00001" >> expected
+send_na 2 1 $dst_mac $router_mac1 $dst_ip6 $router_ip6
+
+OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
+
 OVN_CLEANUP([hv1],[hv2])
 AT_CLEANUP