New beta available + progress update
OpenVPN continues to evolve, and I thought I would take this opportunity to briefly describe some of the current directions in the project (which, incidentally, has passed its 1 year milestone).
For one, a new OpenVPN beta is available and testing would be appreciated.
http://openvpn.sourceforge.net/beta/openvpn-1.3.2.21.tar.gz (or CVS)
Thanks to the stability of 1.3.2, I've held off on making a new release that's composed entirely of minor changes, and have instead focussed on some bigger issues such as making the handling of MTU and fragmentation more dynamic and automatic. To this end, the new beta contains a number of improvements to allow for dynamic MTU resizing. This code is still experimental, and must be explicitly enabled by defining FRAGMENT_ENABLE and rebuilding.
What the FRAGMENT_ENABLE code does is to add an extra 4 byte header to each datagram that includes, among other things, feedback on the number of datagrams received as well as the maximum datagram size received. This information can then be used by an OpenVPN peer to dynamically set the MTU size as well as the datagram transmit rate independently of the OS and the proper functioning of path MTU discovery. Ultimately this code can make OpenVPN more robust in situations where fragmentation is necessary (such as in TAP-based bridged ethernets) when firewalls or routers in the path break PMTU discovery.
My thinking right now is to make the next release 1.4.0 but leave the FRAGMENT_ENABLE code off by default. Even with the FRAGMENT_ENABLE code disabled, there's enough new stuff here to justify a point release.
As well, there are a fair number of minor changes as well (see the ChangeLog at the end of this message).
Looking post-1.4.0, the latest wishlist appears to be:
(1) Simplify configuration for setups that involve one server and numerous roving clients (some of this has already been addressed by the --inetd option).
(2) Dynamic MTU support. Ultimately, the FRAGMENT_ENABLE code will do this, but it still needs testing and more developer input.
(3) Porting to Windows. Judging by email I receive, there seems to be a lot of demand for this. In addition, a lot of developers have come forward who are interested in working on a TUN/TAP driver for Windows (which is the missing link), but so far I haven't seen much progress. I may jump into the fray and work on this myself, though due to the higher costs of developing for Windows, I would need some corporate sponsorship to help defray costs. Let me know if you are interested in sponsoring such an undertaking.
If there are wishlist items I have missed, or if there is something you would like to add, please let us know.
And also, please be reminded that the OpenVPN project is financially supported by the user community. Please consider donating to the project. More info is available here:
http://openvpn.sourceforge.net/donate.html
James
**************
ChangeLog:
$Id: ChangeLog,v 1.69 2003/04/17 07:12:02 jimyonan Exp $
Upcoming version 1.4.0
* 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.
* Added --dev-name option (Christian Lademann).
* Added --mtu-disc option for manual control over MTU options.
* Show OS MTU value on UDP socket write failures (linux only).
* Numerous build system and portability fixes (Matthias Andree).
* Added better sensing of compiler support for variable argument macros, including (a) gcc style, (b) ISO C 1999 style, and (c) no support.
* Removed generated files from CVS. Note INSTALL file for new CVS build commands.
* Changed all internal _* symbols to x_*
for C standards compliance.
* Added TUN/TAP open code to cycle dynamically through unit numbers until it finds a free unit (based on code from Thomas Gielfeldt and VTun).
* Added dynamic MTU and fragmenting infrastructure (Experimental). Rebuild with FRAGMENT_ENABLE defined to enable.
* Minor changes to SSL/TLS negotiation, use exponential backoff on retransmits, and use a smaller MTU size (note that no protocol changes have been made which would break compatibility with 1.3.x).
* Added --enable-strict-options flag
to ./configure. This option will cause
a more strict check for options compatibility between peers when SSL/TLS negotiation is used, but should only be used when both OpenVPN peers are of the same version.
* Reorganization of debugging levels >= 5.
Quoted 1 line
http://openvpn.sourceforge.net/beta/openvpn-1.3.2.21.tar.gz (or CVS)
I have a next round of patches to fix prototypes and types to quench compiler warnings and get a more robust source code against changed environments, to aid possible later debugging; it also includes GCC extensions (only used when GCC is being used) that allow stricter msg() and buf_printf() format string vs. argument checking, to avoid printing bogus data when type sizes differ (think 64 bit).
One problem remains after applying the patch:openvpn.c: In function `openvpn':
openvpn.c:470: warning: cast discards qualifiers from pointer target type
Other than that, we have unused parameter warnings (you said before you're not fixing them), shadow parameter warnings (variable names being the same as system functions, such as time or nice) and in particular, aggregate (struct) values in function calls and function returns, these are inefficient (as the compiler must toss the whole struct on the stack, which involves copy overhead), and some of them (buffer.c in particular) look pretty suspicious. Is there any C standard that guarantees that returning an auto struct works and copies the return value?
Index: buffer.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/buffer.c,v
retrieving revision 1.12
buffer.c +2 -2
@@ -111,7 +111,7 @@* printf append to a buffer with overflow check */ void -buf_printf (struct buffer *buf,char *format, ...) +buf_printf (struct buffer *buf,const char *format, ...) {va_list arglist;
@@ -223,7 +223,7 @@char *format_hex_ex (const uint8_t *data,int size,int maxoutput, -int space_break,char * separator) +int space_break,const char * separator) {struct buffer out =alloc_buf_gc (maxoutput ? maxoutput : ((size *2 ) + (size / space_break) +2 ));
Index: buffer.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/buffer.h,v
retrieving revision 1.11
buffer.h +9 -5
@@ -47,7 +47,7 @@struct buffer alloc_buf (size_t size);struct buffer clone_buf (const struct buffer * buf);struct buffer alloc_buf_gc (size_t size);/* allocate buffer with garbage collection */ -struct buffer clear_buf (); +struct buffer clear_buf (void );void free_buf (struct buffer *buf); static inline bool
@@ -93,7 +93,7 @@/* Like strncpy but makes sure dest is always null terminated */ static inline void -strncpynt (char *dest,const char *src,int maxlen) +strncpynt (char *dest,const char *src,size_t maxlen) {strncpy (dest, src, maxlen);if (maxlen >0 )
@@ -116,7 +116,11 @@/* * printf append to a buffer with overflow check */ -void buf_printf (struct buffer *buf,char *format, ...); +void buf_printf (struct buffer *buf, const char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 2, 3))) +#endif + ; /* * remove trailing newline
@@ -149,7 +153,7 @@*/ char *format_hex_ex (const uint8_t *data,int size,int maxoutput, -int space_break,char * separator); +int space_break,const char * separator);static inline char *format_hex (const uint8_t *data,int size,int maxoutput)
@@ -353,7 +357,7 @@void x_gc_free (void *p);static inline int -gc_new_level () +gc_new_level (void ) {struct gc_thread * thread = &x_gc_thread[thread_number ()];return ++thread->gc_level;
Index: common.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/common.h,v
retrieving revision 1.14
common.h +5 -1
@@ -41,8 +41,12 @@*/ #define counter_format "%10lu"#define ptr_format "0x%08zx" -#define time_format "%u" +#define time_format "%lu"#define fragment_type_format "0x%08x" + +/* these are used to cast the arguments +* and MUST match the formats above */ +typedef unsigned long time_type ;/* * Functions used for circular buffer index arithmetic.
Index: configure.ac
===================================================================
RCS file: /cvsroot/openvpn/openvpn/configure.ac,v
retrieving revision 1.64
configure.ac +3 -0
@@ -223,6 +223,9 @@ [], [#include "syshead.h"]) +AC_CHECK_SIZEOF(unsigned int) +AC_CHECK_SIZEOF(unsigned long) + AC_CACHE_SAVE dnl check for other types
Index: crypto.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/crypto.h,v
retrieving revision 1.11
crypto.h +3 -3
@@ -262,11 +262,11 @@void test_crypto (const struct crypto_options *co,struct frame * f); -void show_available_ciphers (); +void show_available_ciphers (void ); -void show_available_digests (); +void show_available_digests (void ); -void init_crypto_lib (); +void init_crypto_lib (void );#ifdef USE_SSL
Index: error.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.c,v
retrieving revision 1.17
error.c +1 -1
@@ -251,7 +251,7 @@ }void -become_inetd_server () +become_inetd_server (void ) {#if defined(HAVE_OPENLOG ) && defined(HAVE_SYSLOG )if (!msgfp)
Index: error.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/error.h,v
retrieving revision 1.14
error.h +10 -6
@@ -88,30 +88,34 @@#define MSG_TEST (flags) ((((unsigned int)flags) & M_DEBUG_LEVEL) < x_debug_level || ((flags) & M_FATAL)) -#if defined(HAVE_CPP_VARARG_MACRO_ISO ) +#if defined(HAVE_CPP_VARARG_MACRO_ISO ) && !defined(__LCLINT__)#define HAVE_VARARG_MACROS #define msg (flags, ...) do { if (MSG_TEST(flags)) x_msg((flags), __VA_ARGS__); } while (false) -#elif defined(HAVE_CPP_VARARG_MACRO_CPP ) +#elif defined(HAVE_CPP_VARARG_MACRO_CPP ) && !defined(__LCLINT__)#define HAVE_VARARG_MACROS #define msg(flags, args...) do { if (MSG_TEST(flags)) x_msg((flags), args); } while (false)#else #define msg x_msg#endif -void x_msg (unsigned int flags,const char *format, ...);/* should be called via msg above */ +void x_msg (unsigned int flags, const char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 2, 3))) +#endif + ; /* should be called via msg above *//* * Function prototypes */ -void error_reset (); +void error_reset (void );void set_debug_level (int level);void set_mute_cutoff (int cutoff);/* * File to print messages to before syslog is opened. */ -FILE *msg_fp (); +FILE *msg_fp (void );/* Fatal logic errors */ #define ASSERT (x) do { if (!(x)) assert_failed(__FILE__, __LINE__); } while (false)
@@ -127,7 +131,7 @@ }void become_daemon (const char *cd); -void become_inetd_server (); +void become_inetd_server (void );#include "errlevel.h"
Index: gremlin.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/gremlin.c,v
retrieving revision 1.9
gremlin.c +1 -1
@@ -103,7 +103,7 @@* Return false if we should drop a packet. */ bool -ask_gremlin () +ask_gremlin (void ) {struct timeval tv;
Index: gremlin.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/gremlin.h,v
retrieving revision 1.3
gremlin.h +1 -1
@@ -25,5 +25,5 @@#include "buffer.h" -bool ask_gremlin (); +bool ask_gremlin (void );void corrupt_gremlin (struct buffer * buf);
Index: misc.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/misc.h,v
retrieving revision 1.13
misc.h +4 -4
@@ -51,8 +51,8 @@int openvpn_system (const char *command);/* interpret the status code returned by system() */ -bool system_ok (int stat); -const char *system_error_message (int stat); +bool system_ok (int ); +const char *system_error_message (int );/* run system() with error check, return true if success, false if error, exit if error and fatal==true */
@@ -62,11 +62,11 @@const char *time_string (time_t t);/* init random() function, only used as source for weak random numbers, when !USE_CRYPTO */ -void init_random_seed (); +void init_random_seed (void );/* an analogue to the random() function, but use OpenSSL functions if available */ #ifdef USE_CRYPTO -long int get_random (); +long int get_random (void );#else #define get_random random#endif
Index: options.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/options.c,v
retrieving revision 1.31
options.c +5 -5
@@ -491,7 +491,7 @@ }static void -usage () +usage (void ) {struct options o;FILE *fp =msg_fp ();
@@ -518,14 +518,14 @@ }void -usage_small () +usage_small (void ) {msg (M_WARN ,"Use --help for more information" );exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ } -void -usage_version () +static void +usage_version (void ) {msg (M_INFO ,"%s" ,TITLE );msg (M_INFO ,"Copyright (C) 2002-2003 James Yonan <[email protected]...>" );
@@ -552,7 +552,7 @@ }static void -ping_rec_err () +ping_rec_err (void ) {msg (M_WARN ,"Options error: only one of --ping-exit or --ping-restart options may be specified" );usage_small ();
Index: options.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/options.h,v
retrieving revision 1.23
options.h +1 -1
@@ -175,7 +175,7 @@void notnull (const char *arg,const char *description); -void usage_small (); +void usage_small (void );void init_options (struct options *o);void show_settings (const struct options *o);
Index: packet_id.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/packet_id.c,v
retrieving revision 1.13
packet_id.c +8 -7
@@ -86,7 +86,8 @@msg (D_PID_DEBUG ,"PID TEST " time_format":" packet_id_format" " time_format":" packet_id_format"" , - p->time, p->id, pin->time, pin->id); + (time_type )p->time, (packet_id_print_type )p->id, (time_type )pin->time, + (packet_id_print_type )pin->id);if (!pin->id)return false;
@@ -114,10 +115,10 @@ packet_id_net_print (const struct packet_id_net *pin, bool print_timestamp) {struct buffer out =alloc_buf_gc (256 ); - -buf_printf (&out,"[ #" packet_id_format, pin->id); + +buf_printf (&out,"[ #" packet_id_format, (packet_id_print_type )pin->id);if (print_timestamp && pin->time) -buf_printf (&out," / time = (" packet_id_format") %s" , pin->time,time_string (pin->time)); +buf_printf (&out," / time = (" packet_id_format") %s" , (packet_id_print_type )pin->time,time_string (pin->time));buf_printf (&out," ]" );return BSTR (&out);
@@ -244,14 +245,14 @@ packet_id_persist_print (const struct packet_id_persist *p) {struct buffer out =alloc_buf_gc (256 ); - +buf_printf (&out,"[" );if (packet_id_persist_enabled (p)) { -buf_printf (&out," #" packet_id_format, p->id); +buf_printf (&out," #" packet_id_format, (packet_id_print_type )p->id);if (p->time) -buf_printf (&out," / time = (" packet_id_format") %s" , p->time,time_string (p->time)); +buf_printf (&out," / time = (" packet_id_format") %s" , (packet_id_print_type )p->time,time_string (p->time)); }buf_printf (&out," ]" );
Index: packet_id.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/packet_id.h,v
retrieving revision 1.13
packet_id.h +8 -0
@@ -93,7 +93,15 @@/* * Printf formats for special types */ +#if SIZEOF_UNSIGNED_LONG ==4 +#define packet_id_format "%lu" +typedef unsigned long packet_id_print_type ; +#elif SIZEOF_UNSIGNED_INT ==4 #define packet_id_format "%u" +typedef unsigned int packet_id_print_type ; +#else +#error "cannot figure proper format to print uint32_t" +#endif /* * Maximum allowed backtrack in
Index: reliable.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/reliable.c,v
retrieving revision 1.12
reliable.c +13 -13
@@ -62,7 +62,7 @@ { *pid =ntohpid (net_pid);msg (D_REL_DEBUG ,"ACK read ID " packet_id_format" (buf->len=%d)" , - *pid, buf->len); + (packet_id_print_type)*pid, buf->len);return true; }
@@ -78,12 +78,12 @@ { ack->packet_id[ack->len++] = pid;msg (D_REL_DEBUG ,"ACK acknowledge ID " packet_id_format" (ack->len=%d)" , - pid, ack->len); + (packet_id_print_type )pid, ack->len);return true; }msg (D_REL_LOW ,"ACK acknowledge ID " packet_id_format" FAILED (ack->len=%d)" , - pid, ack->len); + (packet_id_print_type )pid, ack->len);return false; }
@@ -153,7 +153,7 @@packet_id_type pid = ack->packet_id[i];packet_id_type net_pid =htonpid (pid);ASSERT (buf_write (&sub, &net_pid,sizeof (net_pid))); -msg (D_REL_DEBUG ,"ACK write ID " packet_id_format" (ack->len=%d, n=%d)" , pid, ack->len, n); +msg (D_REL_DEBUG ,"ACK write ID " packet_id_format" (ack->len=%d, n=%d)" , (packet_id_print_type )pid, ack->len, n); }if (n) {
@@ -195,7 +195,7 @@if (!buf_read (buf, &pid,sizeof (pid))) goto done; pid =ntohpid (pid); -buf_printf (&out," " packet_id_format, pid); +buf_printf (&out," " packet_id_format, (packet_id_print_type )pid); }if (n_ack) {
@@ -294,7 +294,7 @@ {msg (D_REL_DEBUG ,"ACK received for pid " packet_id_format", deleting from send buffer" , - pid); + (packet_id_print_type )pid);#if 0 /* DEBUGGING -- how close were we timing out on ACK failure and resending? */ {
@@ -316,12 +316,12 @@struct buffer out =alloc_buf_gc (512 );int i; -buf_printf (&out,"[" packet_id_format"]" , rel->packet_id); +buf_printf (&out,"[" packet_id_format"]" , (packet_id_print_type )rel->packet_id);for (i =0 ; i < rel->size; ++i) {const struct reliable_entry *e = &rel->array[i];if (e->active) -buf_printf (&out," " packet_id_format, e->packet_id); +buf_printf (&out," " packet_id_format, (packet_id_print_type )e->packet_id); }return BSTR (&out); }
@@ -357,7 +357,7 @@return true; bad: -msg (D_REL_DEBUG ,"ACK " packet_id_format" is a replay: %s" , id,reliable_print_ids (rel)); +msg (D_REL_DEBUG ,"ACK " packet_id_format" is a replay: %s" , (packet_id_print_type )id,reliable_print_ids (rel));return false; }
@@ -372,7 +372,7 @@else {msg (D_REL_DEBUG ,"ACK " packet_id_format" breaks sequentiality: %s" , - id,reliable_print_ids (rel)); + (packet_id_print_type )id,reliable_print_ids (rel));return false; } }
@@ -504,7 +504,7 @@#endif *opcode = best->opcode;msg (D_REL_DEBUG ,"ACK reliable_send ID " packet_id_format" (size=%d to=%d)" , - best->packet_id, best->buf.len, (int ) best->next_try - current); + (packet_id_print_type )best->packet_id, best->buf.len, (int )(best->next_try - current));return &best->buf; }return NULL ;
@@ -552,7 +552,7 @@ e->opcode = opcode; e->next_try =0 ; e->timeout =0 ; -msg (D_REL_DEBUG ,"ACK mark active incoming ID " packet_id_format, e->packet_id); +msg (D_REL_DEBUG ,"ACK mark active incoming ID " packet_id_format, (packet_id_print_type )e->packet_id);return ; } }
@@ -582,7 +582,7 @@ e->opcode = opcode; e->next_try =0 ; e->timeout = rel->initial_timeout; -msg (D_REL_DEBUG ,"ACK mark active outgoing ID " packet_id_format, e->packet_id); +msg (D_REL_DEBUG ,"ACK mark active outgoing ID " packet_id_format, (packet_id_print_type )e->packet_id);return ; } }
Index: shaper.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/shaper.c,v
retrieving revision 1.6
shaper.c +2 -2
@@ -113,7 +113,7 @@ } }msg (D_SHAPER_DEBUG ,"SHAPER shaper_soonest_event sec=%d usec=%d" , - tv->tv_sec, tv->tv_usec); + (int )tv->tv_sec, (int )tv->tv_usec); }/*
@@ -138,7 +138,7 @@ s->wakeup.tv_usec -=1000000 ; }msg (D_SHAPER_DEBUG ,"SHAPER shaper_wrote_bytes bytes=%d delay=%d sec=%d usec=%d" , - nbytes, delay, s->wakeup.tv_sec, s->wakeup.tv_usec); + nbytes, delay, (int )s->wakeup.tv_sec, (int )s->wakeup.tv_usec); }/*
Index: socket.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/socket.h,v
retrieving revision 1.10
socket.h +1 -1
@@ -109,7 +109,7 @@extern unsigned int x_cs_info_level;extern unsigned int x_cs_verbose_level; -void reset_check_status (); +void reset_check_status (void );void set_check_status (unsigned int info_level,unsigned int verbose_level);void x_check_status (int status,const char *description,struct udp_socket *sock);
Index: ssl.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/ssl.c,v
retrieving revision 1.32
ssl.c +3 -3
@@ -1284,7 +1284,7 @@ || (packet_id_close_to_wrapping (&ks->packet_id.send)))) {msg (D_TLS_DEBUG_LOW ,"TLS: soft reset sec=%d bytes=%d/%d pkts=%d/%d" , - (int ) ks->established + session->opt->renegotiate_seconds - current, + (int )(ks->established + session->opt->renegotiate_seconds - current), ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session, current);
@@ -1732,7 +1732,7 @@* Errors are fatal if they are of these types. */ static inline bool -local_sock_fatal () +local_sock_fatal (void ) {return errno ==ENOTCONN || errno ==ECONNREFUSED ; }
@@ -2487,7 +2487,7 @@if (!buf_read (&buf, &l,sizeof (l))) goto done; l =ntohpid (l); -buf_printf (&out," pid=" packet_id_format, l); +buf_printf (&out," pid=" packet_id_format, (packet_id_print_type )l); } print_data:
Index: ssl.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/ssl.h,v
retrieving revision 1.11
ssl.h +3 -3
@@ -331,8 +331,8 @@struct tls_session session[TM_SIZE ]; }; -void init_ssl_lib (); -void free_ssl_lib (); +void init_ssl_lib (void ); +void free_ssl_lib (void );/* Build master SSL_CTX object that serves for the whole of openvpn instantiation */ SSL_CTX *init_ssl (bool server,
@@ -366,7 +366,7 @@void tls_post_encrypt (struct tls_multi *multi,struct buffer *buf); -void show_available_tls_ciphers (); +void show_available_tls_ciphers (void );void get_highest_preference_tls_cipher (char *buf,int size);int pem_password_callback (char *buf,int size,int rwflag,void *u);
Index: syshead.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/syshead.h,v
retrieving revision 1.16
syshead.h +2 -2
@@ -134,7 +134,7 @@#endif #ifdef HAVE_ARPA_INET_H -#ifndef TARGET_OPENBSD +#if !defined(TARGET_OPENBSD ) && !defined(__LCLINT__)#include <arpa/inet.h> #endif #endif
@@ -145,7 +145,7 @@#ifdef TARGET_LINUX -#ifdef HAVE_NETINET_IF_ETHER_H +#if defined(HAVE_NETINET_IF_ETHER_H ) && !defined(__LCLINT__)#include <netinet/if_ether.h> #endif
Index: thread.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/thread.c,v
retrieving revision 1.5
thread.c +4 -4
@@ -45,7 +45,7 @@static void ssl_pthreads_locking_callback (int mode,int type,char *file,int line) { -msg (D_OPENSSL_LOCK ,"SSL LOCK thread=%4d mode=%s lock=%s %s:%d" , +msg (D_OPENSSL_LOCK ,"SSL LOCK thread=%4lu mode=%s lock=%s %s:%d" ,CRYPTO_thread_id (), (mode &CRYPTO_LOCK ) ?"l" :"u" , (type &CRYPTO_READ ) ?"r" :"w" , file, line);
@@ -83,8 +83,8 @@pthread_mutex_init (&(ssl_lock_cs[i]),NULL ); } -CRYPTO_set_id_callback ((unsigned long (*)()) ssl_pthreads_thread_id); -CRYPTO_set_locking_callback ((void (*)()) ssl_pthreads_locking_callback); +CRYPTO_set_id_callback ((unsigned long (*)(void )) ssl_pthreads_thread_id); +CRYPTO_set_locking_callback ((void (*)(int ,int ,const char *,int )) ssl_pthreads_locking_callback); } static void
@@ -113,7 +113,7 @@ASSERT (x_main_thread_id);ASSERT (!x_work_thread_id);ASSERT (!pthread_create (&x_work_thread_id,NULL , start_routine, arg)); -msg (D_THREAD_DEBUG ,"CREATE THREAD ID=%d" , x_work_thread_id); +msg (D_THREAD_DEBUG ,"CREATE THREAD ID=%lu" , (unsigned long )x_work_thread_id); }void
Index: thread.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/thread.h,v
retrieving revision 1.5
thread.h +4 -4
@@ -58,7 +58,7 @@#define MUTEX_UNLOCK (lock) pthread_mutex_unlock (&lock)static inline int -thread_number () +thread_number (void ) {return (!x_main_thread_id ||pthread_self () == x_main_thread_id) ?MAIN_THREAD :WORK_THREAD ; }
@@ -100,11 +100,11 @@ } } -void thread_init (); -void thread_cleanup (); +void thread_init (void ); +void thread_cleanup (void );void work_thread_create (void *(*start_routine) (void *),void * arg); -void work_thread_join (); +void work_thread_join (void );#else /* USE_PTHREAD */
Index: tun.c
===================================================================
RCS file: /cvsroot/openvpn/openvpn/tun.c,v
retrieving revision 1.28
tun.c +1 -1
@@ -417,7 +417,7 @@int fd;if ((fd =socket (PF_INET ,SOCK_DGRAM ,0 )) <0 ) -msg (M_WARN ,"Cannot open control_fd" , dev); +msg (M_WARN ,"Cannot open control_fd" );else {strncpynt (r.ifr_name, tt->actual,IFNAMSIZ );
Index: tun.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/tun.h,v
retrieving revision 1.20
tun.h +1 -1
@@ -88,7 +88,7 @@#define IFCONFIG_DEFAULT 1static inline int -ifconfig_order () +ifconfig_order (void ) {#if defined(TARGET_LINUX )return IFCONFIG_AFTER_TUN_OPEN ;
Signature · 1 line
Matthias Andree
Quoted 8 lines · Matthias Andree
Quoted 1 line
http://openvpn.sourceforge.net/beta/openvpn-1.3.2.21.tar.gz (or CVS)
I have a next round of patches to fix prototypes and types to quench compiler warnings and get a more robust source code against changed environments, to aid possible later debugging; it also includes GCC extensions (only used when GCC is being used) that allow stricter
msg()andbuf_printf()format string vs. argument checking, to avoid printing bogus data when type sizes differ (think 64 bit).
Yes, very good ideas. I will merge.
Quoted 4 lines
One problem remains after applying the patch:
openvpn.c: In function `openvpn':
openvpn.c:470: warning: cast discards qualifiers from pointer target type
That's a tricky matter, because the struct options object is const, but it needs to be passed to a thread, and normally you need to cast something to a void* if you want to pass it to a thread as an argument, which then causes the constness to be lost.
Quoted 3 lines
Other than that, we have unused parameter warnings (you said before you're not fixing them), shadow parameter warnings (variable names being the same as system functions, such as time or nice)
I'm not too worried about the shadow parameters. I think it's pretty obvious when something is being used as a variable vs. a function call.
As for the unused parms, they are mostly a result of conditional compilation making certain variables unnecessary. OpenVPN has a large conditional compilation state-space, so I'm not sure that it makes sense to try to eliminate all such warnings.
Quoted 7 lines
and in particular,
aggregate (struct) values in function calls and function returns, these are inefficient (as the compiler must toss the whole struct on the stack, which involves copy overhead), and some of them (buffer.cin particular) look pretty suspicious. Is there any C standard that guarantees that returning an auto struct works and copies the return value?
While I can't quote chapter and verse, being able to manipulate structures in a value context, such as returning them from functions or passing them on the stack, has been a part of C for ages, and for a long time compilers have tried very hard to optimize this usage as much as possible.
For example, when a function returns an automatic structure, most compilers will optimize this into a zero-copy operation, where the functions's references to the automatic structure go directly into a variable allocated by the caller for its return.
My attitude towards optimization has been to optimize the code across the critical path only, which is essentially the event loop in openvpn.c. Code outside the event loop (such as the SSL negotiation) does not need to be optimized with respect to CPU usage, because it is executed infrequently in relation to the main event loop and OpenSSL EVP crypto code.
Most of the expensive buffer.[ch] code is only executed on startup, shutdown, SIGHUP, or when the debug level is high.
[ patch deleted ]
James