Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1956075imm; Thu, 24 May 2018 03:34:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrzIo1h/dZNbBmpg8Kt25rxKkbtRdmkY0tunTiMQeY9B0jtY438ckMRQ+E3rslxX90HaiiI X-Received: by 2002:a17:902:24c7:: with SMTP id l7-v6mr6869114plg.327.1527158062742; Thu, 24 May 2018 03:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158062; cv=none; d=google.com; s=arc-20160816; b=F1a9gHcXhm9JBvrR3emsmqhrMIt93KKc3dvmkFTVC4uVJspLFbgdRYdWCrDogKyci7 j0XwneEeEG1Ms00dFOKLVQR0QRslp+FxuJ1o87JeTWPA9H0jEUrPFH15KVZLd3ZL9G1i hkXzzPomCkiqKroH64SmawfPcTwvX/MO41ELurJAmMQLliIOyNpH1F+LR9yqoykaEl1L VdsP1GIrh/1H4FMnMF5Na2rTlFaA5UiM05eAAv5fnvFkI6B1AlS6hZOa2Jyzsh+PKLPE SYmWdIof6jUkSjptjV+Wy3gJcUbFuniEkn01qpnTvjZ4TYcknJ2utQeUUc1zSt1u+D2m Rexw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=eODh6k1VEr0215hdFr5PiQ/ntByLEmkMxGDix9bUdtc=; b=aGscA0ipHSURUiZbekKkie9Ece4trzCk+SjS5sy3D8WKViyRQlrmVFy+89hoshc3Z4 xRfB/bfjwd6EkedPsJlOC4taEE7+jvDD/13sf9v3xBcBGSE+6B13/rlAHXyu17EXtHr8 y3QB49Y7g+rCALjFJkOH3OF+YqEoJcw6k49wOK9b8D61HCf3xLhkvX/aKiteCZCnk8Yk 4YcgqMOaHbQEYwugcTAXFXPxqZ0Gyog8oOBrVaO6wk8Bk3ndIrtsmT8CMT97f4IbeZMM cg75jcd+9ljo9Io2RRr+ZdaBFwerrzeJXhANxUca6GS+u2C0e0JTioF/7vedS+gffUQ/ /Zug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vWOYqPPe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l18-v6si20407503pfe.299.2018.05.24.03.34.08; Thu, 24 May 2018 03:34:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vWOYqPPe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032182AbeEXKdR (ORCPT + 99 others); Thu, 24 May 2018 06:33:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:43136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965443AbeEXKAj (ORCPT ); Thu, 24 May 2018 06:00:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 33AED2088E; Thu, 24 May 2018 10:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156038; bh=ORF7RauyRyYLr3uTygQKFb7ncXVO8380gUUuENarE7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vWOYqPPeioBLQhnxW35VGuUUX5pmdMqx2v3P2U+2QMs0DSHEgx1+AfQoFY8eh+yXO aNgMTsCiuNAaLuHMyO/G6dRiTAWBasxkguz7VHf6/Dt3wjtxsrH+pNlLHVV5WNSwsm 5jbSc82iqCnE/yugvvaqLg+zCjdBeovz0/xKpIHU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Machata , William Tu , "David S. Miller" Subject: [PATCH 4.16 024/161] net: ip6_gre: Split up ip6gre_tnl_link_config() Date: Thu, 24 May 2018 11:37:29 +0200 Message-Id: <20180524093021.241884033@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Petr Machata [ Upstream commit a483373ead61e6079bc8ebe27e2dfdb2e3c1559f ] The function ip6gre_tnl_link_config() is used for setting up configuration of both ip6gretap and ip6erspan tunnels. Split the function into the common part and the route-lookup part. The latter then takes the calculated header length as an argument. This split will allow the patches down the line to sneak in a custom header length computation for the ERSPAN tunnel. Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") Signed-off-by: Petr Machata Acked-by: William Tu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_gre.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -1019,12 +1019,11 @@ tx_err: return NETDEV_TX_OK; } -static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) +static void ip6gre_tnl_link_config_common(struct ip6_tnl *t) { struct net_device *dev = t->dev; struct __ip6_tnl_parm *p = &t->parms; struct flowi6 *fl6 = &t->fl.u.ip6; - int t_hlen; if (dev->type != ARPHRD_ETHER) { memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); @@ -1051,12 +1050,13 @@ static void ip6gre_tnl_link_config(struc dev->flags |= IFF_POINTOPOINT; else dev->flags &= ~IFF_POINTOPOINT; +} - t->tun_hlen = gre_calc_hlen(t->parms.o_flags); - - t->hlen = t->encap_hlen + t->tun_hlen; - - t_hlen = t->hlen + sizeof(struct ipv6hdr); +static void ip6gre_tnl_link_config_route(struct ip6_tnl *t, int set_mtu, + int t_hlen) +{ + const struct __ip6_tnl_parm *p = &t->parms; + struct net_device *dev = t->dev; if (p->flags & IP6_TNL_F_CAP_XMIT) { int strict = (ipv6_addr_type(&p->raddr) & @@ -1088,6 +1088,24 @@ static void ip6gre_tnl_link_config(struc } } +static int ip6gre_calc_hlen(struct ip6_tnl *tunnel) +{ + int t_hlen; + + tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); + tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; + + t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); + tunnel->dev->hard_header_len = LL_MAX_HEADER + t_hlen; + return t_hlen; +} + +static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) +{ + ip6gre_tnl_link_config_common(t); + ip6gre_tnl_link_config_route(t, set_mtu, ip6gre_calc_hlen(t)); +} + static int ip6gre_tnl_change(struct ip6_tnl *t, const struct __ip6_tnl_parm *p, int set_mtu) { @@ -1381,11 +1399,7 @@ static int ip6gre_tunnel_init_common(str return ret; } - tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); - tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; - t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); - - dev->hard_header_len = LL_MAX_HEADER + t_hlen; + t_hlen = ip6gre_calc_hlen(tunnel); dev->mtu = ETH_DATA_LEN - t_hlen; if (dev->type == ARPHRD_ETHER) dev->mtu -= ETH_HLEN;