Skip to content

Commit

Permalink
datapath: ip6_gre: Split up ip6gre_changelink()
Browse files Browse the repository at this point in the history
commit c8632fc30bb03aa0c3bd7bcce85355a10feb8149
Author: Petr Machata <petrm@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@mellanox.com>
    Acked-by: William Tu <u9012063@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>
  • Loading branch information
williamtu authored and blp committed May 29, 2018
1 parent 19fd516 commit 2f625b3
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions datapath/linux/compat/ip6_gre.c
Expand Up @@ -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);
Expand Down

0 comments on commit 2f625b3

Please sign in to comment.