From patchwork Thu May 18 20:10:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Garver X-Patchwork-Id: 764172 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 3wTMnb34Qrz9s4q for ; Fri, 19 May 2017 06:13:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A62CEBE8; Thu, 18 May 2017 20:10:44 +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 3ED45B7E 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 8234E1F5 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 E7D6280488 for ; Thu, 18 May 2017 20:10:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E7D6280488 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=erig.me Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=e@erig.me DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E7D6280488 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 A41C318207 for ; Thu, 18 May 2017 20:10:36 +0000 (UTC) From: Eric Garver To: dev@openvswitch.org Date: Thu, 18 May 2017 16:10:31 -0400 Message-Id: <20170518201033.13092-6-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.28]); 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 5/7] dpif-netlink-rtnl: Support GRE 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 GRE 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 | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c index e0924c968cc0..7594e75088d7 100644 --- a/lib/dpif-netlink-rtnl.c +++ b/lib/dpif-netlink-rtnl.c @@ -41,6 +41,13 @@ VLOG_DEFINE_THIS_MODULE(dpif_netlink_rtnl); #define IFLA_VXLAN_COLLECT_METADATA 25 #endif +#ifndef IFLA_GRE_MAX +#define IFLA_GRE_MAX 0 +#endif +#if IFLA_GRE_MAX < 18 +#define IFLA_GRE_COLLECT_METADATA 18 +#endif + static const struct nl_policy rtlink_policy[] = { [IFLA_LINKINFO] = { .type = NL_A_NESTED }, }; @@ -54,6 +61,9 @@ static const struct nl_policy vxlan_policy[] = { [IFLA_VXLAN_UDP_ZERO_CSUM6_RX] = { .type = NL_A_U8 }, [IFLA_VXLAN_PORT] = { .type = NL_A_U16 }, }; +static const struct nl_policy gre_policy[] = { + [IFLA_GRE_COLLECT_METADATA] = { .type = NL_A_FLAG }, +}; static const char * vport_type_to_kind(enum ovs_vport_type type) @@ -168,6 +178,30 @@ dpif_netlink_rtnl_vxlan_verify(const struct netdev_tunnel_config *tnl_cfg, return err; } +static int +dpif_netlink_rtnl_gre_verify(const struct netdev_tunnel_config OVS_UNUSED *tnl, + const char *name, const char *kind) +{ + struct ofpbuf *reply; + int err; + + err = dpif_netlink_rtnl_getlink(name, &reply); + + if (!err) { + struct nlattr *gre[ARRAY_SIZE(gre_policy)]; + + err = rtnl_policy_parse(kind, reply, gre_policy, gre, + ARRAY_SIZE(gre_policy)); + if (!err) { + if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { + err = EINVAL; + } + } + ofpbuf_delete(reply); + } + + return err; +} static int dpif_netlink_rtnl_verify(const struct netdev_tunnel_config *tnl_cfg, @@ -184,6 +218,7 @@ dpif_netlink_rtnl_verify(const struct netdev_tunnel_config *tnl_cfg, case OVS_VPORT_TYPE_VXLAN: return dpif_netlink_rtnl_vxlan_verify(tnl_cfg, name, kind); case OVS_VPORT_TYPE_GRE: + return dpif_netlink_rtnl_gre_verify(tnl_cfg, name, kind); case OVS_VPORT_TYPE_GENEVE: case OVS_VPORT_TYPE_NETDEV: case OVS_VPORT_TYPE_INTERNAL: @@ -230,6 +265,8 @@ dpif_netlink_rtnl_create(const struct netdev_tunnel_config *tnl_cfg, nl_msg_put_be16(&request, IFLA_VXLAN_PORT, tnl_cfg->dst_port); break; case OVS_VPORT_TYPE_GRE: + nl_msg_put_flag(&request, IFLA_GRE_COLLECT_METADATA); + break; case OVS_VPORT_TYPE_GENEVE: case OVS_VPORT_TYPE_NETDEV: case OVS_VPORT_TYPE_INTERNAL: @@ -321,8 +358,8 @@ dpif_netlink_rtnl_port_destroy(const char *name, const char *type) { switch (netdev_to_ovs_vport_type(type)) { case OVS_VPORT_TYPE_VXLAN: - return dpif_netlink_rtnl_destroy(name); case OVS_VPORT_TYPE_GRE: + return dpif_netlink_rtnl_destroy(name); case OVS_VPORT_TYPE_GENEVE: case OVS_VPORT_TYPE_NETDEV: case OVS_VPORT_TYPE_INTERNAL: