From patchwork Thu Jan 2 22:18:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 306296 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C7A0B2C00A2 for ; Fri, 3 Jan 2014 09:18:51 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751433AbaABWSs (ORCPT ); Thu, 2 Jan 2014 17:18:48 -0500 Received: from mail-ie0-f202.google.com ([209.85.223.202]:47264 "EHLO mail-ie0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751136AbaABWSr (ORCPT ); Thu, 2 Jan 2014 17:18:47 -0500 Received: by mail-ie0-f202.google.com with SMTP id lx4so3336889iec.5 for ; Thu, 02 Jan 2014 14:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:user-agent:mime-version :content-type; bh=yl67CpkRFYoXWqkk/ftUcujfuhNKmyaRoA8ddSyGLV8=; b=Yy4hRuDbxZ1jQXhMWi9gc6w9wOp50Ge780PYJyucfHV5/sP9Jgb+scGC+jGGBdjvTS 9T6n1vG9530dfIaWOV0M1WjXj41VX60G7eWOVOoECoLaxiI+c0QVNwERlX6hfIVAntMI 7Ybr0ITeVM0M4rR2LdCzM1wIfMIBmtUgeCiKTt9CGsf1IWCdLOGl9XVw16jrxTMR19Sc B80NL4DqL+dLF/j/aR+/aY8EeRFqThIOuBIB9iR7SaOWNECjsJygEh4Vp3qmR1U/WGHu Hff8HZt2uJaUYXi7yOZiujrfZ5eKHImFIXSVj+JAH2CTXSrG/8QIQZyQ6P8p8jhshrF9 S/sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version:content-type; bh=yl67CpkRFYoXWqkk/ftUcujfuhNKmyaRoA8ddSyGLV8=; b=YAwmJ8gqTaGJGSPOKloFBdKrkI/GMmyTjZipmOPRcXITepznKdehB5R3l77ycsBJXd 2a7rDZzbOVvVXLrzbatx3QCZT9CX+gLxW59BVRZuILakrKzloRnJJf1oN1PBtEKfbOlF c12GwYs8YceYwSLllvI9DbLOzWEhkTP1Vl9PRWFwS0T3ViobTwezQdtRxKqC76DwAfFH 9CFD8v7fr9q3QXl++5KleqUsVTgQX3nGOy5SPINhNfRQfd3Bsxnt0sOUocstoCQgwG4M 92DcsEuzsJHp98vxIZeyNWeifk7Dz/Ybmf8uQq9BxUSWq5Kg9jarEzftDAfwJLqEuh0o K1eA== X-Gm-Message-State: ALoCoQlvx7FNBBScckSD6Xt9CEVhy8uzmIR9Y+mKXYv0dnBnT19efqSpl4VCyYUDwO85PwJy4e2JxaGBtNKPNRcwrR7Bbqbwz7z1Z+xhON3nCC7JCG95Dleo1yA0UrlXWp31TyBZkwvRZsxLnJqHNQS/Fnv5BoQ75iTgBr3zeFTtdwQ2H2oOGHRZA7jU59rEWFj3D0asBHUs28UHXdFjq03WzxUugT7dYw== X-Received: by 10.43.65.81 with SMTP id xl17mr29793625icb.29.1388701126981; Thu, 02 Jan 2014 14:18:46 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id k45si22997yhn.4.2014.01.02.14.18.46 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Jan 2014 14:18:46 -0800 (PST) Received: from tomh.mtv.corp.google.com (tomh.mtv.corp.google.com [172.18.82.128]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id B8DEE31C207; Thu, 2 Jan 2014 14:18:46 -0800 (PST) Received: by tomh.mtv.corp.google.com (Postfix, from userid 60832) id 6C6B820084B; Thu, 2 Jan 2014 14:18:46 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by tomh.mtv.corp.google.com (Postfix) with ESMTP id 63951200661; Thu, 2 Jan 2014 14:18:46 -0800 (PST) Date: Thu, 2 Jan 2014 14:18:46 -0800 (PST) From: Tom Herbert To: davem@davemloft.net, netdev@vger.kernel.org cc: hkchu@google.com Subject: [PATCH RFC 5/7] net: Support for direct GRE/GUE RX encapsulation Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Adds a module parameter for a GRE/UDP port and opens the GUE UDP port at initialization. Signed-off-by: Tom Herbert --- net/ipv4/ip_gre.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index e559e90..786fd59 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -47,6 +47,7 @@ #include #include #include +#include #if IS_ENABLED(CONFIG_IPV6) #include @@ -115,6 +116,13 @@ static bool log_ecn_error = true; module_param(log_ecn_error, bool, 0644); MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN"); +#if defined(CONFIG_NET_GUE) || defined(CONFIG_NET_GUE_MODULE) +static int gre_udp_port = 0; +module_param(gre_udp_port, int, 0); +MODULE_PARM_DESC(gre_udp_port, "GRE/UDP port"); +static struct socket *gue_sock = NULL; +#endif + static struct rtnl_link_ops ipgre_link_ops __read_mostly; static int ipgre_tunnel_init(struct net_device *dev); @@ -784,6 +792,26 @@ static struct pernet_operations ipgre_tap_net_ops = { .size = sizeof(struct ip_tunnel_net), }; +static int open_gre_gue_port(void) +{ +#if defined(CONFIG_NET_GUE) || defined(CONFIG_NET_GUE_MODULE) + if (gre_udp_port) + return gue_open_direct_port(gre_udp_port, IPPROTO_GRE, + &gue_sock); +#endif + return 0; +} + +static void close_gre_gue_port(void) +{ +#if defined(CONFIG_NET_GUE) || defined(CONFIG_NET_GUE_MODULE) + if (gue_sock) { + gue_close_port(gue_sock); + gue_sock = NULL; + } +#endif +} + static int __init ipgre_init(void) { int err; @@ -812,8 +840,14 @@ static int __init ipgre_init(void) if (err < 0) goto tap_ops_failed; + err = open_gre_gue_port(); + if (err < 0) + goto gre_udp_port_failed; + return 0; +gre_udp_port_failed: + rtnl_link_unregister(&ipgre_tap_ops); tap_ops_failed: rtnl_link_unregister(&ipgre_link_ops); rtnl_link_failed: @@ -827,6 +861,7 @@ pnet_tap_faied: static void __exit ipgre_fini(void) { + close_gre_gue_port(); rtnl_link_unregister(&ipgre_tap_ops); rtnl_link_unregister(&ipgre_link_ops); gre_cisco_unregister(&ipgre_protocol);