From patchwork Thu Jun 24 13:09:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: miter X-Patchwork-Id: 1496616 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::136; helo=smtp3.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=fq8IvP/Y; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4G9gSv4pjCz9sRf for ; Thu, 24 Jun 2021 23:09:19 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D49A960BAF; Thu, 24 Jun 2021 13:09:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N9TpjP7f3Mkf; Thu, 24 Jun 2021 13:09:15 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id DE8B8605F7; Thu, 24 Jun 2021 13:09:14 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BB9E9C0010; Thu, 24 Jun 2021 13:09:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id B3117C000E for ; Thu, 24 Jun 2021 13:09:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id AE08E414B3 for ; Thu, 24 Jun 2021 13:09:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=outlook.com 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 mk_BWesw7wMC for ; Thu, 24 Jun 2021 13:09:09 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from AUS01-SY4-obe.outbound.protection.outlook.com (mail-sy4aus01olkn2173.outbound.protection.outlook.com [40.92.62.173]) by smtp4.osuosl.org (Postfix) with ESMTPS id 84D1540E43 for ; Thu, 24 Jun 2021 13:09:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LXvl3d1UTtQ5RnLsgFLuPZc+R9ik8zwihkbUTyTdVr+AHIeyHr0IlGXIbB9nIQ8D3mNHkAelE1vnq42tSjLkXxZn5Rtc7UDHCb4jtpUA1fN6jMPrO3RD+pRET8dI7jRvJcPFIE5fGnMbPV1Y0qVJo4IHs+6/oTy9maFyKBLEPVS/+bH0QvEOlQrbzXwxxthC+9Vrylriu4ZTQ0hcht72S6TOAOUj1qcJKn58wN4/LOs84PSa6QYR+r/RMuiJ1oDfMOX2INJiGJyodTrVcyo5unfLbTudPaHjUelFuJz4jdU5Qq/lS33g1EgupjriVgiJhXqlRAfjEPUo+xMG+5/HwA== 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=H7Smw5D5K1oewMJBGcQlmVE0B2e4Fw9ZqPGJKoNWg9E=; b=itqyDoOoN84sGOMUpOZ4YRLh9CCIrA4gxSCPhSJJL1Le/+/oZoqtKHGXGY7HAwlCGzmL97HD8ypLzPIml17QeezYOFQ4nOC/3paU2qs2sa8fXbY71sGF7gPNKcS59kfxKVeYqno5yKFjOD1fKtI5Obd9+wJI+Yz7pR6vue7n30EPs3rolvbVJWMl43eYAQqViRYwtWOsJJVRNArD5y7z8HQbwIPae1Kitc5LCHyD4XloLG0hXy3zZZoi/SR5BzzRl/hFha89AYmn6+66GnAfdwnXh4TynNzX+Yj9qCiCA2zpUw3yrLf2Ey4KYuz8dhryYTxTPxmpJkyNQwTMcZKMGg== 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=H7Smw5D5K1oewMJBGcQlmVE0B2e4Fw9ZqPGJKoNWg9E=; b=fq8IvP/YQWzllbSCHjA++Qw9j2xmEiSnIeIrmhSclfjmm2hAG/U7pB3ldF/Agz1vbAEfuIgkC9DaaR2AY6beyeymJou01JuhK0iKqbWzZQcXraaOzClodVpufuJVELyoI5QANDtx/9NOakDZJqZV/EMm/Q/7VdDvbIFQz5Wz13zGP0l4VRYma/0smiY/mVlWVbe3bXqOLZyM4RBjwuIPQFtA8/pO+/3VIESOn0wT4PXsrztj8EDc0OEyBVpVCWmP4hVfo1i0Z7uZfWR7Rdq1LgtYglfvX41xhK8WdyvqkgC1nztqJnfKDAXqp3C45hC/RfvURRlJBCH6a+qlTV+Wfw== Received: from MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:15b::24) by MEYP282MB3072.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Thu, 24 Jun 2021 13:09:05 +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.020; Thu, 24 Jun 2021 13:09:05 +0000 From: lin huang To: "dev@openvswitch.org" Thread-Topic: [PATCH] ofproto-dpif-xlate: Using output netdev's ip as tunnel arp/nd request ip Thread-Index: AQHXaPlfU32yH5vJLEOlb+6zaN8sTasjIdUg Date: Thu, 24 Jun 2021 13:09:05 +0000 Message-ID: References: <202106242100348378002@outlook.com> In-Reply-To: <202106242100348378002@outlook.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [5ZieeMG5ZOiui1kp074O/uw+X9ziz8vF] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 679cc33f-893d-4b1f-7776-08d937113eba x-ms-traffictypediagnostic: MEYP282MB3072: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: StoPVo8sLfVPYyL3pCegz/4He/JUfe0cmBg/FToPHGLTMkcJEUa+khUb6CXP9FjPZTTmK2WadiXKVEYdR2Hen4hkmv9TRXLDmHVp1JGQ7l6V2PwRk1JVMUqozHhv7hk7fNXffHu0/KvTTe65PqvmccD5zboWD5/O0jk4Sg6HKw0I0fCAvv7mPP+9VaTBTRvr8+vLh1BFoxn7Saby5F+PmjURsjeybN2xlICv/BBFtusSBPzPcSv1VsgkyRcLnAMqRmxYQTTTCUDRq3VLVdsXAFEvaH+L8Xf+TPVTBIwT0VGTMxRkL8NaompxSISbTe8wL9zBNPT4PqZsnKZX1sLrshGxBTGOiYdXL88Fm65FKquTTSsPVJu+EzqmtgLVc1P2zj2GW6oRhR0/t1Yo6BINxQ== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: C4iTF3d4KOsp3B9q5wCaH6OvP8Nh8I94Gbl37F5zJIjoBoS7+X5FdLdRUwvFKX2zBzbsw0i/EY/mtZhFBgavk0gJq8zVw1AcAsQJMsB+2QwHPQTg9FI08CqSvSI9ABf/c1usOYwT03SY8qeuJaJrFg== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 679cc33f-893d-4b1f-7776-08d937113eba X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2021 13:09:05.4910 (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: MEYP282MB3072 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(-) -- 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..4009fd0f9 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, 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 (local_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; }