[LARTC] ip tunnel doesn't show warning or error

Radek Vokál rvokal at redhat.com
Mon Oct 31 11:08:32 CET 2005


On Mon, 2005-10-31 at 08:59 +0100, Radek Vokál wrote:
> This is really strange behavior .. 
> 
> root at garfield ~# ip tunnel add testing123 mode ipip remote 192.168.1.1
> local 192.168.1.12
> root at garfield ~# ip tunnel show
> ..
> testing123: ip/ip  remote 192.168.1.1  local 192.168.1.12  ttl inherit
> root at garfield ~# ip tunnel add testingabc mode ipip remote 192.168.1.1
> local 192.168.1.12
> root at garfield ~# echo $?
> 0
> root at garfield ~# ip tunnel show
> ..
> testing123: ip/ip  remote 192.168.1.1  local 192.168.1.12  ttl inherit
> 
> I guess the second tunnel add should end up with an error, but ioctl
> doesn't report anything on this .. 
> 

Here's small patch to show at least some warning

--- iproute2-051007/ip/iptunnel.c.old	2005-02-10 19:31:18.000000000
+0100
+++ iproute2-051007/ip/iptunnel.c	2005-10-31 11:03:04.000000000 +0100
@@ -130,7 +130,8 @@ static int do_add_ioctl(int cmd, const c
 	struct ifreq ifr;
 	int fd;
 	int err;
-
+	char old_name[IFNAMSIZ];
+	strncpy(old_name,p->name,IFNAMSIZ);
 	if (cmd == SIOCCHGTUNNEL && p->name[0])
 		strncpy(ifr.ifr_name, p->name, IFNAMSIZ);
 	else
@@ -138,6 +139,10 @@ static int do_add_ioctl(int cmd, const c
 	ifr.ifr_ifru.ifru_data = (void*)p;
 	fd = socket(AF_INET, SOCK_DGRAM, 0);
 	err = ioctl(fd, cmd, &ifr);
+	if (strncmp(ifr.ifr_data,old_name,IFNAMSIZ)) {
+	    fprintf(stderr,"Warning: Tunnel already exists (%
s)\n",ifr.ifr_data);
+	}
 	if (err)
 		perror("ioctl");
 	close(fd);


-- 
Radek Vokál <rvokal at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mailman.ds9a.nl/pipermail/lartc/attachments/20051031/e7d5ed8d/attachment.pgp


More information about the LARTC mailing list