[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALDO+Sb2bQNgJagwAHY7s1_W5Wq1GWRpPq55UD-sF8bfFAXr3w@mail.gmail.com>
Date: Thu, 17 May 2018 12:48:25 -0700
From: William Tu <u9012063@...il.com>
To: Petr Machata <petrm@...lanox.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
David Miller <davem@...emloft.net>,
Alexey Kuznetsov <kuznet@....inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
Dmitry Kozlov <xeb@...l.ru>
Subject: Re: [PATCH net 5/7] net: ip6_gre: Split up ip6gre_newlink()
On Thu, May 17, 2018 at 7:36 AM, Petr Machata <petrm@...lanox.com> wrote:
> Extract from ip6gre_newlink() a reusable function
> ip6gre_newlink_common(). The ip6gre_tnl_link_config() call needs to be
> made customizable for ERSPAN, thus reorder it with calls to
> ip6_tnl_change_mtu() and dev_hold(), and extract the whole tail to the
> caller, ip6gre_newlink(). Thus enable an ERSPAN-specific _newlink()
> function without a lot of duplicity.
>
> Signed-off-by: Petr Machata <petrm@...lanox.com>
> ---
LGTM.
Acked-by: William Tu <u9012063@...il.com>
> net/ipv6/ip6_gre.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 307ac6d..4dfa21d 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -1858,9 +1858,9 @@ static bool ip6gre_netlink_encap_parms(struct nlattr *data[],
> return ret;
> }
>
> -static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
> - struct nlattr *tb[], struct nlattr *data[],
> - struct netlink_ext_ack *extack)
> +static int ip6gre_newlink_common(struct net *src_net, struct net_device *dev,
> + struct nlattr *tb[], struct nlattr *data[],
> + struct netlink_ext_ack *extack)
> {
> struct ip6_tnl *nt;
> struct net *net = dev_net(dev);
> @@ -1897,18 +1897,30 @@ static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
> if (err)
> goto out;
>
> - ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]);
> -
> if (tb[IFLA_MTU])
> ip6_tnl_change_mtu(dev, nla_get_u32(tb[IFLA_MTU]));
>
> dev_hold(dev);
> - ip6gre_tunnel_link(ign, nt);
>
> out:
> return err;
> }
>
> +static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
> + struct nlattr *tb[], struct nlattr *data[],
> + struct netlink_ext_ack *extack)
> +{
> + int err = ip6gre_newlink_common(src_net, dev, tb, data, extack);
> + struct ip6_tnl *nt = netdev_priv(dev);
> + struct net *net = dev_net(dev);
> +
> + if (!err) {
> + ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]);
> + ip6gre_tunnel_link(net_generic(net, ip6gre_net_id), nt);
> + }
> + return err;
> +}
> +
> static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
> struct nlattr *data[],
> struct netlink_ext_ack *extack)
> --
> 2.4.11
>
Powered by blists - more mailing lists