From 482abeae570ce551d808f345caaf5b3c28bcb237 Mon Sep 17 00:00:00 2001 From: wenxu Date: Fri, 1 Apr 2022 11:02:28 -0400 Subject: ofproto-dpif-xlate: Fix netdev native tunnel neigh discovery spa. During native tunnel encapsulation process, on tunnel neighbor cache miss OVS sends an arp/nd request. Currently, tunnel source is used as arp spa. Find the spa which has the same subnet 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 Acked-by: Eelco Chaudron Signed-off-by: Ilya Maximets --- ofproto/ofproto-dpif-xlate.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'ofproto') diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 6d6f2f6a9..7dfd8e9ef 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3681,14 +3681,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; } -- cgit v1.2.1