Skip to contentSkip to conversation

build failure on OpenBSD

Openvpn-devel Gert Doering 2 participants 4 messages Mar 26, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

we currently fail on OpenBSD (4.9) with this error message:

if gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../../include -I../../src/compat -I/usr/include -I/usr/include -g -O2 -MT tun.o -MD -MP -MF ".deps/tun.Tpo" -c -o tun.o tun.c; then mv -f ".deps/tun.Tpo" ".deps/tun.Po"; else rm -f ".deps/tun.Tpo"; exit 1; fi
tun.c: In function 'write_tun':
tun.c:2070: error: dereferencing pointer to incomplete type *** Error code 1

which looks like

------------------------------------------

      struct ip *iph;

      iph = (struct ip *) buf;

      if (tt->ipv6 && iph->ip_v == 6)   <<< here

------------------------------------------

"struct ip" is defined in <netinet/ip.h>, which "syshead.h" includes in weird ways - "syshead.h" has 5 different

#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif

stanzas, always inside #ifdef TARGET_SOMETHING blocks. It does have such a block for TARGET_OPENBSD, but configure doesn't find it:

checking for net/if.h... yes
checking for netinet/ip.h... no
checking for netinet/if_ether.h... no

The relevant section from config.log is here:

---------------------------- snip --------------------------------- configure:21681: checking for netinet/ip.h
configure:21681: gcc -c -g -O2 conftest.c >&5
In file included from conftest.c:170:
/usr//include/netinet/ip.h:178: error: expected specifier-qualifier-list before 'n_time'
configure:21681: $? = 1
configure: failed program was:
---------------------------- snip ---------------------------------

which is defined in <netinet/in_systm.h> - which syshead.h already includes.

the full config log can be found on
http://public.greenie.net/gert/openvpn/config-obsd49-20120326.log

I'd promise instead of trying to fix configure here, and since these are inside well-understood #ifdef TARGET_<foo> things already, just assume that "if it's *BSD, it will always have <netinet/ip.h>" and don't bother running fragile tests from configure.

So that would turn syshead.h

#ifdef TARGET_OPENBSD

#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif

#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif

#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif

#ifdef HAVE_NET_IF_TUN_H
#include <net/if_tun.h>
#endif

#endif /* TARGET_OPENBSD */

into

#ifdef TARGET_OPENBSD

#include <sys/uio.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <net/if_tun.h>

#endif /* TARGET_OPENBSD */

... which is to the point, and works.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#1 lore raw
Quoted 88 lines · Gert Doering

Hi,

we currently fail on OpenBSD (4.9) with this error message:

if gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../../include  -I../../src/compat      -I/usr/include -I/usr/include     -g -O2 -MT tun.o -MD -MP -MF ".deps/tun.Tpo" -c -o tun.o tun.c;  then mv -f ".deps/tun.Tpo" ".deps/tun.Po"; else rm -f ".deps/tun.Tpo"; exit 1; fi tun.c: In function 'write_tun':
tun.c:2070: error: dereferencing pointer to incomplete type
*** Error code 1

which looks like

------------------------------------------
     struct ip *iph;

     iph = (struct ip *) buf;

     if (tt->ipv6 && iph->ip_v == 6)   <<< here
------------------------------------------

"struct ip" is defined in <netinet/ip.h>, which "syshead.h" includes in weird ways - "syshead.h" has 5 different

#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif

stanzas, always inside #ifdef TARGET_SOMETHING blocks.  It does have such a block for TARGET_OPENBSD, but configure doesn't find it:

checking for net/if.h... yes
checking for netinet/ip.h... no
checking for netinet/if_ether.h... no

The relevant section from config.log is here:

---------------------------- snip --------------------------------- configure:21681: checking for netinet/ip.h
configure:21681: gcc -c -g -O2  conftest.c >&5
In file included from conftest.c:170:
/usr//include/netinet/ip.h:178: error: expected specifier-qualifier-list before 'n_time'
configure:21681: $? = 1
configure: failed program was:
---------------------------- snip ---------------------------------

which is defined in <netinet/in_systm.h> - which syshead.h already includes.

the full config log can be found on
 http://public.greenie.net/gert/openvpn/config-obsd49-20120326.log

I'd promise instead of trying to fix configure here, and since these are inside well-understood #ifdef TARGET_<foo> things already, just assume that "if it's *BSD, it will always have <netinet/ip.h>" and don't bother running fragile tests from configure.

So that would turn syshead.h

#ifdef TARGET_OPENBSD

#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif

#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif

#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif

#ifdef HAVE_NET_IF_TUN_H
#include <net/if_tun.h>
#endif

#endif /* TARGET_OPENBSD */

into

#ifdef TARGET_OPENBSD

#include <sys/uio.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <net/if_tun.h>

Quoted 5 lines

#endif /* TARGET_OPENBSD */

... which is to the point, and works.

gert

Thanks!

The problem is the use of the TARGET_XXXX not the use of HAVE.
As I wrote before next stage is to get rid of the syshead.h and its complexity. There is no sense to check for platform, just if header exists.

In the mean time please try the following[1] patch.

Alon

[1] https://github.com/alonbl/openvpn/commit/b0f45ae19909b33723faebe7f8fb003f82900ff4

#2 lore raw

Hi,

Quoted 3 lines · Alon Bar-Lev

The problem is the use of the TARGET_XXXX not the use of HAVE.
As I wrote before next stage is to get rid of the syshead.h and its complexity. There is no sense to check for platform, just if header exists.

Check for header is too fragile, obviously - it checks for header, but fails, because header needs other headers.

We need the TARGET_XXX stuff anyway, because tun.c and route.c need them - stuff like "how is the /bin/route syntax for IPv6 on xxxBSD" can not be detected by configure.

So I'm much more in favour of actually keeping what we have: knowledge about every platform. We *know* which headers are there on FreeBSD, NetBSD, OpenBSD - and the way OpenVPN needs to tie into the system for ifconfig and route means "porting to a yet-unknown operating system by just running 'configure ; make' is a pipe dream, no more".

This might work for stuff that's sufficiently far away from the system innards, and using pkg-config libraries for the nitty gritty details, but it won't for OpenVPN.

Quoted 5 lines

In the mean time please try the following[1] patch.

Alon

[1] https://github.com/alonbl/openvpn/commit/b0f45ae19909b33723faebe7f8fb003f82900ff4

That patch makes configure detect <netinet/in.h> (as such: thanks, it helps), but it makes configure even more complicated, which means "config.log is even longer and harder to read".

<rant>
All this crap in configure really needs to go away...

checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
...
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
...
checking whether SIGHUP is declared... yes
checking whether SIGINT is declared... yes
checking whether SIGUSR1 is declared... yes
checking whether SIGUSR2 is declared... yes
checking whether SIGTERM is declared... yes
...
checking for socket... yes
checking for recv... yes
checking for recvfrom... yes
checking for send... yes
checking for sendto... yes
checking for listen... yes
checking for accept... yes
checking for connect... yes
checking for bind... yes
checking for select... yes
checking for gethostbyname... yes

... all of these are on any operating that has any chance of running OpenVPN. So testing for it is a pure waste of code lines and cpu cycles.
</rant>

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#3 lore raw
Quoted 9 lines · Gert Doering

Hi,

Quoted 3 lines · Alon Bar-Lev

The problem is the use of the TARGET_XXXX not the use of HAVE.
As I wrote before next stage is to get rid of the syshead.h and its complexity. There is no sense to check for platform, just if header exists.

Check for header is too fragile, obviously - it checks for header, but fails, because header needs other headers.

The opposite is true.
From my experience, checking per platform causes problem with toolchain and versions changes.

Quoted 3 lines

We need the TARGET_XXX stuff anyway, because tun.c and route.c need them - stuff like "how is the /bin/route syntax for IPv6 on xxxBSD" can not be detected by configure.

The symbols should exists, yes.
They should be used in platform specific implementation. Headers can be detected in most cases as without references to platform in much simpler source with less conditionals.

Quoted 5 lines

So I'm much more in favour of actually keeping what we have: knowledge about every platform.  We *know* which headers are there on FreeBSD, NetBSD, OpenBSD - and the way OpenVPN needs to tie into the system for ifconfig and route means "porting to a yet-unknown operating system by just running 'configure ; make' is a pipe dream, no more".

No it is not.

Quoted 3 lines

This might work for stuff that's sufficiently far away from the system innards, and using pkg-config libraries for the nitty gritty details, but it won't for OpenVPN.

It will, with a little patient I will show this.

Quoted 39 lines
Quoted 5 lines

In the mean time please try the following[1] patch.

Alon

[1] https://github.com/alonbl/openvpn/commit/b0f45ae19909b33723faebe7f8fb003f82900ff4

That patch makes configure detect <netinet/in.h> (as such: thanks, it helps), but it makes configure even more complicated, which means "config.log is even longer and harder to read".

<rant>
All this crap in configure really needs to go away...

checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
...
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
...
checking whether SIGHUP is declared... yes
checking whether SIGINT is declared... yes
checking whether SIGUSR1 is declared... yes
checking whether SIGUSR2 is declared... yes
checking whether SIGTERM is declared... yes
...
checking for socket... yes
checking for recv... yes
checking for recvfrom... yes
checking for send... yes
checking for sendto... yes
checking for listen... yes
checking for accept... yes
checking for connect... yes
checking for bind... yes
checking for select... yes
checking for gethostbyname... yes

Quoted 4 lines

... all of these are on any operating that has any chance of running OpenVPN.  So testing for it is a pure waste of code lines and cpu cycles.
</rant>

Incorrect.
The same is used to detect and configure also in Microsoft platform.

Less platform specific conditional, the cleaner the code is.

But... one note... many will be removed when I clean up the ipv6 usage.

Alon.