From patchwork Wed Jul 11 16:45:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 942603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.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.b="sbDpMnM3"; dkim-atps=neutral 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 41QlLr0KNszB4MN for ; Thu, 12 Jul 2018 02:45:21 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 260C3EA4; Wed, 11 Jul 2018 16:45:19 +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 3612AE6C for ; Wed, 11 Jul 2018 16:45:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id BF118FC for ; Wed, 11 Jul 2018 16:45:17 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id e6-v6so3065345pgv.2 for ; Wed, 11 Jul 2018 09:45:17 -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; bh=eUd94733R9ztLLqpM1mfntyenLDww03PXjLfmcKu7qw=; b=sbDpMnM3RxccxSq8+FjWqYE+uaU0vprsvAgcc9uiRpbzQoutY0hxFyGjB+BhtFJw/G UutVM+mamjs79mVeAW0ef3z7rSpMJ+NOQfet7wZmt5A6aFibhz3o8f8v4qHFi04GVgf/ hZphKeScnIkGc/i3nIIvkuHaiHTnoMoPGY5XBp9KsEO2lY6zo+Y5S+AOuvK0Pfk6nGIt BORkGkXHB/aSZZSxqbmQ0OwjM1b2yjDs9bXlGwuMfUzbauYeshBhOWzqOZXbRkb5d/4W oUSYdvZ1GSWpC2YgOCy41ptJYuQj8RDV65c7tCRoz7H1FslmNaQIzc+3qsK5w1gD0gSx ZYMw== 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; bh=eUd94733R9ztLLqpM1mfntyenLDww03PXjLfmcKu7qw=; b=rXhek5c0jiLNPXVN0O97wSAsrZU2HvHEaB5sDooJSsmQpdH2bZcuv+5FHHsf93GuAu vbvuGnlB0IEgTB6LFBpyk2vkpN09lXWBmj4yi+YP0Ror8kRQvMLkjjufQYymXT7U3aZG CbGIuhxXyP3KjEVGBuSOizkEg88yasM393Ckd3CjZMokcWe6mrGoY3tOdlzsYbPdFm/k 0lhbvBOo2c/3lMiNjdCYRY9SY/4A5+tblZXtYHKU2+e3OcmHBZeKylJdrsTBhBIII/78 doj2HIxgGKFAMkGJPZmrPC38WCwCsFIoVkGIPizvyTYoOdFgRYD7Fe9OQnB+UV/jlZs9 6hSA== X-Gm-Message-State: APt69E3BX+vqEdJ5mT+rIdpRv0dEwrLcN8ExVk+XKYZVZg6QebalgNGw jQJoHwElAMMH8a4+k3Xd/gmvDAYv X-Google-Smtp-Source: AAOMgpdxjidvK2jjiyjlUeR+52+sVO37E9frQFTV+GAt8jdvHbXRWDq/lr423Z0ynCBVuicu4NY6QQ== X-Received: by 2002:a63:6a45:: with SMTP id f66-v6mr26658866pgc.81.1531327517101; Wed, 11 Jul 2018 09:45:17 -0700 (PDT) Received: from ovs.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id t8-v6sm17969769pfj.165.2018.07.11.09.45.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 09:45:16 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Wed, 11 Jul 2018 09:45:08 -0700 Message-Id: <1531327508-10557-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCHv3] datapath: work around the single GRE receive limitation. 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 Commit 9f57c67c379d ("gre: Remove support for sharing GRE protocol hook") allows only single GRE packet receiver. When upstream kernel's gre module is loaded, the gre.ko exclusively becomes the only gre packet receiver, preventing OVS kernel module from registering another gre receiver. We can either try to unload the gre.ko by removing its dependencies, or, in this patch, we try to register OVS as only the GRE transmit portion when detecting there already exists another GRE receiver. Signed-off-by: William Tu Tested-by: Greg Rose Reviewed-by: Greg Rose Cc: Greg Rose Cc: Yifeng Sun --- v1->v2: improve warnning message --- datapath/linux/compat/ip_gre.c | 60 +++++++++++++++++++++++++++++++++--------- datapath/vport.c | 12 ++++++--- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c index 92de70127189..1ab798164894 100644 --- a/datapath/linux/compat/ip_gre.c +++ b/datapath/linux/compat/ip_gre.c @@ -71,6 +71,7 @@ static void erspan_build_header(struct sk_buff *skb, bool truncate, bool is_ipv4); static struct rtnl_link_ops ipgre_link_ops __read_mostly; +static bool ip_gre_loaded = false; #define ip_gre_calc_hlen rpl_ip_gre_calc_hlen static int ip_gre_calc_hlen(__be16 o_flags) @@ -1640,25 +1641,57 @@ int rpl_ipgre_init(void) int err; err = register_pernet_device(&ipgre_tap_net_ops); - if (err < 0) - goto pnet_tap_failed; + if (err < 0) { + if (err == -EEXIST) + goto ip_gre_loaded; + else + goto pnet_tap_failed; + } err = register_pernet_device(&erspan_net_ops); - if (err < 0) - goto pnet_erspan_failed; + if (err < 0) { + if (err == -EEXIST) + goto ip_gre_loaded; + else + goto pnet_erspan_failed; + } err = register_pernet_device(&ipgre_net_ops); - if (err < 0) - goto pnet_ipgre_failed; + if (err < 0) { + if (err == -EEXIST) + goto ip_gre_loaded; + else + goto pnet_ipgre_failed; + } err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO); if (err < 0) { pr_info("%s: can't add protocol\n", __func__); - goto add_proto_failed; + if (err == -EBUSY) { + goto ip_gre_loaded; + } else { + goto add_proto_failed; + } } pr_info("GRE over IPv4 tunneling driver\n"); - + ovs_vport_ops_register(&ovs_ipgre_vport_ops); + ovs_vport_ops_register(&ovs_erspan_vport_ops); + return 0; + +ip_gre_loaded: + /* Since GRE only allows single receiver to be registerd, + * we skip here so only gre transmit works, see: + * + * commit 9f57c67c379d88a10e8ad676426fee5ae7341b14 + * Author: Pravin B Shelar + * Date: Fri Aug 7 23:51:52 2015 -0700 + * gre: Remove support for sharing GRE protocol hook + * + * OVS GRE receive part is disabled. + */ + pr_info("GRE TX only over IPv4 tunneling driver\n"); + ip_gre_loaded = true; ovs_vport_ops_register(&ovs_ipgre_vport_ops); ovs_vport_ops_register(&ovs_erspan_vport_ops); return 0; @@ -1678,10 +1711,13 @@ void rpl_ipgre_fini(void) { ovs_vport_ops_unregister(&ovs_erspan_vport_ops); ovs_vport_ops_unregister(&ovs_ipgre_vport_ops); - gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO); - unregister_pernet_device(&ipgre_net_ops); - unregister_pernet_device(&erspan_net_ops); - unregister_pernet_device(&ipgre_tap_net_ops); + + if (!ip_gre_loaded) { + gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO); + unregister_pernet_device(&ipgre_net_ops); + unregister_pernet_device(&erspan_net_ops); + unregister_pernet_device(&ipgre_tap_net_ops); + } } #endif diff --git a/datapath/vport.c b/datapath/vport.c index 02f6b56d3243..28ddb865c3a2 100644 --- a/datapath/vport.c +++ b/datapath/vport.c @@ -66,11 +66,15 @@ int ovs_vport_init(void) if (err) goto err_lisp; err = gre_init(); - if (err && err != -EEXIST) + if (err && err != -EEXIST) { goto err_gre; - else if (err == -EEXIST) - pr_warn("Cannot take GRE protocol entry - The ERSPAN feature may not be supported\n"); - else { + } else { + if (err == -EEXIST) { + pr_warn("Cannot take GRE protocol rx entry"\ + "- The GRE/ERSPAN rx feature not supported\n"); + /* continue GRE tx */ + } + err = ipgre_init(); if (err && err != -EEXIST) goto err_ipgre;