From: wenxu <[email protected]>

netdev native tunnel encap process, when tunnel neighbor cache miss,
send arp/nd request. Before spa use tunnel source, change to:
find the spa which have the same subset with the nexthop of tunnel dst
on  egress port, if false, use the tunnel src as spa.

For example:
tunnel src is a vip with 10.0.0.7/32, tunnel dst is 10.0.1.7
the br-phy with address 192.168.0.7/24 and the default gateway is 192.168.0.1
So the spa of arp request for 192.168.0.1 should be 192.168.0.7 but not 10.0.0.7

Signed-off-by: wenxu <[email protected]>
---
 ofproto/ofproto-dpif-xlate.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index cc9c1c6..f287918 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -3673,14 +3673,27 @@ native_tunnel_output(struct xlate_ctx *ctx, const 
struct xport *xport,
 
     err = tnl_neigh_lookup(out_dev->xbridge->name, &d_ip6, &dmac);
     if (err) {
+        struct in6_addr nh_s_ip6 = in6addr_any;
+
         xlate_report(ctx, OFT_DETAIL,
                      "neighbor cache miss for %s on bridge %s, "
                      "sending %s request",
                      buf_dip6, out_dev->xbridge->name, d_ip ? "ARP" : "ND");
+
+        err = ovs_router_get_netdev_source_address(&d_ip6,
+                                                   out_dev->xbridge->name,
+                                                   &nh_s_ip6);
+        if (err) {
+            nh_s_ip6 = s_ip6;
+        }
+
         if (d_ip) {
-            tnl_send_arp_request(ctx, out_dev, smac, s_ip, d_ip);
+            ovs_be32 nh_s_ip;
+
+            nh_s_ip = in6_addr_get_mapped_ipv4(&nh_s_ip6);
+            tnl_send_arp_request(ctx, out_dev, smac, nh_s_ip, d_ip);
         } else {
-            tnl_send_nd_request(ctx, out_dev, smac, &s_ip6, &d_ip6);
+            tnl_send_nd_request(ctx, out_dev, smac, &nh_s_ip6, &d_ip6);
         }
         return err;
     }
-- 
1.8.3.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to