Skip to content

Commit d61746b

Browse files
klassertdavem330
authored andcommitted
ip_tunnel: Don't allow to add the same tunnel multiple times.
When we try to add an already existing tunnel, we don't return an error. Instead we continue and call ip_tunnel_update(). This means that we can change existing tunnels by adding the same tunnel multiple times. It is even possible to change the tunnel endpoints of the fallback device. We fix this by returning an error if we try to add an existing tunnel. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b94d525 commit d61746b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎net/ipv4/ip_tunnel.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,9 +764,14 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd)
764764

765765
t = ip_tunnel_find(itn, p, itn->fb_tunnel_dev->type);
766766

767-
if (!t && (cmd == SIOCADDTUNNEL)) {
768-
t = ip_tunnel_create(net, itn, p);
769-
err = PTR_ERR_OR_ZERO(t);
767+
if (cmd == SIOCADDTUNNEL) {
768+
if (!t) {
769+
t = ip_tunnel_create(net, itn, p);
770+
err = PTR_ERR_OR_ZERO(t);
771+
break;
772+
}
773+
774+
err = -EEXIST;
770775
break;
771776
}
772777
if (dev != itn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) {

0 commit comments

Comments
 (0)