* [PATCH -next] gre: return more precise errno value when adding tunnel fails
@ 2014-02-12 9:28 Florian Westphal
2014-02-12 22:33 ` Ben Hutchings
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2014-02-12 9:28 UTC (permalink / raw)
To: netdev; +Cc: Florian Westphal
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: Florian Westphal <fw@strlen.de>
---
net/ipv4/ip_tunnel.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 90ff957..ef43356 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -393,7 +393,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
fbt = netdev_priv(itn->fb_tunnel_dev);
dev = __ip_tunnel_create(net, itn->fb_tunnel_dev->rtnl_link_ops, parms);
if (IS_ERR(dev))
- return NULL;
+ return (void *) dev;
dev->mtu = ip_tunnel_bind_dev(dev);
@@ -732,9 +732,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);
- if (!t && (cmd == SIOCADDTUNNEL))
+ if (!t && (cmd == SIOCADDTUNNEL)) {
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 (t != NULL) {
if (t->dev != dev) {
@@ -761,8 +765,9 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd)
if (t) {
err = 0;
ip_tunnel_update(itn, t, dev, p, true);
- } else
- err = (cmd == SIOCADDTUNNEL ? -ENOBUFS : -ENOENT);
+ } else {
+ err = -ENOENT;
+ }
break;
case SIOCDELTUNNEL:
--
1.8.1.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] gre: return more precise errno value when adding tunnel fails
2014-02-12 9:28 [PATCH -next] gre: return more precise errno value when adding tunnel fails Florian Westphal
@ 2014-02-12 22:33 ` Ben Hutchings
0 siblings, 0 replies; 2+ messages in thread
From: Ben Hutchings @ 2014-02-12 22:33 UTC (permalink / raw)
To: Florian Westphal; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]
On Wed, 2014-02-12 at 10:28 +0100, Florian Westphal wrote:
> 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: Florian Westphal <fw@strlen.de>
> ---
> net/ipv4/ip_tunnel.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
> index 90ff957..ef43356 100644
> --- a/net/ipv4/ip_tunnel.c
> +++ b/net/ipv4/ip_tunnel.c
> @@ -393,7 +393,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
> fbt = netdev_priv(itn->fb_tunnel_dev);
> dev = __ip_tunnel_create(net, itn->fb_tunnel_dev->rtnl_link_ops, parms);
> if (IS_ERR(dev))
> - return NULL;
> + return (void *) dev;
[...]
This should be written as ERR_CAST(dev).
Ben.
--
Ben Hutchings
If more than one person is responsible for a bug, no one is at fault.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-12 22:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-12 9:28 [PATCH -next] gre: return more precise errno value when adding tunnel fails Florian Westphal
2014-02-12 22:33 ` Ben Hutchings
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).