[ovs-dev] [PATCH 6/8] net: ip6_gre: Split up ip6gre_changelink()
Gregory Rose
gvrose8192 at gmail.com
Tue May 29 20:40:11 UTC 2018
On 5/29/2018 5:55 AM, William Tu wrote:
> commit c8632fc30bb03aa0c3bd7bcce85355a10feb8149
> Author: Petr Machata <petrm at mellanox.com>
> Date: Thu May 17 16:36:45 2018 +0200
>
> net: ip6_gre: Split up ip6gre_changelink()
>
> 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 <petrm at mellanox.com>
> Acked-by: William Tu <u9012063 at gmail.com>
> Signed-off-by: David S. Miller <davem at davemloft.net>
>
> Cc: Greg Rose <gvrose8192 at gmail.com>
> Signed-off-by: William Tu <u9012063 at gmail.com>
> ---
> datapath/linux/compat/ip6_gre.c | 48 +++++++++++++++++++++++++++++++----------
> 1 file changed, 37 insertions(+), 11 deletions(-)
>
> diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c
> index 4cd877bcf32e..7c06d732285c 100644
> --- a/datapath/linux/compat/ip6_gre.c
> +++ b/datapath/linux/compat/ip6_gre.c
> @@ -2170,41 +2170,67 @@ static int rpl_ip6gre_newlink(struct net *src_net, struct net_device *dev,
> #define ip6gre_newlink rpl_ip6gre_newlink
>
> #ifdef HAVE_IP6GRE_EXTACK
> -static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
> - struct nlattr *data[],
> - struct netlink_ext_ack *extack)
> +static struct ip6_tnl *
> +rpl_ip6gre_changelink_common(struct net_device *dev, struct nlattr *tb[],
> + struct nlattr *data[], struct __ip6_tnl_parm *p_p,
> + struct netlink_ext_ack *extack)
> #else
> -static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
> - struct nlattr *data[])
> +static struct ip6_tnl *
> +rpl_ip6gre_changelink_common(struct net_device *dev, struct nlattr *tb[],
> + struct nlattr *data[], struct __ip6_tnl_parm *p_p)
> #endif
> {
> 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;
> +}
> +#define ip6gre_changelink_common rpl_ip6gre_changelink_common
> +
> +#ifdef HAVE_IP6GRE_EXTACK
> +static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
> + struct nlattr *data[],
> + struct netlink_ext_ack *extack)
> +#else
> +static int rpl_ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
> + struct nlattr *data[])
> +#endif
> +{
> + struct ip6gre_net *ign = net_generic(dev_net(dev), ip6gre_net_id);
> + struct __ip6_tnl_parm p;
> + struct ip6_tnl *t;
> +
> +#ifdef HAVE_IP6GRE_EXTACK
> + t = ip6gre_changelink_common(dev, tb, data, &p, extack);
> +#else
> + t = ip6gre_changelink_common(dev, tb, data, &p);
> +#endif
> + 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);
Reviewed-by: Greg Rose <gvrose8192 at gmail.com>
Tested-by: Greg Rose <gvrose8192 at gmail.com>
More information about the dev
mailing list