Commit 6dd3c9ec authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

ip_tunnel: return more precise errno value when adding tunnel fails

Currently this always returns ENOBUFS, because the return value of
__ip_tunnel_create is discarded.

A more common failure is a duplicate name (EEXIST).  Propagate the real
error code so userspace can display a more meaningful error message.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent df9d9fdf
...@@ -443,7 +443,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net, ...@@ -443,7 +443,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
fbt = netdev_priv(itn->fb_tunnel_dev); fbt = netdev_priv(itn->fb_tunnel_dev);
dev = __ip_tunnel_create(net, itn->fb_tunnel_dev->rtnl_link_ops, parms); dev = __ip_tunnel_create(net, itn->fb_tunnel_dev->rtnl_link_ops, parms);
if (IS_ERR(dev)) if (IS_ERR(dev))
return NULL; return ERR_CAST(dev);
dev->mtu = ip_tunnel_bind_dev(dev); dev->mtu = ip_tunnel_bind_dev(dev);
...@@ -796,9 +796,13 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) ...@@ -796,9 +796,13 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd)
t = ip_tunnel_find(itn, p, itn->fb_tunnel_dev->type); t = ip_tunnel_find(itn, p, itn->fb_tunnel_dev->type);
if (!t && (cmd == SIOCADDTUNNEL)) if (!t && (cmd == SIOCADDTUNNEL)) {
t = ip_tunnel_create(net, itn, p); t = ip_tunnel_create(net, itn, p);
if (IS_ERR(t)) {
err = PTR_ERR(t);
break;
}
}
if (dev != itn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) { if (dev != itn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) {
if (t != NULL) { if (t != NULL) {
if (t->dev != dev) { if (t->dev != dev) {
...@@ -825,8 +829,9 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd) ...@@ -825,8 +829,9 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd)
if (t) { if (t) {
err = 0; err = 0;
ip_tunnel_update(itn, t, dev, p, true); ip_tunnel_update(itn, t, dev, p, true);
} else } else {
err = (cmd == SIOCADDTUNNEL ? -ENOBUFS : -ENOENT); err = -ENOENT;
}
break; break;
case SIOCDELTUNNEL: case SIOCDELTUNNEL:
......
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