Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1950251imm; Thu, 24 May 2018 03:28:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrIMwC7qVgtIfTIgB0D80kXFKerwHULvwolJEN1bF8e8kHfT+Pw29XikWt6Obp/TCWhwuep X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr6589888plb.99.1527157728674; Thu, 24 May 2018 03:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157728; cv=none; d=google.com; s=arc-20160816; b=eleF6eWAk5SnWKxYFKWaSyRDH3wHZgCc/ZLhs9Wgq5iGqlbWrl7KpEdF+IuRR5jFPY 433iQ7XGwe5s2M45LDxLuZ7v365zoXV1AN+cNB+ZmHi8WUODMdpzUcSBwehpGesmH+uI 5wNGA09Imco00ALz7Q79dKHsABQOnvwK1GQgTEhX+2IHc7i3D0ccYiw7cfNPPI/9bRJz LF1RY/rwpEQ4X1+7DFzXjUtLjJ/Lg0G+c7Mz+eb8+7nz3nugXaT6lkANAcWW2hwCkUax yODh0AG7P2tZrgCvogSoUG7bCJCjwMzQOjXEPAmP7dBSD6gYRYNM1sdGHFa63jDRx+7a fqmQ== 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=IRmLcBwxOVM0ALVcHjlqsUm66ZRFpjXcWMJ/TYUA4Nw=; b=TNjQtxb/6U8XH/KNlf9rRa1obPZQBrz3HkQ6IIUOf1kSFUGb1NNSsKOzDcSxaSw/wx x5xitP/WmlJIUueW05PpnRxNLmQt+LmpAUerTqv5Qng2JejdkbN79IVGV41JieNnKBh7 Q3VkNqaxptVnBSMrj1dGJCnb898Zbq/MuORBs9hNayOm9i2K6SArERQtKhMXyFEmXap0 9gUsozYJREJsDagw0+TMt+Wboa6qvDDm4gAqoSICK5bPy3Wkb3MMqVkUesOgUYp4dhQU 4Y2FQt7JmpozQ/fa1p4+v/J5hd4dpFok50/Y4l04gMKrBW31heSvzliIsH7vsSWkyIKR UHWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=spyNbNuy; 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 m3-v6si20855633plt.71.2018.05.24.03.28.34; Thu, 24 May 2018 03:28:48 -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=spyNbNuy; 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 S1031974AbeEXK1z (ORCPT + 99 others); Thu, 24 May 2018 06:27:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:47472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030731AbeEXKBh (ORCPT ); Thu, 24 May 2018 06:01:37 -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 DDBC020870; Thu, 24 May 2018 10:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156096; bh=8u+zFnfpaUk29/xHMIv0dVVOyqlVzi17Zu6p8kxf528=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spyNbNuyPZe/Ln0OOmf8zWNRGNpXpZJmKvyXwmD6BHSN9TYxYQvk9h62a+3dvmzCL CpjU+bNFODBnPficFjJ49QV6ozUWhV7m5yDSR0WoZ6SVV6hek1s8iPst24EFxN0cPq lGkVm9Rf+MMTE8MvQ2cMcExt56DLXr6sYGJMlqpA= 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 027/161] net: ip6_gre: Split up ip6gre_changelink() Date: Thu, 24 May 2018 11:37:32 +0200 Message-Id: <20180524093021.579807394@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 c8632fc30bb03aa0c3bd7bcce85355a10feb8149 ] Extract from ip6gre_changelink() a reusable function ip6gre_changelink_common(). This will allow introduction of ERSPAN-specific _changelink() function with not a lot of code duplication. 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 | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -1911,37 +1911,52 @@ static int ip6gre_newlink(struct net *sr return err; } -static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], - struct nlattr *data[], - struct netlink_ext_ack *extack) +static struct ip6_tnl * +ip6gre_changelink_common(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[], struct __ip6_tnl_parm *p_p, + struct netlink_ext_ack *extack) { struct ip6_tnl *t, *nt = netdev_priv(dev); struct net *net = nt->net; struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); - struct __ip6_tnl_parm p; struct ip_tunnel_encap ipencap; if (dev == ign->fb_tunnel_dev) - return -EINVAL; + return ERR_PTR(-EINVAL); if (ip6gre_netlink_encap_parms(data, &ipencap)) { int err = ip6_tnl_encap_setup(nt, &ipencap); if (err < 0) - return err; + return ERR_PTR(err); } - ip6gre_netlink_parms(data, &p); + ip6gre_netlink_parms(data, p_p); - t = ip6gre_tunnel_locate(net, &p, 0); + t = ip6gre_tunnel_locate(net, p_p, 0); if (t) { if (t->dev != dev) - return -EEXIST; + return ERR_PTR(-EEXIST); } else { t = nt; } + return t; +} + +static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], + struct nlattr *data[], + struct netlink_ext_ack *extack) +{ + struct ip6gre_net *ign = net_generic(dev_net(dev), ip6gre_net_id); + struct __ip6_tnl_parm p; + struct ip6_tnl *t; + + t = ip6gre_changelink_common(dev, tb, data, &p, extack); + if (IS_ERR(t)) + return PTR_ERR(t); + ip6gre_tunnel_unlink(ign, t); ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]); ip6gre_tunnel_link(ign, t);