From patchwork Thu May 18 20:10:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Garver X-Patchwork-Id: 764173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wTMp84mJ4z9s4q for ; Fri, 19 May 2017 06:13:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id ACEEEBEB; Thu, 18 May 2017 20:10:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 6E358BC7 for ; Thu, 18 May 2017 20:10:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DBC30206 for ; Thu, 18 May 2017 20:10:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5781EC04B927 for ; Thu, 18 May 2017 20:10:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5781EC04B927 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=erig.me Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=e@erig.me DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5781EC04B927 Received: from dev-rhel7.localdomain (wsfd-netdev-vmhost.ntdv.lab.eng.bos.redhat.com [10.19.17.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1404118203 for ; Thu, 18 May 2017 20:10:36 +0000 (UTC) From: Eric Garver To: dev@openvswitch.org Date: Thu, 18 May 2017 16:10:32 -0400 Message-Id: <20170518201033.13092-7-e@erig.me> In-Reply-To: <20170518201033.13092-1-e@erig.me> References: <20170518201033.13092-1-e@erig.me> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 May 2017 20:10:37 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v5 6/7] dpif-netlink-rtnl: Support GENEVE creation X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Creates GENEVE devices using rtnetlink and tunnel metadata. Co-Authored-by: Thadeu Lima de Souza Cascardo Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Eric Garver --- lib/dpif-netlink-rtnl.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c index 7594e75088d7..2061564436df 100644 --- a/lib/dpif-netlink-rtnl.c +++ b/lib/dpif-netlink-rtnl.c @@ -48,6 +48,15 @@ VLOG_DEFINE_THIS_MODULE(dpif_netlink_rtnl); #define IFLA_GRE_COLLECT_METADATA 18 #endif +#ifndef IFLA_GENEVE_MAX +#define IFLA_GENEVE_MAX 0 +#endif +#if IFLA_GENEVE_MAX < 10 +#define IFLA_GENEVE_PORT 5 +#define IFLA_GENEVE_COLLECT_METADATA 6 +#define IFLA_GENEVE_UDP_ZERO_CSUM6_RX 10 +#endif + static const struct nl_policy rtlink_policy[] = { [IFLA_LINKINFO] = { .type = NL_A_NESTED }, }; @@ -64,6 +73,11 @@ static const struct nl_policy vxlan_policy[] = { static const struct nl_policy gre_policy[] = { [IFLA_GRE_COLLECT_METADATA] = { .type = NL_A_FLAG }, }; +static const struct nl_policy geneve_policy[] = { + [IFLA_GENEVE_COLLECT_METADATA] = { .type = NL_A_FLAG }, + [IFLA_GENEVE_UDP_ZERO_CSUM6_RX] = { .type = NL_A_U8 }, + [IFLA_GENEVE_PORT] = { .type = NL_A_U16 }, +}; static const char * vport_type_to_kind(enum ovs_vport_type type) @@ -204,6 +218,34 @@ dpif_netlink_rtnl_gre_verify(const struct netdev_tunnel_config OVS_UNUSED *tnl, } static int +dpif_netlink_rtnl_geneve_verify(const struct netdev_tunnel_config *tnl_cfg, + const char *name, const char *kind) +{ + struct ofpbuf *reply; + int err; + + err = dpif_netlink_rtnl_getlink(name, &reply); + + if (!err) { + struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; + + err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, + ARRAY_SIZE(geneve_policy)); + if (!err) { + if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) + || 1 != nl_attr_get_u8(geneve[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) + || (tnl_cfg->dst_port + != nl_attr_get_be16(geneve[IFLA_GENEVE_PORT]))) { + err = EINVAL; + } + } + ofpbuf_delete(reply); + } + + return err; +} + +static int dpif_netlink_rtnl_verify(const struct netdev_tunnel_config *tnl_cfg, enum ovs_vport_type type, const char *name) { @@ -220,6 +262,7 @@ dpif_netlink_rtnl_verify(const struct netdev_tunnel_config *tnl_cfg, case OVS_VPORT_TYPE_GRE: return dpif_netlink_rtnl_gre_verify(tnl_cfg, name, kind); case OVS_VPORT_TYPE_GENEVE: + return dpif_netlink_rtnl_geneve_verify(tnl_cfg, name, kind); case OVS_VPORT_TYPE_NETDEV: case OVS_VPORT_TYPE_INTERNAL: case OVS_VPORT_TYPE_LISP: @@ -268,6 +311,10 @@ dpif_netlink_rtnl_create(const struct netdev_tunnel_config *tnl_cfg, nl_msg_put_flag(&request, IFLA_GRE_COLLECT_METADATA); break; case OVS_VPORT_TYPE_GENEVE: + nl_msg_put_flag(&request, IFLA_GENEVE_COLLECT_METADATA); + nl_msg_put_u8(&request, IFLA_GENEVE_UDP_ZERO_CSUM6_RX, 1); + nl_msg_put_be16(&request, IFLA_GENEVE_PORT, tnl_cfg->dst_port); + break; case OVS_VPORT_TYPE_NETDEV: case OVS_VPORT_TYPE_INTERNAL: case OVS_VPORT_TYPE_LISP: @@ -359,8 +406,8 @@ dpif_netlink_rtnl_port_destroy(const char *name, const char *type) switch (netdev_to_ovs_vport_type(type)) { case OVS_VPORT_TYPE_VXLAN: case OVS_VPORT_TYPE_GRE: - return dpif_netlink_rtnl_destroy(name); case OVS_VPORT_TYPE_GENEVE: + return dpif_netlink_rtnl_destroy(name); case OVS_VPORT_TYPE_NETDEV: case OVS_VPORT_TYPE_INTERNAL: case OVS_VPORT_TYPE_LISP: