From: Andreas Henriksson <andreas@fatal.se>
To: netdev@vger.kernel.org
Subject: [PATCH RFC] net: error on trying to add a duplicate ipip tunnel
Date: Wed, 13 Nov 2013 19:21:33 +0100 [thread overview]
Message-ID: <20131113182133.GA8760@amd64.fatal.se> (raw)
After patch:
$ sudo ip tunnel add test1 mode ipip remote 1.2.3.4
$ sudo ip tunnel add test2 mode ipip remote 1.2.3.4
add tunnel "tunl0" failed: File exists
Before the patch, there would be no error and
"test2" (silently) not added.
Originally reported at http://bugs.debian.org/508450
The originally reported problem with sit tunnel seems
to have been resolved since then:
$ sudo ip tun add test3 mode sit
add tunnel "sit0" failed: No buffer space available
The problem still exists for (atleast) ipip tunnels though.
Reported-by: martin f krafft <madduck@debian.org>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
net/ipv4/ip_tunnel.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Maybe also sit tunnels should explicitly
use EEXISTS instead of ENOBUFS?
Maybe ipip tunnel code should be refactored
to be similar to sit tunnel addition code?
Which other tunnel types should be checked
for how they behave in similar situations?
Other comments?
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 63a6d6d..1dc4e41 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -732,8 +732,14 @@ 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))
- t = ip_tunnel_create(net, itn, p);
+ if (cmd == SIOCADDTUNNEL) {
+ if (!t) {
+ t = ip_tunnel_create(net, itn, p);
+ } else {
+ err = -EEXIST;
+ break;
+ }
+ }
if (dev != itn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) {
if (t != NULL) {
--
1.8.4.3
reply other threads:[~2013-11-13 18:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20131113182133.GA8760@amd64.fatal.se \
--to=andreas@fatal.se \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox