Skip to contentSkip to conversation

Pre-1.3.3 beta available for testing

Openvpn-devel James Yonan 2 participants 15 messages Feb 16, 2003 – Feb 20, 2003 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello OpenVPN Users & Developers,

I thought it would be a good time to wrap up the minor fixes that have gone into the codebase over the last couple months.

So here's a beta which I would encourage you to test as much as possible. While the changes are mostly minor, some of the fixes such as --tun-mtu-extra resulted in major changes to the MTU sizing algorithm. As well, I have only built for RH Linux in my testing, so please test on other OSes, distros, processor architectures, etc.

Beta is available on CVS as well as here:

http://openvpn.sourceforge.net/beta/openvpn-1.3.2.9.tar.gz

Change Log:

2003.02.16 -- Version 1.3.2.9

* Added --replay-persist feature to allow replay protection across sessions.
* Fixed bug where --ifconfig could not be used with --tun-mtu.
* Added --tun-mtu-extra parameter to deal with the situation where a read on a TUN/TAP device returns more data than the device's MTU size.
* Fixed bug where some IPv6 support code for Linux was not being properly ifdefed out for Linux 2.2, causing compile errors.
* Added OPENVPN_EXIT_STATUS_x codes to openvpn.h to control which status value openvpn returns to its caller (such as
a shell or inetd/xinetd) for various conditions.
* Added OPENVPN_DEBUG_COMMAND_LINE flag to openvpn.h to allow debugging in situations where stdout, stderr, and syslog cannot be used for message output, such as when OpenVPN is instantiated by inetd/xinetd.
* Removed owner-execute permission from file created by static key generator (Herbert Xu and Alberto Gonzalez Iniesta).
* Added --passtos option to allow IPv4 TOS bits to be passed from TUN/TAP input packets to the outgoing UDP socket (Craig Knox).
* Added code to prevent open socket file descriptors from being accessible to called scripts.

James

#1 lore raw
Quoted 3 lines · James Yonan

Beta is available on CVS as well as here:

http://openvpn.sourceforge.net/beta/openvpn-1.3.2.9.tar.gz

I tried the current CVS as of some minutes ago on Linux, Solaris and FreeBSD. This first mail is about Linux, Solaris status is in a separate mail.

This mail has four sections.

1. Here are important complaints of my compiler (SuSE 8.1, gcc 3.2, with lzo):

packet_id.c: In function `packet_id_add':
packet_id.c:67: warning: comparison between signed and unsigned socket.c: In function `getaddr':
socket.c:69: warning: comparison between signed and unsigned tun.c:254: warning: `open_tun_generic' defined but not used

2. SuSE 7.3, gcc 2.95, without lzo installed is a no-go despite --disable-lzo:

source='/home/ma/tmp/openvpn/lzo.c' object='lzo.o' libtool=no \
depfile='.deps/lzo.Po' tmpdepfile='.deps/lzo.TPo' \
depmode=gcc /bin/sh /home/ma/tmp/openvpn/depcomp \
gcc -DHAVE_CONFIG_H -I. -I/home/ma/tmp/openvpn -I. -g -O2 -c test -f '/home/ma/tmp/openvpn/lzo.c' || echo '/home/ma/tmp/openvpn/'/home/ma/tmp/openvpn/lzo.c
In file included from /home/ma/tmp/openvpn/lzo.c:32:
/home/ma/tmp/openvpn/lzo.h:28: lzo1x.h: No such file or directory make[1]: *** [lzo.o] Error 1

I tracked this down to flaws in the Makefile.am that ships a config.h (which breaks VPATH builds). Here's a patch to rectify this and to enable you to "make dist" to get the tarball with all subdirectories included:

Index: openvpn.spec
===================================================================
RCS file: /cvsroot/openvpn/openvpn/openvpn.spec,v
retrieving revision 1.59

openvpn.spec +0 -1
diff -u -r1.59 openvpn.spec
@@ -22,7 +22,6 @@
 %setup -q
 
 %build
-./pre-touch
 %configure --enable-pthread
 %__make
 

Index: Makefile.am
===================================================================
RCS file: /cvsroot/openvpn/openvpn/Makefile.am,v
retrieving revision 1.3

Makefile.am +16 -2
diff -u -r1.3 Makefile.am
@@ -24,9 +24,23 @@
 #
 
 sbin_PROGRAMS = openvpn
-openvpn_SOURCES = basic.h buffer.c buffer.h circ_list.h common.h config.h crypto.c crypto.h errlevel.h error.c error.h fdmisc.c fdmisc.h gremlin.c gremlin.h interval.h lzo.c lzo.h memdbg.h misc.c misc.h mtu.h openvpn.c openvpn.h options.c options.h packet_id.c packet_id.h reliable.c reliable.h session_id.c session_id.h shaper.c shaper.h socket.c socket.h ssl.c ssl.h syshead.h thread.c thread.h tun.c tun.h
+nodist_openvpn_SOURCES = config.h
+openvpn_SOURCES = basic.h buffer.c buffer.h circ_list.h common.h \
+		  crypto.c crypto.h errlevel.h error.c error.h \
+		  fdmisc.c fdmisc.h gremlin.c gremlin.h interval.h \
+		  lzo.c lzo.h memdbg.h misc.c misc.h mtu.h openvpn.c \
+		  openvpn.h options.c options.h packet_id.c \
+		  packet_id.h reliable.c reliable.h session_id.c \
+		  session_id.h shaper.c shaper.h socket.c socket.h \
+		  ssl.c ssl.h syshead.h thread.c thread.h tun.c tun.h
 
 KEY_FILES = dh1024.pem client.crt client.key server.crt server.key tmp-ca.crt tmp-ca.key
 
 man_MANS = openvpn.8
-EXTRA_DIST = $(KEY_FILES)
+EXTRA_DIST = $(KEY_FILES) $(man_MANS) \
+	     COPYRIGHT.GPL PORTS openvpn.spec \
+	     easy-rsa sample-config-files sample-keys \
+	     sample-scripts
+
+dist-hook:
+	cd $(distdir) && for i in $(EXTRA_DIST) ; do find $$i -name CVS -type d -prune -exec rm -r '{}' ';' ; done

3. I also suggest this patch to enhance portability, particularly for older, possibly non-gcc, configurations:

Index: configure.ac
===================================================================
RCS file: /cvsroot/openvpn/openvpn/configure.ac,v
retrieving revision 1.51

configure.ac +3 -0
diff -u -r1.51 configure.ac
@@ -137,8 +137,11 @@
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
+AC_C_VOLATILE
+AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
+AC_TYPE_UID_T
 AC_HEADER_TIME
 
 dnl Check for more header files.

4. don't use autogen.sh, it has been superseded by "autoreconf". Try autoreconf -i -v (be chary about passing -f, it will kill your COPYING and INSTALL files!)

I think you then don't need pre-touch either. In fact, I usually discourage keeping generated files in CVS. They only bloat things and cause unnecessary rebuilds and commits.

Please consider doing:
cvs rm -f Makefile.in aclocal.m4 config.h.in configure cvs rm -f config.guess config.sub depcomp install-sh missing cvs rm -f mkinstalldirs
cvs commit -m "Remove generated files from CVS."

Signature · 1 line
Matthias Andree
#5 lore raw
In reply to James Yonan
Quoted 4 lines · James Yonan

2003.02.16 -- Version 1.3.2.9

* Added --replay-persist feature to allow replay
protection across sessions.

The persist stuff seems to break when --disable-crypto is in effect:
/usr/include/netinet/in.h:69: warning: empty declaration
/home/ma/tmp/openvpn/openvpn.c:175: warning: `struct packet_id_persist' declared inside parameter list /home/ma/tmp/openvpn/openvpn.c:175: warning: its scope is only this definition or declaration, which is probably not what you want. /home/ma/tmp/openvpn/openvpn.c: In function `openvpn':
/home/ma/tmp/openvpn/openvpn.c:346: structure has no member named packet_id_file' /home/ma/tmp/openvpn/openvpn.c:347: structure has no member named packet_id_file' /home/ma/tmp/openvpn/openvpn.c: In function `main':
/home/ma/tmp/openvpn/openvpn.c:1730: storage size of `pid_persist' isn't known

Signature · 1 line
Matthias Andree
#2 lore raw
In reply to Matthias Andree
Quoted 9 lines · Matthias Andree
Quoted 3 lines · James Yonan

Beta is available on CVS as well as here:

http://openvpn.sourceforge.net/beta/openvpn-1.3.2.9.tar.gz

I tried the current CVS as of some minutes ago on Linux, Solaris and FreeBSD. This first mail is about Linux, Solaris status is in a separate mail.

I also found there were some issues with Solaris, patches below.

Note the error message when the Solaris net/if_tun.h include file is missing is pretty unspecific; ultimately, openvpn.c:504 complains about an undefined TUNNEWPPA. This might warrant improvement (maybe an explicit check in configure.ac).

Anyways, there are some bugs in configure.ac that break the VPATH build on Solaris for me, here is the patch, to be applied on top of my previous configure.ac patch.

Note that the stuff cannot be compiled on C89 compilers (SunPro Workshop
6) because of the variadic msg() macros in error.h:79.

I understand it's convenient to use a macro like that, and might be more efficient because the optimizer has something to crunch away (DCE), but it's a compile killer.

Please also note that _* names are reserved name space. Don't use them for your functions if you can avoid it, for portability -- they might screw some linker.

configure.ac +6 -2
diff -u configure.ac configure.ac
@@ -27,6 +27,7 @@
 
 AC_INIT([OpenVPN], [1.3.2.9], [[email protected]], [openvpn])
 AM_CONFIG_HEADER(config.h)
+AC_CONFIG_SRCDIR(syshead.h)
 
 AC_ARG_ENABLE(lzo,
    [  --disable-lzo           Do not compile LZO compression support],
@@ -66,7 +67,7 @@
 
 AC_ARG_WITH(ssl-lib,
    [  --with-ssl-lib=DIR      Crypto/SSL Library location],
-   [LIBS="$LIBS -L$withval"] 
+   [LDFLAGS="$LDFLAGS -L$withval"] 
 )
 
 AC_ARG_WITH(lzo-headers,
@@ -77,7 +78,7 @@
 
 AC_ARG_WITH(lzo-lib,
    [  --with-lzo-lib=DIR      LZO Library location],
-   [LIBS="$LIBS -L$withval"] 
+   [LDFLAGS="$LDFLAGS -L$withval"] 
 )
 
 AC_ARG_WITH(ifconfig-path,
@@ -97,6 +98,9 @@
 AC_CANONICAL_SYSTEM
 AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
 
+dnl fix search path, to allow compilers to find syshead.h
+CPPFLAGS="$CPPFLAGS -I${srcdir}"
+
 dnl check target OS
 openvpn_target=$target
 if test $target_alias; then

I also need these two patches to compile the stuff on SUNpro:

Index: error.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.c,v
retrieving revision 1.10

error.c +4 -1
diff -u -r1.10 error.c
@@ -114,7 +114,7 @@
 int msg_line_num;
 
 void
-_msg (unsigned int flags, const char *format, ...)
+msg (unsigned int flags, const char *format, ...)
 {
   va_list arglist;
   int level;
@@ -124,6 +124,9 @@
   char *m2;
   char *tmp;
   int e;
+
+  if (!(((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)))
+      return;
 
   e = errno;
 

Index: error.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.h,v
retrieving revision 1.8

error.h +1 -5
diff -u -r1.8 error.h
@@ -76,11 +76,7 @@
  */
 #define LOGLEV(log_level, mute_level, other) (((log_level)-1) | ENCODE_MUTE_LEVEL(mute_level) | other)
 
-#define msg(flags, args...) \
-    do { if (((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)) \
-    _msg((flags), args); } while (false)
-
-void _msg (unsigned int flags, const char *format, ...); /* should be called via msg above */
+void msg (unsigned int flags, const char *format, ...);
 
 void error_reset ();
 void set_check_status (int info_level, int verbose_level);

Index: buffer.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/buffer.c,v
retrieving revision 1.7

buffer.c +1 -1
diff -u -r1.7 buffer.c
@@ -160,7 +160,7 @@
   e->back = thread->gc_stack;
   thread->gc_stack = e;
   /*printf("GC MALLOC " ptr_format " size=%d lev=%d\n", e, s, e->level); */
-  return (void *) e + sizeof (struct gc_entry);
+  return (char *) e + sizeof (struct gc_entry);
 }
 
 void

Index: crypto.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/crypto.c,v
retrieving revision 1.11

crypto.c +4 -6
diff -u -r1.11 crypto.c
@@ -77,9 +77,6 @@
 #define CRYPT_ERROR(format) \
   do { msg (D_CRYPT_ERRORS, "%s: " format, error_prefix); goto error_exit; } while (false)
 
-#define CRYPT_ERROR_ARGS(format, args...) \
-  do { msg (D_CRYPT_ERRORS, "%s: " format, error_prefix, args); goto error_exit; } while (false)
-
 void
 openvpn_encrypt (struct buffer *buf, struct buffer work,
 		 const struct crypto_options *opt,
@@ -339,9 +336,10 @@
 	      packet_id_add (&opt->packet_id->rec, &pin);
 	      if (opt->pid_persist && opt->packet_id_long_form)
 		packet_id_persist_save_obj (opt->pid_persist, opt->packet_id);
-	    }
-	  else
-	    CRYPT_ERROR_ARGS ("bad packet ID (may be a replay): %s", packet_id_net_print (&pin));
+	    } else {
+	      msg(D_CRYPT_ERRORS, "%s: bad packet ID (may be a replay): %s", error_prefix, packet_id_net_print(&pin));
+	      goto error_exit;
+	  }
 	}
       *buf = work;
     }
#6 lore raw
In reply to James Yonan

OK,

here is a full patch for your convenience without the "apply on top" junk, with this patch, the current CVS compiles on:

SuSE Linux 7.3 x86 gcc 2.95.3
SuSE Linux 8.1 x86 gcc 3.2
FreeBSD 4-STABLE x86 gcc 2.95.3+FreeBSD
Solaris 8 Sparc gcc 2.95.3
Solaris 8 Sparc SunPro Workshop 6.

The unfixed bug that remains that I am aware of is the --disable-crypto issue I reported earlier today. I don't think many people will use this configure option, but it should be fixed nonetheless, that's what beta versions are good for :-)

Thanks for the continued maintenance of OpenVPN, BTW.

# Makefile.am  |   18 ++++++++++++++++--
# buffer.c     |    2 +-
# configure.ac |   11 +++++++++--
# crypto.c     |   10 ++++------
# error.c      |    5 ++++-
# error.h      |    6 +-----
# openvpn.spec |    1 -

# 7 files changed, 35 insertions(+), 18 deletions(-)

Index: buffer.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/buffer.c,v
retrieving revision 1.7

buffer.c +1 -1
diff -u -r1.7 buffer.c
@@ -160,7 +160,7 @@
   e->back = thread->gc_stack;
   thread->gc_stack = e;
   /*printf("GC MALLOC " ptr_format " size=%d lev=%d\n", e, s, e->level); */
-  return (void *) e + sizeof (struct gc_entry);
+  return (char *) e + sizeof (struct gc_entry);
 }
 
 void

Index: crypto.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/crypto.c,v
retrieving revision 1.11

crypto.c +4 -6
diff -u -r1.11 crypto.c
@@ -77,9 +77,6 @@
 #define CRYPT_ERROR(format) \
   do { msg (D_CRYPT_ERRORS, "%s: " format, error_prefix); goto error_exit; } while (false)
 
-#define CRYPT_ERROR_ARGS(format, args...) \
-  do { msg (D_CRYPT_ERRORS, "%s: " format, error_prefix, args); goto error_exit; } while (false)
-
 void
 openvpn_encrypt (struct buffer *buf, struct buffer work,
 		 const struct crypto_options *opt,
@@ -339,9 +336,10 @@
 	      packet_id_add (&opt->packet_id->rec, &pin);
 	      if (opt->pid_persist && opt->packet_id_long_form)
 		packet_id_persist_save_obj (opt->pid_persist, opt->packet_id);
-	    }
-	  else
-	    CRYPT_ERROR_ARGS ("bad packet ID (may be a replay): %s", packet_id_net_print (&pin));
+	    } else {
+	      msg(D_CRYPT_ERRORS, "%s: bad packet ID (may be a replay): %s", error_prefix, packet_id_net_print(&pin));
+	      goto error_exit;
+	  }
 	}
       *buf = work;
     }

Index: error.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.c,v
retrieving revision 1.10

error.c +4 -1
diff -u -r1.10 error.c
@@ -114,7 +114,7 @@
 int msg_line_num;
 
 void
-_msg (unsigned int flags, const char *format, ...)
+msg (unsigned int flags, const char *format, ...)
 {
   va_list arglist;
   int level;
@@ -124,6 +124,9 @@
   char *m2;
   char *tmp;
   int e;
+
+  if (!(((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)))
+      return;
 
   e = errno;
 

Index: error.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.h,v
retrieving revision 1.8

error.h +1 -5
diff -u -r1.8 error.h
@@ -76,11 +76,7 @@
  */
 #define LOGLEV(log_level, mute_level, other) (((log_level)-1) | ENCODE_MUTE_LEVEL(mute_level) | other)
 
-#define msg(flags, args...) \
-    do { if (((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)) \
-    _msg((flags), args); } while (false)
-
-void _msg (unsigned int flags, const char *format, ...); /* should be called via msg above */
+void msg (unsigned int flags, const char *format, ...);
 
 void error_reset ();
 void set_check_status (int info_level, int verbose_level);

Index: configure.ac
===================================================================
RCS file: /cvsroot/openvpn/openvpn/configure.ac,v
retrieving revision 1.51

configure.ac +9 -2
diff -u -r1.51 configure.ac
@@ -27,6 +27,7 @@
 
 AC_INIT([OpenVPN], [1.3.2.9], [[email protected]], [openvpn])
 AM_CONFIG_HEADER(config.h)
+AC_CONFIG_SRCDIR(syshead.h)
 
 AC_ARG_ENABLE(lzo,
    [  --disable-lzo           Do not compile LZO compression support],
@@ -66,7 +67,7 @@
 
 AC_ARG_WITH(ssl-lib,
    [  --with-ssl-lib=DIR      Crypto/SSL Library location],
-   [LIBS="$LIBS -L$withval"] 
+   [LDFLAGS="$LDFLAGS -L$withval"] 
 )
 
 AC_ARG_WITH(lzo-headers,
@@ -77,7 +78,7 @@
 
 AC_ARG_WITH(lzo-lib,
    [  --with-lzo-lib=DIR      LZO Library location],
-   [LIBS="$LIBS -L$withval"] 
+   [LDFLAGS="$LDFLAGS -L$withval"] 
 )
 
 AC_ARG_WITH(ifconfig-path,
@@ -97,6 +98,9 @@
 AC_CANONICAL_SYSTEM
 AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
 
+dnl fix search path, to allow compilers to find syshead.h
+CPPFLAGS="$CPPFLAGS -I${srcdir}"
+
 dnl check target OS
 openvpn_target=$target
 if test $target_alias; then
@@ -137,8 +141,11 @@
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
+AC_C_VOLATILE
+AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
+AC_TYPE_UID_T
 AC_HEADER_TIME
 
 dnl Check for more header files.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/openvpn/openvpn/Makefile.am,v
retrieving revision 1.3

Makefile.am +16 -2
diff -u -r1.3 Makefile.am
@@ -24,9 +24,23 @@
 #
 
 sbin_PROGRAMS = openvpn
-openvpn_SOURCES = basic.h buffer.c buffer.h circ_list.h common.h config.h crypto.c crypto.h errlevel.h error.c error.h fdmisc.c fdmisc.h gremlin.c gremlin.h interval.h lzo.c lzo.h memdbg.h misc.c misc.h mtu.h openvpn.c openvpn.h options.c options.h packet_id.c packet_id.h reliable.c reliable.h session_id.c session_id.h shaper.c shaper.h socket.c socket.h ssl.c ssl.h syshead.h thread.c thread.h tun.c tun.h
+nodist_openvpn_SOURCES = config.h
+openvpn_SOURCES = basic.h buffer.c buffer.h circ_list.h common.h \
+		  crypto.c crypto.h errlevel.h error.c error.h \
+		  fdmisc.c fdmisc.h gremlin.c gremlin.h interval.h \
+		  lzo.c lzo.h memdbg.h misc.c misc.h mtu.h openvpn.c \
+		  openvpn.h options.c options.h packet_id.c \
+		  packet_id.h reliable.c reliable.h session_id.c \
+		  session_id.h shaper.c shaper.h socket.c socket.h \
+		  ssl.c ssl.h syshead.h thread.c thread.h tun.c tun.h
 
 KEY_FILES = dh1024.pem client.crt client.key server.crt server.key tmp-ca.crt tmp-ca.key
 
 man_MANS = openvpn.8
-EXTRA_DIST = $(KEY_FILES)
+EXTRA_DIST = $(KEY_FILES) $(man_MANS) \
+	     COPYRIGHT.GPL PORTS openvpn.spec \
+	     easy-rsa sample-config-files sample-keys \
+	     sample-scripts
+
+dist-hook:
+	cd $(distdir) && for i in $(EXTRA_DIST) ; do find $$i -name CVS -type d -prune -exec rm -r '{}' ';' ; done

Index: openvpn.spec
===================================================================
RCS file: /cvsroot/openvpn/openvpn/openvpn.spec,v
retrieving revision 1.59

openvpn.spec +0 -1
diff -u -r1.59 openvpn.spec
@@ -22,7 +22,6 @@
 %setup -q
 
 %build
-./pre-touch
 %configure --enable-pthread
 %__make
 
#7 lore raw

Matthias,

Hey, thanks for the patch and all the testing work on different platforms. You raise a number of good points which I will address below:

(1) Signed/unsigned comparison warnings in packet_id.c and socket.c -- these are obviously just cast issues and I will clean up for a mostly warning-free compile.

(2) "tun.c:254: warning: `open_tun_generic' defined but not used" -> totally innocuous, though I suppose I could design a conditional to filter it out.

(3) On the issue of including generated files in the CVS -- it seemed in the early days of OpenVPN that people wanted the CVS to mirror a tarball and build without the required dependencies of automake/autoconf. But I would have to agree with you that eliminating these files makes a lot of sense and nicely simplifies things.

(4) pre-touch -- a bit of a kludge which was added because cvs was not committing files which had a later modification date but null diffs (as one might argue is correct behaviour). Because of this there were some automake/autoconf problems. This is probably no longer an issue if generated files are removed from the CVS.

(5) --disable-crypto breaks compile -- thanks for noticing that. I forgot to bracket the --replay-persist code inside of #ifdef USE_CRYPTO.

(6) Solaris net/if_tun.h missing produces undefined TUNNEWPPA -- will add a check to configure.ac.

(7) Problems with variadic msg() macros on some compilers -- Writing msg() as a macro is important for efficiency, to avoid a function call during the vast majority of cases where msg() is a noop. Do you think many people use compilers which do not support this? I suppose one could replace with msg1, msg2, msg3, etc. based on the number of arguments, but that would be terribly ugly. I am inclined to leave this as-is, unless you can think of a better way.

(8) Please also note that _* names are reserved name space -- agreed.

(9) The Patch -- looks good, I will test and let you know if I see any problems. BTW, does your changes to the automake/autoconf scripts raise the required version number for automake/autoconf from 1.6/2.50?

James

Quoted 51 lines · Matthias Andree

OK,

here is a full patch for your convenience without the "apply on top" junk, with this patch, the current CVS compiles on:

SuSE Linux 7.3 x86 gcc 2.95.3
SuSE Linux 8.1 x86 gcc 3.2
FreeBSD 4-STABLE x86 gcc 2.95.3+FreeBSD
Solaris 8 Sparc gcc 2.95.3
Solaris 8 Sparc SunPro Workshop 6.

The unfixed bug that remains that I am aware of is the --disable-crypto issue I reported earlier today. I don't think many people will use this configure option, but it should be fixed nonetheless, that's what beta versions are good for :-)

Thanks for the continued maintenance of OpenVPN, BTW.

# Makefile.am  |   18 ++++++++++++++++--
# buffer.c     |    2 +-
# configure.ac |   11 +++++++++--
# crypto.c     |   10 ++++------
# error.c      |    5 ++++-
# error.h      |    6 +-----
# openvpn.spec |    1 -

# 7 files changed, 35 insertions(+), 18 deletions(-)

Index: buffer.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/buffer.c,v
retrieving revision 1.7
diff -u -r1.7 buffer.c

buffer.c +1 -1
@@ -160,7 +160,7 @@
   e->back = thread->gc_stack;
   thread->gc_stack = e;
   /*printf("GC MALLOC " ptr_format " size=%d lev=%d\n", e, s, e->level); */
-  return (void *) e + sizeof (struct gc_entry);
+  return (char *) e + sizeof (struct gc_entry);
 }
 
 void

Index: crypto.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/crypto.c,v
retrieving revision 1.11
diff -u -r1.11 crypto.c

crypto.c line 78

Quoted 2 lines
crypto.c +0 -0
@@ -77,9 +77,6 @@
 #define CRYPT_ERROR(format) \
   do { msg (D_CRYPT_ERRORS, "%s: " format, error_prefix); goto error_exit;

} while (false)

crypto.c line 80

Quoted 3 lines
crypto.c +0 -2
-#define CRYPT_ERROR_ARGS(format, args...) \
-  do { msg (D_CRYPT_ERRORS, "%s: " format, error_prefix, args); goto

error_exit; } while (false)

crypto.c line 344

Quoted 11 lines
crypto.c +0 -4
-
 void
 openvpn_encrypt (struct buffer *buf, struct buffer work,
 		 const struct crypto_options *opt,
@@ -339,9 +336,10 @@
 	      packet_id_add (&opt->packet_id->rec, &pin);
 	      if (opt->pid_persist && opt->packet_id_long_form)
 		packet_id_persist_save_obj (opt->pid_persist, opt->packet_id);
-	    }
-	  else
-	    CRYPT_ERROR_ARGS ("bad packet ID (may be a replay): %s",

packet_id_net_print (&pin));

crypto.c line 340

Quoted 2 lines
crypto.c +2 -0
+	    } else {
+	      msg(D_CRYPT_ERRORS, "%s: bad packet ID (may be a replay): %s",

error_prefix, packet_id_net_print(&pin));

Quoted 39 lines
crypto.c +2 -0
+	      goto error_exit;
+	  }
 	}
       *buf = work;
     }

Index: error.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.c,v
retrieving revision 1.10
diff -u -r1.10 error.c

error.c +4 -1
@@ -114,7 +114,7 @@
 int msg_line_num;
 
 void
-_msg (unsigned int flags, const char *format, ...)
+msg (unsigned int flags, const char *format, ...)
 {
   va_list arglist;
   int level;
@@ -124,6 +124,9 @@
   char *m2;
   char *tmp;
   int e;
+
+  if (!(((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)))
+      return;
 
   e = errno;
 

Index: error.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.h,v
retrieving revision 1.8
diff -u -r1.8 error.h

error.h line 77

Quoted 2 lines
error.h +0 -0
@@ -76,11 +76,7 @@
  */
 #define LOGLEV(log_level, mute_level, other) (((log_level)-1) |

ENCODE_MUTE_LEVEL(mute_level) | other)

error.h

Quoted 6 lines
error.h +0 -5
-#define msg(flags, args...) \
-    do { if (((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)) \
-    _msg((flags), args); } while (false)
-
-void _msg (unsigned int flags, const char *format, ...); /* should be

called via msg above */

Quoted 67 lines
error.h +1 -0
+void msg (unsigned int flags, const char *format, ...);
 
 void error_reset ();
 void set_check_status (int info_level, int verbose_level);

Index: configure.ac
===================================================================
RCS file: /cvsroot/openvpn/openvpn/configure.ac,v
retrieving revision 1.51
diff -u -r1.51 configure.ac

configure.ac +9 -2
@@ -27,6 +27,7 @@
 
 AC_INIT([OpenVPN], [1.3.2.9], [[email protected]], [openvpn])
 AM_CONFIG_HEADER(config.h)
+AC_CONFIG_SRCDIR(syshead.h)
 
 AC_ARG_ENABLE(lzo,
    [  --disable-lzo           Do not compile LZO compression support],
@@ -66,7 +67,7 @@
 
 AC_ARG_WITH(ssl-lib,
    [  --with-ssl-lib=DIR      Crypto/SSL Library location],
-   [LIBS="$LIBS -L$withval"] 
+   [LDFLAGS="$LDFLAGS -L$withval"] 
 )
 
 AC_ARG_WITH(lzo-headers,
@@ -77,7 +78,7 @@
 
 AC_ARG_WITH(lzo-lib,
    [  --with-lzo-lib=DIR      LZO Library location],
-   [LIBS="$LIBS -L$withval"] 
+   [LDFLAGS="$LDFLAGS -L$withval"] 
 )
 
 AC_ARG_WITH(ifconfig-path,
@@ -97,6 +98,9 @@
 AC_CANONICAL_SYSTEM
 AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
 
+dnl fix search path, to allow compilers to find syshead.h
+CPPFLAGS="$CPPFLAGS -I${srcdir}"
+
 dnl check target OS
 openvpn_target=$target
 if test $target_alias; then
@@ -137,8 +141,11 @@
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
+AC_C_VOLATILE
+AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
+AC_TYPE_UID_T
 AC_HEADER_TIME
 
 dnl Check for more header files.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/openvpn/openvpn/Makefile.am,v
retrieving revision 1.3
diff -u -r1.3 Makefile.am

Makefile.am line 27

Quoted 4 lines
Makefile.am +0 -1
@@ -24,9 +24,23 @@
 #
 
 sbin_PROGRAMS = openvpn
-openvpn_SOURCES = basic.h buffer.c buffer.h circ_list.h common.h config.h

crypto.c crypto.h errlevel.h error.c error.h fdmisc.c fdmisc.h gremlin.c gremlin.h interval.h lzo.c lzo.h memdbg.h misc.c misc.h mtu.h openvpn.c openvpn.h options.c options.h packet_id.c packet_id.h reliable.c reliable.h session_id.c session_id.h shaper.c shaper.h socket.c socket.h ssl.c ssl.h syshead.h thread.c thread.h tun.c tun.h

Makefile.am

Quoted 11 lines
Makefile.am +9 -0
+nodist_openvpn_SOURCES = config.h
+openvpn_SOURCES = basic.h buffer.c buffer.h circ_list.h common.h \
+		  crypto.c crypto.h errlevel.h error.c error.h \
+		  fdmisc.c fdmisc.h gremlin.c gremlin.h interval.h \
+		  lzo.c lzo.h memdbg.h misc.c misc.h mtu.h openvpn.c \
+		  openvpn.h options.c options.h packet_id.c \
+		  packet_id.h reliable.c reliable.h session_id.c \
+		  session_id.h shaper.c shaper.h socket.c socket.h \
+		  ssl.c ssl.h syshead.h thread.c thread.h tun.c tun.h
 
 KEY_FILES = dh1024.pem client.crt client.key server.crt server.key

tmp-ca.crt tmp-ca.key

Makefile.am

Quoted 10 lines
Makefile.am +7 -1
 man_MANS = openvpn.8
-EXTRA_DIST = $(KEY_FILES)
+EXTRA_DIST = $(KEY_FILES) $(man_MANS) \
+	     COPYRIGHT.GPL PORTS openvpn.spec \
+	     easy-rsa sample-config-files sample-keys \
+	     sample-scripts
+
+dist-hook:
+	cd $(distdir) && for i in $(EXTRA_DIST) ; do find $$i -name CVS -type d

-prune -exec rm -r '{}' ';' ; done

Quoted 27 lines

Index: openvpn.spec
===================================================================
RCS file: /cvsroot/openvpn/openvpn/openvpn.spec,v
retrieving revision 1.59
diff -u -r1.59 openvpn.spec

openvpn.spec +0 -2
@@ -22,7 +22,6 @@
 %setup -q
 
 %build
-./pre-touch
 %configure --enable-pthread
 %__make
 
 
 
-------------------------------------------------------

This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#8 lore raw
Quoted 1 line · James Yonan

Hey, thanks for the patch and all the testing work on different platforms.

You're welcome. I thought if I give it a whirl, I'd spin it until it was dizzy :-)

Quoted 1 line

You raise a number of good points which I will address below:

There were more warnings that I haven't reported because I think they didn't warrant fixes at this time, some "unused parameter" warnings. Try

make clean
make CFLAGS="-W -Wall"

to see more warnings :-)

Quoted 11 lines

(3) On the issue of including generated files in the CVS -- it seemed in the early days of OpenVPN that people wanted the CVS to mirror a tarball and build without the required dependencies of automake/autoconf. But I would have to agree with you that eliminating these files makes a lot of sense and nicely simplifies things.

(4) pre-touch -- a bit of a kludge which was added because cvs was not committing files which had a later modification date but null diffs (as one might argue is correct behaviour). Because of this there were some automake/autoconf problems. This is probably no longer an issue if generated files are removed from the CVS.

Shipping generated files will usually break things one way or another. I found a few issues in many packages by doing

make distclean
mkdir ../openvpn-build
cd ../openvpn-build
../openvpn/configure -C
make check

or something. I bit myself by accidentally shipping a file I'd think was generated with leafnode, so I have got some first-hand burn marks ;-)

Quoted 2 lines

(6) Solaris net/if_tun.h missing produces undefined TUNNEWPPA -- will add a check to configure.ac.

Thanks.

Quoted 6 lines

(7) Problems with variadic msg() macros on some compilers -- Writing msg() as a macro is important for efficiency, to avoid a function call during the vast majority of cases where msg() is a noop. Do you think many people use compilers which do not support this? I suppose one could replace with msg1, msg2, msg3, etc. based on the number of arguments, but that would be terribly ugly. I am inclined to leave this as-is, unless you can think of a better way.

I have no profiles, sorry, neither of the function call overhead incurred or avoided, nor of the compilers.

Hum. <BRAINSTORMING>

## idea #1:
One thing commonly used to hide prototypes away from compilers that don't support them is enclosing the whole function call in a macro, say:

#ifdef SUPPORT_PROTOS
#define D(p) p
#else
#define D(p) ()
#endif

void myfunc D((int name, char name2));

The important thing is that you pass double parentheses here.

However, the "flags" you use probably prevents us from using this approach.

## idea #2:
Convert the msg macro that you have now to an __inline function and compile with -finline-functions or -O3 and let the global optimizer inline the if (debuglevel high enough) checks. I fear though that the varargs breaks this as well and prevents inlining.

## idea #3:
Use a fixed-argument msg macro big enough to hold all arguments and fill the unused with NULL (rather than doing a dozen macros on your own).

## idea #4:
profile if calling the function really slows down things that much.

</BRAINSTORMING>

Quoted 3 lines

(9) The Patch -- looks good, I will test and let you know if I see any problems. BTW, does your changes to the automake/autoconf scripts raise the required version number for automake/autoconf from 1.6/2.50?

Not that I'm aware of.

I tested aclocal/automake 1.6.3, they look fine on my machine. (I usually use 1.7.2 though).

autoconf 2.50 should be fine as well, all the relevant checks I added are documented in autoconf's ChangeLog.2 which "ends" (topmost entry) with the release of 2.50. I'm using 2.57.

However, I've found that later software (automake 1.7.x and autoconf 2.5x) usually give less bogus warnings and are more robust.

#3 lore raw
In reply to Matthias Andree
Quoted 3 lines

Please also note that _* names are reserved name space. Don't use them for your functions if you can avoid it, for portability -- they might screw some linker.

Are __* names reserved? What's the recommended form for naming "private" variables (I'm coming from C++/Python where _* names are a common naming style for class-private variables to avoid collisions with similarly named public member functions)?

James

#9 lore raw
In reply to Matthias Andree
Quoted 7 lines

There were more warnings that I haven't reported because I think they didn't warrant fixes at this time, some "unused parameter" warnings. Try

make clean
make CFLAGS="-W -Wall"

to see more warnings :-)

Yes, also ./configure --enable-strict does something like this.

Most of the warnings that are left (such as unused function call parameters, unused static functions, etc.) would create more obfuscation if they were fixed. In principle, warnings should direct your attention to possible bugs or things that need to be cleaned up, but I don't believe in making the code harder to read just to fix a warning. For example, I wouldn't bracket a static function with a complex #if just to eliminate warnings about its non-use (as in tun.c).

Quoted 34 lines

I have no profiles, sorry, neither of the function call overhead incurred or avoided, nor of the compilers.

Hum. <BRAINSTORMING>

## idea #1:
One thing commonly used to hide prototypes away from compilers that don't support them is enclosing the whole function call in a macro, say:

#ifdef SUPPORT_PROTOS
#define D(p) p
#else
#define D(p) ()
#endif

void myfunc D((int name, char name2));

The important thing is that you pass double parentheses here.

However, the "flags" you use probably prevents us from using this approach.

## idea #2:
Convert the msg macro that you have now to an __inline function and compile with -finline-functions or -O3 and let the global optimizer inline the if (debuglevel high enough) checks. I fear though that the varargs breaks this as well and prevents inlining.

## idea #3:
Use a fixed-argument msg macro big enough to hold all arguments and fill the unused with NULL (rather than doing a dozen macros on your own).

Quoted 4 lines

## idea #4:
profile if calling the function really slows down things that much.

</BRAINSTORMING>

How about we add a new configure option such as --no-vararg-macros that makes msg() into a function (as you do in your patch) to pacify older compilers?

Even better, is there an autoconf macro which will automatically test whether or not vararg macros are supported?

Then we only take the msg-as-function route if we need to.

James

#4 lore raw
In reply to James Yonan
Quoted 8 lines · James Yonan
Quoted 3 lines

Please also note that _* names are reserved name space. Don't use them for your functions if you can avoid it, for portability -- they might screw some linker.

Are __* names reserved? What's the recommended form for naming "private" variables (I'm coming from C++/Python where _* names are a common naming style for class-private variables to avoid collisions with similarly named public member functions)?

Mostly anything that starts with _ is reserved. There are some exceptions, you may name auto variables _[a-z]*, but not functions.

You could use x_ as prefix though.

I've googled a little and found
http://oakroadsystems.com/tech/c-predef.htm#Groups to be a very useful resource (and it's concise as well).

Signature · 1 line
Matthias Andree
#10 lore raw

[Openvpn-devel] First half of macro-vs-function hacks (was: Pre-1.3.3 beta available for testing)

In reply to James Yonan

Jim,

this is the configure.ac part of the variadic macro test patch, it seems to work OK and cache the results.

I have added also some unrelated AC_CACHE_SAVE (supported since autoconf 2.13) to checkpoint the cache should some later test fail, so the user can more quickly pick up when she typed "./configure -C".

This patch is against my previous one, so if it fails, try patch -F1 or -F2 to narrow the context patch looks at. If that doesn't help, I can send the whole file or a patch against current CVS.

Feel free to try it. To my astonishment, the SUNpro WorkShop compiler seems to know ISO C99 but not the GCC-style variadic macros. I'll investigate some more and might refine this test.

configure.ac +35 -0
diff -u configure.ac configure.ac
@@ -148,6 +148,38 @@
 AC_TYPE_UID_T
 AC_HEADER_TIME
 
+dnl See if the compiler supports variadic macros
+dnl GCC-style
+AC_MSG_CHECKING(if your preprocessor supports GCC-style variadic macros)
+AC_CACHE_VAL(openvpn_cv_c_varmac_gcc,
+AC_COMPILE_IFELSE([[
+		   #include <stdio.h>
+		   #define mymac(first, second...) printf(first, ## second)
+		   main() { mymac("%s", "test"); }
+		   ]],
+		   [openvpn_cv_c_varmac_gcc=yes],
+		   [openvpn_cv_c_varmac_gcc=no]))
+AC_MSG_RESULT($openvpn_cv_c_varmac_gcc)
+if test $openvpn_cv_c_varmac_gcc = yes ; then
+    AC_DEFINE(OPENVPN_VARMAC_GCC, [1], [Define to 1 if your preprocessor supports GCC-style variadic macros.])
+fi
+
+dnl ISO C99-style
+AC_MSG_CHECKING(if your preprocessor supports ISO C99 variadic macros)
+AC_CACHE_VAL(openvpn_cv_c_varmac_isoc99,
+AC_COMPILE_IFELSE([[
+		   #include <stdio.h>
+		   #define mymac(first, ...) printf(first, __VA_ARGS__)
+		   main() { mymac("%s", "test"); }
+		   ]],
+		   [openvpn_cv_c_varmac_isoc99=yes],
+		   [openvpn_cv_c_varmac_isoc99=no]))
+AC_MSG_RESULT($openvpn_cv_c_varmac_isoc99)
+if test $openvpn_cv_c_varmac_isoc99 = yes ; then
+    AC_DEFINE(OPENVPN_VARMAC_ISOC99, [1], [Define to 1 if your preprocessor supports ISO C99 variadic macros.])
+fi
+AC_CACHE_SAVE
+
 dnl Check for more header files.
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(sys/time.h)
@@ -184,6 +216,7 @@
 AC_CHECK_HEADERS(netdb.h)
 AC_CHECK_HEADERS(sys/uio.h)
 AC_CHECK_HEADERS(linux/if_tun.h)
+AC_CACHE_SAVE
 
 dnl check that in_addr_t is defined
 AC_CHECK_TYPE(
@@ -220,6 +253,7 @@
 	[AC_DEFINE(HAVE_IOVEC, 1, [struct iovec needed for IPv6 support])],
 	[],
 	[#include "syshead.h"])
+AC_CACHE_SAVE
 
 dnl check for other types
 TYPE_SOCKLEN_T
@@ -257,6 +291,7 @@
 AC_CHECK_FUNCS(readv)
 AC_CHECK_FUNCS(writev)
 AC_CHECK_FUNCS(setsockopt)
+AC_CACHE_SAVE
 
 dnl Required library functions
 AC_FUNC_MEMCMP
#13 lore raw

Second half of variadic macro fix (was: [Openvpn-devel] Pre-1.3.3 beta available for testing)

In reply to James Yonan

Dear Jim,

this second patch completes the varargs stuff. Tested on all machines I listed last time, and SUNpro 6 is very happy with the ISO C99 stuff and uses the macro (rather than the function). I tried to force the function underneath gcc 2.95 (edited config.cache, ran ./config.status --recheck, ./config.status, remade stuff), seems fine here.

Please give it a try (sorry for listing the files in the wrong reading order, shell globbed .c before .h).

Cheers,
Matthias

Index: error.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.c,v
retrieving revision 1.10

error.c +21 -3
diff -u -r1.10 error.c
@@ -113,10 +113,24 @@
 
 int msg_line_num;
 
-void
-_msg (unsigned int flags, const char *format, ...)
+#if !MSGMACRO
+void msg(unsigned int flags, const char *format, ...) {
+    va_list ap;
+    va_start(ap, format);
+    _msg(flags, format, ap);
+    va_end(ap);
+}
+#endif
+
+#if MSGMACRO
+void _msg (unsigned int flags, const char *format, ...)
+#else
+void _msg (unsigned int flags, const char *format, va_list arglist)
+#endif
 {
+#if MSGMACRO
   va_list arglist;
+#endif
   int level;
   char msg1[ERR_BUF_SIZE];
   char msg2[ERR_BUF_SIZE];
@@ -161,9 +175,13 @@
   m1 = msg1;
   m2 = msg2;
 
+#if MSGMACRO
   va_start (arglist, format);
+#endif
   vsnprintf (m1, ERR_BUF_SIZE, format, arglist);
+#if MSGMACRO
   va_end (arglist);
+#endif
 
   if ((flags & M_ERRNO) && e)
     {
@@ -180,7 +198,7 @@
     {
       int nerrs = 0;
       int err;
-      while (err = ERR_get_error ())
+      while ((err = ERR_get_error ()))
 	{
 	  snprintf (m2, ERR_BUF_SIZE, "%s: %s", m1, ERR_error_string (err, NULL));
 	  SWAP;

Index: error.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.h,v
retrieving revision 1.8

error.h +16 -1
diff -u -r1.8 error.h
@@ -76,11 +76,26 @@
  */
 #define LOGLEV(log_level, mute_level, other) (((log_level)-1) | ENCODE_MUTE_LEVEL(mute_level) | other)
 
+#if OPENVPN_VARMAC_ISOC99
+#define msg(flags, ...) \
+    do { if (((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)) \
+    _msg((flags), __VA_ARGS__); } while (false)
+#define MSGMACRO 1
+#elif OPENVPN_VARMAC_GCC
 #define msg(flags, args...) \
     do { if (((flags) & M_DEBUG_LEVEL) < _debug_level || ((flags) & M_FATAL)) \
     _msg((flags), args); } while (false)
+#define MSGMACRO 1
+#else
+#define MSGMACRO 0
+    void msg(unsigned int flags, const char *format, ...);
+#endif
 
-void _msg (unsigned int flags, const char *format, ...); /* should be called via msg above */
+#if MSGMACRO
+void _msg(unsigned int flags, const char *format, ...); /* should be called via msg above */
+#else
+void _msg(unsigned int flags, const char *format, va_list ap);
+#endif
 
 void error_reset ();
 void set_check_status (int info_level, int verbose_level);
#14 lore raw

[Openvpn-devel] warnings quencher #1

In reply to James Yonan

against current CVS:

Index: thread.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/thread.h,v
retrieving revision 1.3

thread.h +5 -0
diff -u -r1.3 thread.h
@@ -136,6 +136,8 @@
 static inline void
 work_thread_create (void *(*start_routine) (void *), void* arg)
 {
+    (void)start_routine;
+    (void)arg;
 }
 
 static inline void
@@ -146,16 +148,19 @@
 static inline void
 mutex_lock (int type)
 {
+    (void)type;
 }
 
 static inline void
 mutex_unlock (int type)
 {
+    (void)type;
 }
 
 static inline void
 mutex_cycle (int type)
 {
+    (void)type;
 }
 
 #endif /* USE_PTHREAD */
#11 lore raw

Re: [Openvpn-devel] First half of macro-vs-function hacks (was: Pre-1.3.3 beta available for testing)

In reply to Matthias Andree

Matthias,

Okay, I just put a bunch of stuff in the CVS:

(1) your earlier patch (pre-variable argument macro fix)
(2) some warning removals
(3) my own vararg stuff (we'll have to reconcile our versions)
(4) removed generated files from CVS
(5) fixed --disable-crypto
(6) a better undefined TUNNEWPPA error for Solaris

Still to do:
(1) _* name renaming
(2) merge your warnings quencher #1
(3) the removal of install-sh seems to have broken rpmbuild -tb [tarball]
(4) reconcile macro vararg approaches

Question: What's the best way to generate a tarball that has ./configure already generated, so that openvpn can be built and installed with the usual "./configure && make && make install"?

James

Quoted 95 lines · Matthias Andree

Jim,

this is the configure.ac part of the variadic macro test patch, it seems to work OK and cache the results.

I have added also some unrelated AC_CACHE_SAVE (supported since autoconf 2.13) to checkpoint the cache should some later test fail, so the user can more quickly pick up when she typed "./configure -C".

This patch is against my previous one, so if it fails, try patch -F1 or -F2 to narrow the context patch looks at. If that doesn't help, I can send the whole file or a patch against current CVS.

Feel free to try it. To my astonishment, the SUNpro WorkShop compiler seems to know ISO C99 but not the GCC-style variadic macros. I'll investigate some more and might refine this test.

diff -u configure.ac configure.ac

configure.ac +35 -1
@@ -148,6 +148,38 @@
 AC_TYPE_UID_T
 AC_HEADER_TIME
 
+dnl See if the compiler supports variadic macros
+dnl GCC-style
+AC_MSG_CHECKING(if your preprocessor supports GCC-style variadic macros)
+AC_CACHE_VAL(openvpn_cv_c_varmac_gcc,
+AC_COMPILE_IFELSE([[
+		   #include <stdio.h>
+		   #define mymac(first, second...) printf(first, ## second)
+		   main() { mymac("%s", "test"); }
+		   ]],
+		   [openvpn_cv_c_varmac_gcc=yes],
+		   [openvpn_cv_c_varmac_gcc=no]))
+AC_MSG_RESULT($openvpn_cv_c_varmac_gcc)
+if test $openvpn_cv_c_varmac_gcc = yes ; then
+    AC_DEFINE(OPENVPN_VARMAC_GCC, [1], [Define to 1 if your preprocessor supports GCC-style variadic macros.])
+fi
+
+dnl ISO C99-style
+AC_MSG_CHECKING(if your preprocessor supports ISO C99 variadic macros)
+AC_CACHE_VAL(openvpn_cv_c_varmac_isoc99,
+AC_COMPILE_IFELSE([[
+		   #include <stdio.h>
+		   #define mymac(first, ...) printf(first, __VA_ARGS__)
+		   main() { mymac("%s", "test"); }
+		   ]],
+		   [openvpn_cv_c_varmac_isoc99=yes],
+		   [openvpn_cv_c_varmac_isoc99=no]))
+AC_MSG_RESULT($openvpn_cv_c_varmac_isoc99)
+if test $openvpn_cv_c_varmac_isoc99 = yes ; then
+    AC_DEFINE(OPENVPN_VARMAC_ISOC99, [1], [Define to 1 if your preprocessor supports ISO C99 variadic macros.])
+fi
+AC_CACHE_SAVE
+
 dnl Check for more header files.
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(sys/time.h)
@@ -184,6 +216,7 @@
 AC_CHECK_HEADERS(netdb.h)
 AC_CHECK_HEADERS(sys/uio.h)
 AC_CHECK_HEADERS(linux/if_tun.h)
+AC_CACHE_SAVE
 
 dnl check that in_addr_t is defined
 AC_CHECK_TYPE(
@@ -220,6 +253,7 @@
 	[AC_DEFINE(HAVE_IOVEC, 1, [struct iovec needed for IPv6 support])],
 	[],
 	[#include "syshead.h"])
+AC_CACHE_SAVE
 
 dnl check for other types
 TYPE_SOCKLEN_T
@@ -257,6 +291,7 @@
 AC_CHECK_FUNCS(readv)
 AC_CHECK_FUNCS(writev)
 AC_CHECK_FUNCS(setsockopt)
+AC_CACHE_SAVE
 
 dnl Required library functions
 AC_FUNC_MEMCMP
 
 
-------------------------------------------------------

This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#12 lore raw

Re: [Openvpn-devel] First half of macro-vs-function hacks (was: Pre-1.3.3 beta available for testing)

[resend, first send went to James but not the list]

Hi,

after the merge, I got some rejects for minor differences, usually coding style.

My coding style is: add parentheses without space for function and macro calls, add a space for control constructs:

printf("something");
if (test == true) { ... }
while (1) { munch_cpu(); }

Quoted 2 lines · James Yonan

Still to do:
(1) _* name renaming

I'm not pressing towards this before 1.3.3, if 1.3.3 ships with the _names in place, that's fine with me.

Quoted 2 lines

(2) merge your warnings quencher #1
(3) the removal of install-sh seems to have broken rpmbuild -tb [tarball]

I don't have rpmbuild (rpm 3.0.x here, SuSE Linux 8.1), but I can successfully build a binary rpm by: (the same i586 target is used for any other SuSE Linux 8.1 package)

make dist
rpm --target=i586 -tb openvpn-1.3.2.10.tar.gz

Quoted 1 line

(4) reconcile macro vararg approaches

Leaving the acinclude.m4/configure.ac aside for a moment, how about this patch to reduce special casing in the preprocessor, rename _msg to x_msg and fix warnings?

# error.h |   25 ++++++++++++-------------
# error.c |   20 ++++++++------------
# 2 files changed, 20 insertions(+), 25 deletions(-)

Index: error.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.h,v
retrieving revision 1.9

error.h +12 -13
diff -u -r1.9 error.h
@@ -34,9 +34,9 @@
  * These globals should not be accessed directly,
  * but rather through macros or inline functions defined below.
  */
-extern int _debug_level;
-extern int _cs_info_level;
-extern int _cs_verbose_level;
+extern unsigned int _debug_level;
+extern unsigned int _cs_info_level;
+extern unsigned int _cs_verbose_level;
 
 extern int msg_line_num;
 
@@ -85,25 +85,24 @@
 
 #if defined(HAVE_VARARG_MACROS_ISO)
 #define HAVE_VARARG_MACROS
-#define msg(flags, ...) do { if (MSG_TEST(flags)) _msg((flags), __VA_ARGS__); } while (false)
+#define msg(flags, ...) do { if (MSG_TEST(flags)) x_msg((flags), __VA_ARGS__); } while (false)
 #elif defined(HAVE_VARARG_MACROS_GCC)
 #define HAVE_VARARG_MACROS
-#define msg(flags, args...) do { if (MSG_TEST(flags)) _msg((flags), args); } while (false)
-#endif
-
-#ifdef HAVE_VARARG_MACROS
-void _msg (unsigned int flags, const char *format, ...); /* should be called via msg above */
+#define msg(flags, args...) do { if (MSG_TEST(flags)) x_msg((flags), args); } while (false)
 #else
-void msg (unsigned int flags, const char *format, ...);
+#define x_msg msg
+#undef HAVE_VARARG_MACROS
 #endif
 
+void x_msg (unsigned int flags, const char *format, ...);
+
 /*
  * Function prototypes
  */
 
 void error_reset ();
-void set_check_status (int info_level, int verbose_level);
-void set_debug_level (int level);
+void set_check_status (unsigned int info_level, unsigned int verbose_level);
+void set_debug_level (unsigned int level);
 void set_mute_cutoff (int cutoff);
 
 /*
@@ -119,7 +118,7 @@
 /* Inline functions */
 
 static inline bool
-check_debug_level (int level)
+check_debug_level (unsigned int level)
 {
   return (level & M_DEBUG_LEVEL) < _debug_level;
 }

Index: error.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.c,v
retrieving revision 1.11

error.c +8 -12
diff -u -r1.11 error.c
@@ -39,9 +39,9 @@
 #include "memdbg.h"
 
 /* Globals */
-int _debug_level;
-int _cs_info_level;
-int _cs_verbose_level;
+unsigned int _debug_level;
+unsigned int _cs_info_level;
+unsigned int _cs_verbose_level;
 
 /* Mute state */
 static int mute_cutoff;
@@ -55,7 +55,7 @@
 static FILE *msgfp;
 
 void
-set_debug_level (int level)
+set_debug_level (unsigned int level)
 {
   _debug_level = level;
 }
@@ -87,7 +87,7 @@
 }
 
 void
-set_check_status (int info_level, int verbose_level)
+set_check_status (unsigned int info_level, unsigned int verbose_level)
 {
   _cs_info_level = info_level;
   _cs_verbose_level = verbose_level;
@@ -113,11 +113,7 @@
 
 int msg_line_num;
 
-#ifdef HAVE_VARARG_MACROS
-void _msg (unsigned int flags, const char *format, ...)
-#else
-void msg (unsigned int flags, const char *format, ...)
-#endif
+void x_msg (unsigned int flags, const char *format, ...)
 {
   va_list arglist;
   int level;
@@ -187,8 +183,8 @@
   if (flags & M_SSL)
     {
       int nerrs = 0;
-      int err;
-      while (err = ERR_get_error ())
+      unsigned long err;
+      while ((err = ERR_get_error ()))
 	{
 	  snprintf (m2, ERR_BUF_SIZE, "%s: %s", m1, ERR_error_string (err, NULL));
 	  SWAP;
Quoted 3 lines

Question: What's the best way to generate a tarball that has ./configure already generated, so that openvpn can be built and installed with the usual "./configure && make && make install"?

The canonical way is:

make distcheck

If you're absolutely confident it works, because you just changed documentation, "make dist" will suffice.

Signature · 1 line
Matthias Andree