The following commit has been merged in the master branch: commit cb2b331ccb1fb7a992c9d0509c6d9aa57ddd8498 Author: Stefan Sperling stsp@stsp.in-berlin.de Date: Thu Oct 12 01:14:10 2006 +0200
Initialise tuninfo properly. Fix setting the MTU.
diff --git a/bsd.c b/bsd.c index 5e4404a..bd86d62 100644 --- a/bsd.c +++ b/bsd.c @@ -260,12 +260,19 @@ int add_dev_tun(struct batman_if *batman_if, unsigned int tun_addr, char *tun_de /* set up tunnel device */ memset(&ifr_tun, 0, sizeof(ifr_tun)); memset(&ifr_if, 0, sizeof(ifr_if)); + memset(&ti, 0, sizeof(ti));
if ((*fd = open_tun_any()) < 0) { perror("Could not open tun device"); return -1; }
+ if (ioctl(*fd, TUNGIFINFO, &ti) < 0) { + perror("TUNGIFINFO"); + del_dev_tun(*fd); + return -1; + } + /* set ip of this end point of tunnel */ memset(&addr, 0, sizeof(addr)); addr.sin_addr.s_addr = tun_addr; @@ -306,8 +313,8 @@ int add_dev_tun(struct batman_if *batman_if, unsigned int tun_addr, char *tun_de fprintf(stderr, "Warning: MTU smaller than 100 - cannot reduce MTU anymore\n" ); } else { ti.mtu = ifr_if.ifr_mtu - 28; - if (ioctl(*fd, TUNSIFMODE, &ti) < 0) { - perror("TUNSIFMODE"); + if (ioctl(*fd, TUNSIFINFO, &ti) < 0) { + perror("TUNSIFINFO"); del_dev_tun(*fd); return -1; }