Commit a0efab67 authored by Xin Long's avatar Xin Long Committed by David S. Miller

ip_gre: add the support for i/o_flags update via ioctl

As patch 'ip_gre: add the support for i/o_flags update via netlink'
did for netlink, we also need to do the same job for these update
via ioctl.

This patch is to update i/o_flags and call ipgre_link_update to
recalculate these gre properties after ip_tunnel_ioctl does the
common update.
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Acked-by: default avatarWilliam Tu <u9012063@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dd9d598c
...@@ -800,17 +800,19 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu) ...@@ -800,17 +800,19 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu)
static int ipgre_tunnel_ioctl(struct net_device *dev, static int ipgre_tunnel_ioctl(struct net_device *dev,
struct ifreq *ifr, int cmd) struct ifreq *ifr, int cmd)
{ {
int err;
struct ip_tunnel_parm p; struct ip_tunnel_parm p;
int err;
if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
return -EFAULT; return -EFAULT;
if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) { if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE || if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE ||
p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)) || p.iph.ihl != 5 || (p.iph.frag_off & htons(~IP_DF)) ||
((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING))) ((p.i_flags | p.o_flags) & (GRE_VERSION | GRE_ROUTING)))
return -EINVAL; return -EINVAL;
} }
p.i_flags = gre_flags_to_tnl_flags(p.i_flags); p.i_flags = gre_flags_to_tnl_flags(p.i_flags);
p.o_flags = gre_flags_to_tnl_flags(p.o_flags); p.o_flags = gre_flags_to_tnl_flags(p.o_flags);
...@@ -818,11 +820,22 @@ static int ipgre_tunnel_ioctl(struct net_device *dev, ...@@ -818,11 +820,22 @@ static int ipgre_tunnel_ioctl(struct net_device *dev,
if (err) if (err)
return err; return err;
if (cmd == SIOCCHGTUNNEL) {
struct ip_tunnel *t = netdev_priv(dev);
t->parms.i_flags = p.i_flags;
t->parms.o_flags = p.o_flags;
if (strcmp(dev->rtnl_link_ops->kind, "erspan"))
ipgre_link_update(dev, true);
}
p.i_flags = gre_tnl_flags_to_gre_flags(p.i_flags); p.i_flags = gre_tnl_flags_to_gre_flags(p.i_flags);
p.o_flags = gre_tnl_flags_to_gre_flags(p.o_flags); p.o_flags = gre_tnl_flags_to_gre_flags(p.o_flags);
if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p))) if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment