All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	me@pierre-cheynier.net,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: Re: [PATCH net] ip6_tunnel: fix error code when tunnel exists
Date: Fri, 13 Mar 2015 06:43:47 -0700	[thread overview]
Message-ID: <1426254227.11398.183.camel@edumazet-glaptop2.roam.corp.google.com> (raw)
In-Reply-To: <1426251537-31870-1-git-send-email-nicolas.dichtel@6wind.com>

On Fri, 2015-03-13 at 13:58 +0100, Nicolas Dichtel wrote:
> After commit 2b0bb01b6edb, the kernel returns -ENOBUFS when user tries to add
> an existing tunnel with ioctl API:
> $ ip -6 tunnel add ip6tnl1 mode ip6ip6 dev eth1
> add tunnel "ip6tnl0" failed: No buffer space available
> 
> It's confusing, the right error is EEXIST.
> 
> Fixes: 2b0bb01b6edb ("ip6_tunnel: Return an error when adding an existing tunnel.")
> CC: Steffen Klassert <steffen.klassert@secunet.com>
> Reported-by: Pierre Cheynier <me@pierre-cheynier.net>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
>  net/ipv6/ip6_tunnel.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index 266a264ec212..7ba5608d64c5 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -380,7 +380,7 @@ static struct ip6_tnl *ip6_tnl_locate(struct net *net,
>  		if (ipv6_addr_equal(local, &t->parms.laddr) &&
>  		    ipv6_addr_equal(remote, &t->parms.raddr)) {
>  			if (create)
> -				return NULL;
> +				return ERR_PTR(-EEXIST);
>  
>  			return t;
>  		}
> @@ -1420,7 +1420,7 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
>  			}
>  			ip6_tnl_parm_from_user(&p1, &p);
>  			t = ip6_tnl_locate(net, &p1, 0);
> -			if (t == NULL)
> +			if (IS_ERR_OR_NULL(t))

These IS_ERR_OR_NULL(t) looks like defensive/lazy programming to me.

A NULL pointer should not be allowed here.

If t is not valid, it should be a plain error code mapping.

I wish we get rid of all IS_ERR_OR_NULL() uses in networking tree,
instead of adding plenty of them.

  reply	other threads:[~2015-03-13 13:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 12:58 [PATCH net] ip6_tunnel: fix error code when tunnel exists Nicolas Dichtel
2015-03-13 13:43 ` Eric Dumazet [this message]
2015-03-13 14:46   ` Nicolas Dichtel
2015-03-13 16:32   ` David Miller
2015-03-16 14:56     ` [PATCH net v2] " Nicolas Dichtel
2015-03-16 20:34       ` David Miller
2015-03-17  8:27         ` Nicolas Dichtel
2015-03-17 19:02           ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426254227.11398.183.camel@edumazet-glaptop2.roam.corp.google.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=me@pierre-cheynier.net \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.