Re: ip tunnel doesn't show warning or error

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2005-10-31 at 08:59 +0100, Radek Vokál wrote:
> This is really strange behavior .. 
> 
> root@garfield ~# ip tunnel add testing123 mode ipip remote 192.168.1.1
> local 192.168.1.12
> root@garfield ~# ip tunnel show
> ..
> testing123: ip/ip  remote 192.168.1.1  local 192.168.1.12  ttl inherit
> root@garfield ~# ip tunnel add testingabc mode ipip remote 192.168.1.1
> local 192.168.1.12
> root@garfield ~# echo $?
> 0
> root@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@xxxxxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux