From patchwork Thu Sep 17 17:14:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1366294 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.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Crx09eI5; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bsk921Fmtz9sPB for ; Fri, 18 Sep 2020 03:14:30 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B4A3687699; Thu, 17 Sep 2020 17:14:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gp3AWo677nv9; Thu, 17 Sep 2020 17:14:26 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id BDE61876A5; Thu, 17 Sep 2020 17:14:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9BAADC089E; Thu, 17 Sep 2020 17:14:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id CB4CFC0859 for ; Thu, 17 Sep 2020 17:14:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C67D587697 for ; Thu, 17 Sep 2020 17:14:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ju6r1mDk4F7l for ; Thu, 17 Sep 2020 17:14:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by hemlock.osuosl.org (Postfix) with ESMTPS id 10EC487688 for ; Thu, 17 Sep 2020 17:14:22 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id c3so1475449plz.5 for ; Thu, 17 Sep 2020 10:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TeOqt6W7CCjU1VbNlfT2NB4y9nvZ8bgib1ee4ThjvNo=; b=Crx09eI5vnWUrFM+tQtUWrNXFVmOaoZ1BoU+HoVLqifBjHdRCXderic3ZCVKLHO0wR a260Xp8MIrYGiNT7bCx13cNnGC0gLHkL2AaYxahp1+7HlRReyUm4earklb1fwezRzLMO SyexYyGi15ReXzSMB3j/zmEC41yw9XNhvDbobPpsf4v3iBpeL99Wo33vGD0C96qlvHMX AnFaHHVlijOyKkJiBqW5PQgKvE2fi8lYwrBXGrI9sXiUCE1g7fKZ5JDn9FYIeh8OBjiN G7zBmAteoFgQdR/GFtsyabw+SJnNvPPI/9Ha1vw0WlbWSLTvdBUJ5uBAhwd1hF6YKcjr TSSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TeOqt6W7CCjU1VbNlfT2NB4y9nvZ8bgib1ee4ThjvNo=; b=KqzFIkPP9N5o4PFFbgx/b/FPlcglMpbBTlbQhKvgU7BqyuUMgjftlB0PhrMsBTK1jC ZtZKt3yLytpKAYDScE+iRrbDnYr8YNPiTS7bmyBeLL+4fOPbzx9L/J2QIcadBbTgReic NLn6892kFQwDA62a6XYuf6FLUmlJDoiEsIOFOB/vHkAL9klvsEu4P2jj33nOx28R5Cph SKBe39htXsjB7ilfs+dIvj2v6fF//Kano3l5/ANdpUEgZsDjVMiQx+E30cM/opPQrwfl ZoMVDDCQAvt01j+VtQMV3KC6U5Bp0M6b9wKPEpyeU8/jFtmygK8nPJU+7GCaBdrNFqpf 4S2A== X-Gm-Message-State: AOAM530uf8nO1/p89PYW3rd/6fZUDeFdVxH143HDIxWb4aS1j0n6N1gS tHMy2yFzFfBxL11w6RWKcMH0zs8YqkmbVw== X-Google-Smtp-Source: ABdhPJxA/4c2ljsSKw7I9vuidD5qufGvnYXUdWGxZUitPlqwFc+tjODnoLA0cCz07LNfYzYL8whslg== X-Received: by 2002:a17:90a:104f:: with SMTP id y15mr8778945pjd.45.1600362860804; Thu, 17 Sep 2020 10:14:20 -0700 (PDT) Received: from VMware-box.domain ([97.115.183.169]) by smtp.googlemail.com with ESMTPSA id q4sm269822pjl.28.2020.09.17.10.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:14:19 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Thu, 17 Sep 2020 10:14:13 -0700 Message-Id: <20200917171414.7886-3-gvrose8192@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917171414.7886-1-gvrose8192@gmail.com> References: <20200917171414.7886-1-gvrose8192@gmail.com> Cc: wenxu , i.maximets@ovn.org Subject: [ovs-dev] [PATCH 2/3] datapath: Make metadata_dst tunnel work in IP_TUNNEL_INFO_BRIDGE mode 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 Upstream commit: commit 18b6f717483a835fb98de9f0df6c724df9324e78 Author: wenxu Date: Thu Mar 28 12:43:23 2019 +0800 openvswitch: Make metadata_dst tunnel work in IP_TUNNEL_INFO_BRIDGE mode There is currently no support for the multicast/broadcast aspects of VXLAN in ovs. In the datapath flow the tun_dst must specific. But in the IP_TUNNEL_INFO_BRIDGE mode the tun_dst can not be specific. And the packet can forward through the fdb table of vxlan devcice. In this mode the broadcast/multicast packet can be sent through the following ways in ovs. ovs-vsctl add-port br0 vxlan -- set in vxlan type=vxlan \ options:key=1000 options:remote_ip=flow ovs-ofctl add-flow br0 in_port=LOCAL,dl_dst=ff:ff:ff:ff:ff:ff, \ action=output:vxlan bridge fdb append ff:ff:ff:ff:ff:ff dev vxlan_sys_4789 dst 172.168.0.1 \ src_vni 1000 vni 1000 self bridge fdb append ff:ff:ff:ff:ff:ff dev vxlan_sys_4789 dst 172.168.0.2 \ src_vni 1000 vni 1000 self Signed-off-by: wenxu Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Cc: wenxu Signed-off-by: Greg Rose --- datapath/flow_netlink.c | 46 +++++++++++++++---- .../linux/compat/include/linux/openvswitch.h | 1 + 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c index d3fd77106..24ecdf816 100644 --- a/datapath/flow_netlink.c +++ b/datapath/flow_netlink.c @@ -406,6 +406,7 @@ static const struct ovs_len_tbl ovs_tunnel_key_lens[OVS_TUNNEL_KEY_ATTR_MAX + 1] [OVS_TUNNEL_KEY_ATTR_IPV6_SRC] = { .len = sizeof(struct in6_addr) }, [OVS_TUNNEL_KEY_ATTR_IPV6_DST] = { .len = sizeof(struct in6_addr) }, [OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS] = { .len = OVS_ATTR_VARIABLE }, + [OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE] = { .len = 0 }, }; static const struct ovs_len_tbl @@ -669,6 +670,7 @@ static int ip_tun_from_nlattr(const struct nlattr *attr, bool log) { bool ttl = false, ipv4 = false, ipv6 = false; + bool info_bridge_mode = false; __be16 tun_flags = 0; int opts_type = 0; struct nlattr *a; @@ -785,6 +787,10 @@ static int ip_tun_from_nlattr(const struct nlattr *attr, tun_flags |= TUNNEL_ERSPAN_OPT; opts_type = type; break; + case OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE: + info_bridge_mode = true; + ipv4 = true; + break; default: OVS_NLERR(log, "Unknown IP tunnel attribute %d", type); @@ -815,16 +821,29 @@ static int ip_tun_from_nlattr(const struct nlattr *attr, OVS_NLERR(log, "IP tunnel dst address not specified"); return -EINVAL; } - if (ipv4 && !match->key->tun_key.u.ipv4.dst) { - OVS_NLERR(log, "IPv4 tunnel dst address is zero"); - return -EINVAL; + if (ipv4) { + if (info_bridge_mode) { + if (match->key->tun_key.u.ipv4.src || + match->key->tun_key.u.ipv4.dst || + match->key->tun_key.tp_src || + match->key->tun_key.tp_dst || + match->key->tun_key.ttl || + match->key->tun_key.tos || + tun_flags & ~TUNNEL_KEY) { + OVS_NLERR(log, "IPv4 tun info is not correct"); + return -EINVAL; + } + } else if (!match->key->tun_key.u.ipv4.dst) { + OVS_NLERR(log, "IPv4 tunnel dst address is zero"); + return -EINVAL; + } } if (ipv6 && ipv6_addr_any(&match->key->tun_key.u.ipv6.dst)) { OVS_NLERR(log, "IPv6 tunnel dst address is zero"); return -EINVAL; } - if (!ttl) { + if (!ttl && !info_bridge_mode) { OVS_NLERR(log, "IP tunnel TTL not specified."); return -EINVAL; } @@ -853,12 +872,17 @@ static int vxlan_opt_to_nlattr(struct sk_buff *skb, static int __ip_tun_to_nlattr(struct sk_buff *skb, const struct ip_tunnel_key *output, const void *tun_opts, int swkey_tun_opts_len, - unsigned short tun_proto) + unsigned short tun_proto, u8 mode) { if (output->tun_flags & TUNNEL_KEY && nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id, OVS_TUNNEL_KEY_ATTR_PAD)) return -EMSGSIZE; + + if (mode & IP_TUNNEL_INFO_BRIDGE) + return nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE) + ? -EMSGSIZE : 0; + switch (tun_proto) { case AF_INET: if (output->u.ipv4.src && @@ -921,7 +945,7 @@ static int __ip_tun_to_nlattr(struct sk_buff *skb, static int ip_tun_to_nlattr(struct sk_buff *skb, const struct ip_tunnel_key *output, const void *tun_opts, int swkey_tun_opts_len, - unsigned short tun_proto) + unsigned short tun_proto, u8 mode) { struct nlattr *nla; int err; @@ -931,7 +955,7 @@ static int ip_tun_to_nlattr(struct sk_buff *skb, return -EMSGSIZE; err = __ip_tun_to_nlattr(skb, output, tun_opts, swkey_tun_opts_len, - tun_proto); + tun_proto, mode); if (err) return err; @@ -945,7 +969,7 @@ int ovs_nla_put_tunnel_info(struct sk_buff *skb, return __ip_tun_to_nlattr(skb, &tun_info->key, ip_tunnel_info_opts(tun_info), tun_info->options_len, - ip_tunnel_info_af(tun_info)); + ip_tunnel_info_af(tun_info), tun_info->mode); } static int encode_vlan_from_nlattrs(struct sw_flow_match *match, @@ -1999,7 +2023,7 @@ static int __ovs_nla_put_key(const struct sw_flow_key *swkey, opts = TUN_METADATA_OPTS(output, swkey->tun_opts_len); if (ip_tun_to_nlattr(skb, &output->tun_key, opts, - swkey->tun_opts_len, swkey->tun_proto)) + swkey->tun_opts_len, swkey->tun_proto, 0)) goto nla_put_failure; } @@ -2634,6 +2658,8 @@ static int validate_and_copy_set_tun(const struct nlattr *attr, tun_info->mode = IP_TUNNEL_INFO_TX; if (key.tun_proto == AF_INET6) tun_info->mode |= IP_TUNNEL_INFO_IPV6; + else if (key.tun_proto == AF_INET && key.tun_key.u.ipv4.dst == 0) + tun_info->mode |= IP_TUNNEL_INFO_BRIDGE; tun_info->key = key.tun_key; /* We need to store the options in the action itself since @@ -3418,7 +3444,7 @@ static int set_action_to_attr(const struct nlattr *a, struct sk_buff *skb) err = ip_tun_to_nlattr(skb, &tun_info->key, ip_tunnel_info_opts(tun_info), tun_info->options_len, - ip_tunnel_info_af(tun_info)); + ip_tunnel_info_af(tun_info), tun_info->mode); if (err) return err; nla_nest_end(skb, start); diff --git a/datapath/linux/compat/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h index cc41bbea4..28fe7b3b7 100644 --- a/datapath/linux/compat/include/linux/openvswitch.h +++ b/datapath/linux/compat/include/linux/openvswitch.h @@ -405,6 +405,7 @@ enum ovs_tunnel_key_attr { OVS_TUNNEL_KEY_ATTR_IPV6_DST, /* struct in6_addr dst IPv6 address. */ OVS_TUNNEL_KEY_ATTR_PAD, OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS, /* struct erspan_metadata */ + OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE, /* No argument. IPV4_INFO_BRIDGE mode.*/ OVS_TUNNEL_KEY_ATTR_GTPU_OPTS, /* struct gtpu_metadata */ __OVS_TUNNEL_KEY_ATTR_MAX };