From 11c3dcc622990b3b9b8e4d1e04c3a50c78411cdc Mon Sep 17 00:00:00 2001 From: Michael Richardson Date: Fri, 9 May 2014 14:25:59 -0400 Subject: [PATCH] tunslip6: added some better clarification of errors when TUNSETIFF fails --- tools/tunslip6.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/tunslip6.c b/tools/tunslip6.c index e2413cb88..4f3ff7e3e 100644 --- a/tools/tunslip6.c +++ b/tools/tunslip6.c @@ -520,6 +520,7 @@ tun_alloc(char *dev, int tap) int fd, err; if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) { + perror("can not open /dev/net/tun"); return -1; } @@ -536,8 +537,12 @@ tun_alloc(char *dev, int tap) if((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) { close(fd); + fprintf(stderr, "can not tunsetiff to %s (flags=%08x): %s\n", dev, ifr.ifr_flags, + strerror(errno)); return err; } + + /* get resulting tunnel name */ strcpy(dev, ifr.ifr_name); return fd; } @@ -932,7 +937,7 @@ exit(1); if(inslip == NULL) err(1, "main: fdopen"); tunfd = tun_alloc(tundev, tap); - if(tunfd == -1) err(1, "main: open"); + if(tunfd == -1) err(1, "main: open /dev/tun"); if (timestamp) stamptime(); fprintf(stderr, "opened %s device ``/dev/%s''\n", tap ? "tap" : "tun", tundev);