From patchwork Mon Jun 28 11:31:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: miter X-Patchwork-Id: 1497882 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=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=tb1KbFLE; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 ozlabs.org (Postfix) with ESMTPS id 4GD56P3Nscz9sW7 for ; Mon, 28 Jun 2021 21:31:41 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6ED4C40393; Mon, 28 Jun 2021 11:31:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 47G2Uj_AnXku; Mon, 28 Jun 2021 11:31:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 2AA6B402BB; Mon, 28 Jun 2021 11:31:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EE554C0010; Mon, 28 Jun 2021 11:31:36 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2CDAAC000E for ; Mon, 28 Jun 2021 11:31:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0E0A68293F for ; Mon, 28 Jun 2021 11:31:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=outlook.com 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 e3hfGOTmuynp for ; Mon, 28 Jun 2021 11:31:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01olkn2164.outbound.protection.outlook.com [40.92.63.164]) by smtp1.osuosl.org (Postfix) with ESMTPS id 91843828FB for ; Mon, 28 Jun 2021 11:31:34 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TQdhb0K/ZzCDSuCjHd5I/jWdzXEMn+ufdcFbpAYG7bWaYMDU5mBZ1GElaok3t65ed4DREw6/i015yERz0E2K3tqfj9bLjz/FcNvNfG8aikcZYLJxqnNSVAx5z7OK0Q7hrdKv6xAFGoD4+I8gaEInC5agvEM71hD8zQxjm19/bA5r1KhaGoNrLPOf8fsXwXWMgKuLKrTF6beYzv6ShCuoyDJdeF7bVLFANMFYrfPeJvZutZ1n0KddnnbklEAiIyQIUFutwuKS8M4rzvWtv/49WCKX6QLMqDobsIJuc3pUfOCMFC2xkcPs1Krpy/RysRknxCBbtEyW1zm5DLSt7zmdXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UYeksyfaIBSIExNNzhoN5dF9qlgP24jucKPzZsL7LGQ=; b=Is6nFJ9/yVv9LC5D1ViMQcL086L1xfGpoLFtUS09fdkuy+QOA5nOSoFS4C+SUz5voequ2uV6OPECexzmuGg9c4CAGQFnmu+EplrcPvdNp+PjSkiMMQoAsyqjEcu2A1I8jdR/4uR1ca+m9dXeHK+cKs7f6ex8H5Ca2MG8CuFRn/5be4fznyU/6HkRAGKw1UmikKlqaX08SPvH7tA+kZyhtgtDI49+wsj6nyYO2D9ZlQLoJA2LYIlgYRgRRufPkau2QPo95yQqX1HNpm0RQ66o4ohzfc9N91mIG0c05iAHthdT4TGpfGi+AEddDHheFG+b+Gh1x+vXC9cov349W2JaZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UYeksyfaIBSIExNNzhoN5dF9qlgP24jucKPzZsL7LGQ=; b=tb1KbFLEkOBo4G76RHdxcejDoKVldwPumTuuQ5Pod3CHtfmdbnPW967Y9Nf4NmH2dYjungLpqqSLdZT5ED/8UJdXHi1jMITDRT+zrGrMKzp8JZawuzh0nPCaavCVCHlGVMqgtx6CkDhYd4rxvTHz/Q+sD6KaueLqBa1QLT9cYUeIOyPyf+yEYOoRZFGPtuyD4VgGt0GNi1UgP+X/mWm17jFhntR4sUIq51yGJ3Gk5k47NRk2UVtwCbR3bcneJRXPEpbeu5T79NPboWnc3LARNLOfwFq020j4/7ayoCNdwfdWhIje0MUmAXD83ngRupkOtlU/dgXgO1LYyzV3fMfB+Q== Received: from MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:15b::24) by ME3P282MB2729.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:13e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.22; Mon, 28 Jun 2021 11:31:30 +0000 Received: from MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM ([fe80::dd71:a32a:32de:975]) by MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM ([fe80::dd71:a32a:32de:975%7]) with mapi id 15.20.4264.026; Mon, 28 Jun 2021 11:31:30 +0000 Date: Mon, 28 Jun 2021 19:31:28 +0800 From: "miterv@outlook.com" To: ovs-dev X-GUID: A7A0E7CE-B06C-4ECB-8188-57B2743EAEBE X-Has-Attach: no X-Mailer: Foxmail 7.2.18.95[cn] Message-ID: X-TMN: [mXk5f/c6yVOBPZJ3/TrrmKLJw80CqILd] X-ClientProxiedBy: HK0PR03CA0119.apcprd03.prod.outlook.com (2603:1096:203:b0::35) To MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:15b::24) X-Microsoft-Original-Message-ID: <202106281929571528422@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from DESKTOP-NHO3ML7 (218.85.80.138) by HK0PR03CA0119.apcprd03.prod.outlook.com (2603:1096:203:b0::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Mon, 28 Jun 2021 11:31:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22db5b41-1d86-4ab3-4ead-08d93a284629 X-MS-TrafficTypeDiagnostic: ME3P282MB2729: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ubKd65k4bjkyl9HVf47b0OvHD4XcsCItR9pOUdbSI23XSw8/tc5pvk2PPckcZT7oQHgciouAMjfStZWQzB8f2LVvNtcxF1nPByylPVp81LHLWgq4HMgp32xOSWcxUpuZJ5VWKrm83on9rU35w9V6AhcALF2qHykc0GFBoNBdcDgwNnVAk7o1a7qzKKSeVDBqXSEqospjjDa7m4A0wE8wJSsmDPgijneXH/UM2DMibbfbJfM1E6bqg9tcNiBwnTyOnMOcBndna4R9igq/aky2N/y82wMHfLEKGpwDPnHy2xOdheZNSBTeLPI8PpMZ8gYJnYK1yX1c6hrFgtNrlkvwVR1fkrN0hjv6aEyOEfXISSgdqbiAsRO6GUGCqsvGLsx7O6vJ/aMefMOXQQdxWCcUtXCdzrQzNzeQy02g0fWZjPOUxIVz/6SO519NrHsgyvIr X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GdTYiwwp3/p0Bd2Q9DI87UAwyEwwLF6CtchqjexqAEJRPvrlctmCcvebHGyFZ2UnRIMmMSqSPau3/6Nr+r/RgjbuMwhRucmSzbkVqqtbXyqak06FIryNXm9yHC7nYFrwG/AkJ4HVAYHYjnVVaeF1UA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22db5b41-1d86-4ab3-4ead-08d93a284629 X-MS-Exchange-CrossTenant-AuthSource: MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2021 11:31:30.3285 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ME3P282MB2729 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [ovs-dev] [PATCH] ofproto-dpif-xlate: Using output netdev's ip as tunnel arp/nd request ip 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" If VXLAN tunnel's source ip and the output_bridge netdev's ip are not on the same subnet, tnl_send_arp_request() will use tunnel's source ip as arp/nd sender not the output netdev's ip. This lead to address resolution (i.e., IPv4 ARP and IPv6 ND) scaling issues. OVS unable to get gateway address information. For example, OVS vxlan tunnel source ip is 2.2.2.2. The output_bridge netdev's ip is 1.1.1.1. The ToR gateway ip is 1.1.1.2. After we sending packets into this tunnel, tnl_send_arp_request() will send arp/nd request which sender ip is 2.2.2.2 not the 1.1.1.1. That is arp/nd gateway learning failed, no packets will be encapped in vxlan tunnel. This patch fix it using the output_bridge netdev's ip as arp/nd request ip. Signed-off-by: Lin Huang --- lib/ovs-router.c | 2 +- ofproto/ofproto-dpif-xlate.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) d_ip = in6_addr_get_mapped_ipv4(&d_ip6); if (d_ip) { s_ip = in6_addr_get_mapped_ipv4(&s_ip6); + o_ip = in6_addr_get_mapped_ipv4(&o_ip6); } err = tnl_neigh_lookup(out_dev->xbridge->name, &d_ip6, &dmac); @@ -3656,10 +3665,22 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport, "neighbor cache miss for %s on bridge %s, " "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); + if (!ipv6_addr_is_set(&o_ip6) || ipv6_addr_equals(&o_ip6, &s_ip6)) { + if (d_ip) { + tnl_send_arp_request(ctx, out_dev, smac, s_ip, d_ip); + } else { + tnl_send_nd_request(ctx, out_dev, smac, &s_ip6, &d_ip6); + } } else { - tnl_send_nd_request(ctx, out_dev, smac, &s_ip6, &d_ip6); + /* + * s_ip and d_ip is not on the same subnet, we need to using + * output_bridge netdev's ip as the arp sender or nd sender. + */ + if (o_ip) { + tnl_send_arp_request(ctx, out_dev, smac, o_ip, d_ip); + } else { + tnl_send_nd_request(ctx, out_dev, smac, &o_ip6, &d_ip6); + } } return err; } -- 2.12.2 diff --git a/lib/ovs-router.c b/lib/ovs-router.c index 09b81c6e5..3f9a72153 100644 --- a/lib/ovs-router.c +++ b/lib/ovs-router.c @@ -132,7 +132,7 @@ ovs_router_lookup(uint32_t mark, const struct in6_addr *ip6_dst, ovs_strlcpy(output_bridge, p->output_bridge, IFNAMSIZ); *gw = p->gw; - if (src && !ipv6_addr_is_set(src)) { + if (src) { *src = p->src_addr; } return true; diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index a6f4ea334..36253379d 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, o_ip = 0; struct in6_addr s_ip6 = in6addr_any; struct in6_addr d_ip6 = in6addr_any; + struct in6_addr o_ip6 = in6addr_any; struct eth_addr smac; struct eth_addr dmac; int err; @@ -3627,7 +3628,14 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport, in6_addr_set_mapped_ipv4(&s_ip6, flow->tunnel.ip_src); } - err = tnl_route_lookup_flow(ctx, flow, &d_ip6, &s_ip6, &out_dev); + if (!ipv6_addr_is_set(&s_ip6)) { + err = tnl_route_lookup_flow(ctx, flow, &d_ip6, &s_ip6, &out_dev); + } else { + /* o_ip6/o_ip means the output_bridge netdev's ip. */ + o_ip6 = s_ip6; + err = tnl_route_lookup_flow(ctx, flow, &d_ip6, &o_ip6, &out_dev); + } + if (err) { xlate_report(ctx, OFT_WARN, "native tunnel routing failed"); return err; @@ -3648,6 +3656,7 @@ native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport,