Comment 1 for bug 69838

Revision history for this message
Israel G. Lugo (ilugo) wrote :

I took a quick look at the program's source code, and they are doing a lot of definitions of system constants by themselves. For example, in socket.h line 79, they have:

#define SOCK_STREAM 0

This file is included from netuser.h:38, which is included from tcp.h:26, which is included from iface.h:21, which is included from tun.c:25. They also define struct sockaddr in their headers (in file sockaddr.h).

All of this happens before they include <linux/if.h> in (tun.c:40). As can be seen in your report, <linux/if.h> is including <sys/socket.h>, which will try to define the relevant data types and constants, and fail because they're already defined.

I was unable to reproduce the problem on Ubuntu Edgy, using libc6-dev 2.4-1ubuntu12.3 and linux-libc-dev 2.6.17.1-10.34. I downloaded the tar.gz from the URL you specified, and was able to successfully compile tun.c:

~/jnos2$ gcc --version
gcc (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~/jnos2$ gcc -DUNIX -g3 -DDEVELOPMENT -DDEBUG -W -Wimplicit -Wreturn-type -Wswitch -Wpointer-arith -Wcast-qual -Wcast-align -Waggregate-return -Wparentheses -I/usr/include/ncurses -DLCURSES=\"-lncurses\" -c -o tun.o tun.c
~/jnos2$ ls tun.o
tun.o
~/jnos2$

Looking at my /usr/include/linux/if.h file, it does not include <sys/socket.h>. In fact, it includes <linux/socket.h>, which does practically nothing because almost all the inclusions and definitions are inside the following #if block:

#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)

None of those conditions are true when building the program, so the #if is never entered, so <linux/socket.h> does nothing (so there are no problems with redefining what JNOS already defined).

Your file /usr/include/linux/if.h seems to differ from mine. Which version of linux-libc-dev do you have? (that is the package which owns the headers from the Linux kernel, including the files located inside /usr/include/linux).

I would recommend you file this bug to the creators of the program. This seems to be a problem with their code; they probably did not test it against the particular version of linux headers you are using, and/or glibc.