From patchwork Tue Dec 14 03:59:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wenxu X-Patchwork-Id: 1567562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JCl4Z6Fxhz9s3q for ; Tue, 14 Dec 2021 14:59:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0DD7F81386; Tue, 14 Dec 2021 03:59:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2h9GuHsej_6U; Tue, 14 Dec 2021 03:59:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3324C8137F; Tue, 14 Dec 2021 03:59:22 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01D5BC001E; Tue, 14 Dec 2021 03:59:22 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 24625C0012 for ; Tue, 14 Dec 2021 03:59:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0A2574010E for ; Tue, 14 Dec 2021 03:59:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8xVZyheZ6Z_n for ; Tue, 14 Dec 2021 03:59:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mail-m2456.qiye.163.com (mail-m2456.qiye.163.com [220.194.24.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id DAF35400F5 for ; Tue, 14 Dec 2021 03:59:18 +0000 (UTC) Received: from localhost.localdomain (unknown [117.50.0.204]) by mail-m2456.qiye.163.com (Hmail) with ESMTPA id 85B0570066B; Tue, 14 Dec 2021 11:59:16 +0800 (CST) From: wenxu@ucloud.cn To: i.maximets@ovn.org, pvalerio@redhat.com Date: Tue, 14 Dec 2021 11:59:16 +0800 Message-Id: <1639454356-27621-1-git-send-email-wenxu@ucloud.cn> X-Mailer: git-send-email 1.8.3.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlCN1dZLVlBSVdZDwkaFQgSH1lBWRkeGkNWSUpPQ05OGkweHk pIVRkRExYaEhckFA4PWVdZFhoPEhUdFFlBWVVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NjY6Hio6DjI6GhQrKDABEQwW Fz9PFCtVSlVKTUhCT05PSE5NTUNMVTMWGhIXVQweFQMOOw4YFxQOH1UYFUVZV1kSC1lBWUpKTFVO S1VLVUlLT1lXWQgBWUFIQkJCNwY+ X-HM-Tid: 0a7db71834518c15kuqt85b0570066b Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH] ofproto-dpif-xlate: Fix netdev native tunnel neigh discovery spa X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: wenxu 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 --- lib/ovs-router.c | 2 +- lib/ovs-router.h | 2 ++ ofproto/ofproto-dpif-xlate.c | 12 +++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/ovs-router.c b/lib/ovs-router.c index 09b81c6..6d3c731 100644 --- a/lib/ovs-router.c +++ b/lib/ovs-router.c @@ -164,7 +164,7 @@ static void rt_init_match(struct match *match, uint32_t mark, match->flow.pkt_mark = mark; } -static int +int get_src_addr(const struct in6_addr *ip6_dst, const char output_bridge[], struct in6_addr *psrc) { diff --git a/lib/ovs-router.h b/lib/ovs-router.h index 34ea163..f7ce7cf 100644 --- a/lib/ovs-router.h +++ b/lib/ovs-router.h @@ -26,6 +26,8 @@ extern "C" { #endif +int get_src_addr(const struct in6_addr *ip6_dst, + const char output_bridge[], struct in6_addr *psrc); bool ovs_router_lookup(uint32_t mark, const struct in6_addr *ip_dst, char out_dev[], struct in6_addr *src, struct in6_addr *gw); diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 9d336bc..c556312 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3603,9 +3603,10 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport, struct netdev_tnl_build_header_params tnl_params; struct ovs_action_push_tnl tnl_push_data; struct xport *out_dev = NULL; - ovs_be32 s_ip = 0, d_ip = 0; + ovs_be32 s_ip = 0, d_ip = 0, neigh_s_ip = 0; struct in6_addr s_ip6 = in6addr_any; struct in6_addr d_ip6 = in6addr_any; + struct in6_addr neigh_s_ip6 = in6addr_any; struct eth_addr smac; struct eth_addr dmac; int err; @@ -3646,8 +3647,13 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport, } d_ip = in6_addr_get_mapped_ipv4(&d_ip6); + err = get_src_addr(&d_ip6, out_dev->xbridge->name, &neigh_s_ip6); + if (err) { + neigh_s_ip6 = s_ip6; + } if (d_ip) { s_ip = in6_addr_get_mapped_ipv4(&s_ip6); + neigh_s_ip = in6_addr_get_mapped_ipv4(&neigh_s_ip6); } err = tnl_neigh_lookup(out_dev->xbridge->name, &d_ip6, &dmac); @@ -3657,9 +3663,9 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport, "sending %s request", buf_dip6, out_dev->xbridge->name, d_ip ? "ARP" : "ND"); if (d_ip) { - tnl_send_arp_request(ctx, out_dev, smac, s_ip, d_ip); + tnl_send_arp_request(ctx, out_dev, smac, neigh_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, &neigh_s_ip6, &d_ip6); } return err; }