Fix non-C89 comments
PATCH 1/1 Fix non-C89 comments
Hi,
openvpn uses non-C89 //-style comments in two places. Patch to convert these to /* ... */ style comments attached.
Best
Signature · 1 line
Matthias Andree
proto.h +5 -5
@@ -66,15 +66,15 @@struct openvpn_arp {# define ARP_MAC_ADDR_TYPE 0x0001 -uint16_t mac_addr_type;// 0x0001 +uint16_t mac_addr_type;/* 0x0001 */ -uint16_t proto_addr_type;// 0x0800 -uint8_t mac_addr_size;// 0x06 -uint8_t proto_addr_size;// 0x04 +uint16_t proto_addr_type;/* 0x0800 */ +uint8_t mac_addr_size;/* 0x06 */ +uint8_t proto_addr_size;/* 0x04 */ # define ARP_REQUEST 0x0001# define ARP_REPLY 0x0002 -uint16_t arp_command;// 0x0001 for ARP request, 0x0002 for ARP reply +uint16_t arp_command;/* 0x0001 for ARP request, 0x0002 for ARP reply */ uint8_t mac_src[OPENVPN_ETH_ALEN ];in_addr_t ip_src;
route.c +1 -1
@@ -1694,7 +1694,7 @@if (netmask) { - *netmask =0xFFFFFF00 ;// FIXME -- get the real netmask of the adapter containing the default gateway + *netmask =0xFFFFFF00 ;/* FIXME -- get the real netmask of the adapter containing the default gateway */ }gc_free (&gc);
Sent this to James.
Did not apply.
My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alon
Quoted 23 lines · Matthias Andree
Hi,
openvpn uses non-C89 //-style comments in two places. Patch to convert these to /* ... */ style comments attached.
Best
--
Matthias Andree
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 5 lines · Alon Bar-Lev
Sent this to James.
Did not apply.My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alon
Perhaps the choice of version control system used for OpenVPN could deserve a second thought -- Mercurial or better Git might support such models or merge queues much better than Subversion does.
Signature · 1 line
Matthias Andree
Quoted 5 lines · Matthias Andree
Quoted 3 lines · Alon Bar-Lev
Sent this to James.
Did not apply.
Quoted 8 lines
Quoted 2 lines
My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alonPerhaps the choice of version control system used for OpenVPN could
deserve a second thought -- Mercurial or better Git might support such models or merge queues much better than Subversion does.
Nope.
subversion is the simplest one to use.
Alon.
Quoted 15 lines · Alon Bar-Lev
Quoted 5 lines · Matthias Andree
Quoted 3 lines · Alon Bar-Lev
Sent this to James.
Did not apply.Quoted 8 lines
Quoted 2 lines
My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alonPerhaps the choice of version control system used for OpenVPN could
deserve a second thought -- Mercurial or better Git might support such models or merge queues much better than Subversion does.
Quoted 4 lines
Nope.
subversion is the simplest one to use.Alon.
Luckily for us who find git a lot easier than svn, there is always git-svn ... even though it's slow to do the fetching, it's a lot more comfortable to use. But once the fetching is done, it's as quick as a SCM should be.
I really do not intend to start a flame war over what's best or not - respect that there are different opinions ... but I have used both svn and git, and I am of a complete different opinion regarding what is the simplest one.
kind regards,
David Sommerseth
Quoted 7 lines · Alon Bar-Lev
Quoted 4 lines
Perhaps the choice of version control system used for OpenVPN could
deserve a second thought -- Mercurial or better Git might support such models or merge queues much better than Subversion does.Nope.
subversion is the simplest one to use.
That's a moot point and depending on requirement no longer true (seems to me this assertion has always been untrue WRT Mercurial that prints helpful usage hints all along the way) -- let me state just three points where I find Mercurial (Hg) or GIT superior to SVN, and that the basic day-to-day operation is done with the usual set of checkout, diff, branch, merge, commit, log commands in either of the systems.
(1) selective (partial/interactive) commits of hunks (built-in with Git, try git commit -i or -p; for Mercurial, there's the record extension that ships with the tarball proper)
(2) "properties" (svn propedit ... eek) and
(3) cheap & fast & really lightweight tags and branches. No need to remember URLs and type three lines even for basic operations such as tagging or branching. SVN is lightweight on the server's repository database, but heavy on my fingers and local file system...
Further advocacy, comparisons, and tutorials are for other places of the Internet than this list; let me just point towards Mercurial + MQ, Git or StGit if you want patch queue handling.
Historical note: If you've last looked at an early Mercurial 0.X version (current is 1.1.X), or a Git version before 1.5 (current is beyond 1.6.1), you might want to know that lots of things have improved, particularly usability and documentation. Git has evolved into a real version control system that's usable.
Signature · 1 line
Matthias Andree
Quoted 11 lines · Matthias Andree
Quoted 5 lines · Alon Bar-Lev
Sent this to James.
Did not apply.My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alonPerhaps the choice of version control system used for OpenVPN could deserve a second thought -- Mercurial or better Git might support such models or merge queues much better than Subversion does.
I'm on top of this -- Alon's queue including Jos Vos's [PATCH] Fix non-C89 comments has been merged:
------------------------------------------------------------------------
r3899 | james | 2009-01-27 12:22:42 -0700 (Tue, 27 Jan 2009) | 2 lines Changed paths:
M /branches/BETA21/openvpn/proto.h
M /branches/BETA21/openvpn/route.c
Fixed some issues with C++ style comments that leaked into the code.
------------------------------------------------------------------------
r3900 | james | 2009-01-27 12:32:46 -0700 (Tue, 27 Jan 2009) | 2 lines Changed paths:
M /branches/BETA21/openvpn/error.c
M /branches/BETA21/openvpn/ntlm.c
M /branches/BETA21/openvpn/pkcs11.c
M /branches/BETA21/openvpn/win32.h
Fixed some compile-time warnings.
------------------------------------------------------------------------
r3901 | james | 2009-01-27 13:05:48 -0700 (Tue, 27 Jan 2009) | 2 lines Changed paths:
M /branches/BETA21/openvpn/configure.ac
Updated configure.ac to work on MinGW.
------------------------------------------------------------------------
r3902 | james | 2009-01-27 13:10:49 -0700 (Tue, 27 Jan 2009) | 2 lines Changed paths:
M /branches/BETA21/openvpn/common.h
Updated common.h types for _WIN64.
------------------------------------------------------------------------
r3903 | james | 2009-01-27 14:18:51 -0700 (Tue, 27 Jan 2009) | 3 lines Changed paths:
M /branches/BETA21/openvpn/ssl.c
Fixed issue involving an #ifdef in a macro reference that breaks early gcc compilers.
------------------------------------------------------------------------
James
[Openvpn-devel] OVPN patching process RE: [PATCH] Fix non-C89 comments
In reply to Alon Bar-LevHi!
I sent a patch recently to the openvpn-devel list and got no reply whatsoever. Did I miss something ? Is there a procedure that I did not follow ?
That patch is to fix a longstanding bug that users encountered.
Regards,
David
PS: the mail message in question is :
Fix for "Cannot read current default gateway" problem on Linux
http://article.gmane.org/gmane.network.openvpn.devel/2472
Quoted 52 lines
-----Original Message-----
From: Alon Bar-Lev [mailto:[email protected]...]
Sent: Tuesday, January 27, 2009 5:32 PM
To: [email protected]
Subject: Re: [Openvpn-devel] [PATCH] Fix non-C89 commentsSent this to James.
Did not apply.My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alonQuoted 3 lines · Matthias Andree
Hi,
openvpn uses non-C89 //-style comments in two places.
Patch to convert
Quoted 9 lines
these to /* ... */ style comments attached.
Best
--
Matthias Andree
--------------------------------------------------------------
----------------Quoted 11 lines
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel--------------------------------------------------------------
----------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] OVPN patching process RE: [PATCH] Fix non-C89 comments
Quoted 5 lines · David Balazic
Hi!
I sent a patch recently to the openvpn-devel list and got no reply whatsoever. Did I miss something ? Is there a procedure that I did not follow ?
From what I've heard from other sources as well, this is usually the normal procedure ... pop the patch to this mailing list .... and watch if something happens ... or not .... you might get a response, and you might not. Who knows ...
kind regards,
David Sommerseth
Quoted 68 lines
That patch is to fix a longstanding bug that users encountered.
Regards,
DavidPS: the mail message in question is :
Fix for "Cannot read current default gateway" problem on Linux
http://article.gmane.org/gmane.network.openvpn.devel/2472Quoted 38 lines
-----Original Message-----
From: Alon Bar-Lev [mailto:[email protected]...] Sent: Tuesday, January 27, 2009 5:32 PM
To: [email protected]
Subject: Re: [Openvpn-devel] [PATCH] Fix non-C89 commentsSent this to James.
Did not apply.My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alonQuoted 3 lines · Matthias Andree
Hi,
openvpn uses non-C89 //-style comments in two places.
Patch to convert
Quoted 9 lines
these to /* ... */ style comments attached.
Best
--
Matthias Andree
--------------------------------------------------------------
----------------Quoted 11 lines
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-develQuoted 11 lines
--------------------------------------------------------------
----------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] OVPN patching process RE: [PATCH] Fix non-C89 comments
Quoted 4 lines · David Sommerseth
From what I've heard from other sources as well, this is usually the normal procedure ... pop the patch to this mailing list .... and watch if something happens ... or not .... you might get a response, and you might not. Who knows ...
It is a good summary of the management of openvpn. Hopefully it's not a program that deals with security, otherwise we would be worried...
Signature · 1 line
Thomas
Re: [Openvpn-devel] OVPN patching process RE: [PATCH] Fix non-C89 comments
In reply to David BalazicQuoted 5 lines · David Balazic
Hi!
I sent a patch recently to the openvpn-devel list and got no reply whatsoever. Did I miss something ? Is there a procedure that I did not follow ?
Send the patch again.
At the subject specify [PATCH]
Place the patch inline, be sure your mail client does not remove tabs, by sending the message first to your-self and try to apply it.
Alon.
Re: [Openvpn-devel] OVPN patching process RE: [PATCH] Fix non-C89 comments
In reply to David BalazicDavid,
A couple issues with the patch:
* sscanf usage doesn't check for buffer overflow.
* You use gw_if_name in some places and gw_ifname in other places. To eliminate confusion it would be best to use a consistent form.
Also, to reiterate, try submitting the patch as an attachment to deal with email client munging issues.
Thanks,
James
Quoted 74 lines · David Balazic
Hi!
I sent a patch recently to the openvpn-devel list and got no reply whatsoever. Did I miss something ? Is there a procedure that I did not follow ?
That patch is to fix a longstanding bug that users encountered.
Regards,
DavidPS: the mail message in question is :
Fix for "Cannot read current default gateway" problem on Linux
http://article.gmane.org/gmane.network.openvpn.devel/2472Quoted 38 lines
-----Original Message-----
From: Alon Bar-Lev [mailto:[email protected]...] Sent: Tuesday, January 27, 2009 5:32 PM
To: [email protected]
Subject: Re: [Openvpn-devel] [PATCH] Fix non-C89 commentsSent this to James.
Did not apply.My queue is at:
http://svn.openvpn.net/projects/openvpn/contrib/alonQuoted 3 lines · Matthias Andree
Hi,
openvpn uses non-C89 //-style comments in two places.
Patch to convert
Quoted 9 lines
these to /* ... */ style comments attached.
Best
--
Matthias Andree
--------------------------------------------------------------
----------------Quoted 11 lines
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-develQuoted 11 lines
--------------------------------------------------------------
----------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix for "Cannot read current defaultgateway" problem on Linux
Quoted 5 lines · James Yonan
David,
A couple issues with the patch:
* sscanf usage doesn't check for buffer overflow.
See below.
Quoted 3 lines
* You use
gw_if_namein some places andgw_ifnamein other places. To
eliminate confusion it would be best to use a consistent form.
Done.
Quoted 2 lines
Also, to reiterate, try submitting the patch as an attachment to deal with email client munging issues.
OK.
About the sscanf:
(copied from my earlier message to Alon)
Quoted 2 lines
3. Please don't use scanf this way as it may overflow the buffer. Use %##s and check that overflow is avoided.
I use "%32s\t" now.
How do I check for overflow? sscanf always returns 1. Besides, the linux kernel headers declare 32 as maximum iface name length.
Even in case of overflow, what shoudl I do ? Return false ? I think leaving it as is is good for 99,999% of cases and in the rest (in case of overflow), either a gateway IP address is present, so no problem, or the route add command will fail (or use the wrong device). Not perfect, but what is in these days ? ;-)
Oh, my patch removes spaces at the end of some lines. My editor did this automatically. Is that a problem ? I thought to remove it from the patch, but then the next guy to edit it will have the same problem.
The patch is attached.
Regards,
David
route.c +50 -31
@@ -214,7 +214,7 @@ { goto fail; } - +if (!get_special_addr (spec, ro->network, &r->network, &status)) { r->network = getaddr (
@@ -371,7 +371,7 @@ rl->spec.default_metric_defined = true; } - rl->spec.net_gateway_defined =get_default_gateway (&rl->spec.net_gateway,NULL ); + rl->spec.net_gateway_defined =get_default_gateway (&rl->spec.net_gateway,NULL , rl->spec.net_gateway_ifname);if (rl->spec.net_gateway_defined) {setenv_route_addr (es,"net_gateway" , rl->spec.net_gateway,-1 );
@@ -440,6 +440,7 @@ add_route3 (in_addr_t network, in_addr_t netmask, in_addr_t gateway, + char * gateway_ifname, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
@@ -450,6 +451,7 @@ r.network = network; r.netmask = netmask; r.gateway = gateway; + r.gateway_ifname = gateway_ifname;add_route (&r, tt, flags, es); }
@@ -473,6 +475,7 @@static void add_bypass_routes (struct route_bypass *rb,in_addr_t gateway, +char * gateway_ifname,const struct tuntap *tt,unsigned int flags,const struct env_set *es)
@@ -484,6 +487,7 @@add_route3 (rb->bypass[i], ~0 , gateway, + gateway_ifname, tt, flags, es);
@@ -536,12 +540,13 @@add_route3 (rl->spec.remote_host, ~0 , rl->spec.net_gateway, + rl->spec.net_gateway_ifname, tt, flags, es);/* route DHCP/DNS server traffic through original default gateway */ -add_bypass_routes (&rl->spec.bypass, rl->spec.net_gateway, tt, flags, es); +add_bypass_routes (&rl->spec.bypass, rl->spec.net_gateway, rl->spec.net_gateway_ifname, tt, flags, es);if (rl->flags &RG_DEF1 ) {
@@ -549,6 +554,7 @@add_route3 (0x00000000 ,0x80000000 , rl->spec.remote_endpoint, +NULL , tt, flags, es);
@@ -557,6 +563,7 @@add_route3 (0x80000000 ,0x80000000 , rl->spec.remote_endpoint, +NULL , tt, flags, es);
@@ -575,6 +582,7 @@add_route3 (0 ,0 , rl->spec.remote_endpoint, +NULL , tt, flags, es);
@@ -635,6 +643,7 @@add_route3 (0 ,0 , rl->spec.net_gateway, + rl->spec.net_gateway_ifname, tt, flags, es);
@@ -662,7 +671,7 @@ 0); }#endif - +for (i =0 ; i < rl->n; ++i) {struct route *r = &rl->routes[i];
@@ -805,20 +814,26 @@#if defined(TARGET_LINUX )#ifdef CONFIG_FEATURE_IPROUTE -argv_printf (&argv,"%s route add %s/%d via %s" , +argv_printf (&argv,"%s route add %s/%d" , iproute_path, network, -count_netmask_bits (netmask), - gateway); +count_netmask_bits (netmask)); +if (r->gateway) +argv_printf_cat (&argv,"via %s" , gateway); +else +argv_printf_cat (&argv,"dev %s" , r->gateway_ifname);if (r->metric_defined)argv_printf_cat (&argv,"metric %d" , r->metric);#else -argv_printf (&argv,"%s add -net %s netmask %s gw %s" , +argv_printf (&argv,"%s add -net %s netmask %s" ,ROUTE_PATH , network, - netmask, - gateway); + netmask); +if (r->gateway) +argv_printf_cat (&argv,"gw %s" , gateway); +else +argv_printf_cat (&argv,"dev %s" , r->gateway_ifname);if (r->metric_defined)argv_printf_cat (&argv,"metric %d" , r->metric);#endif /*CONFIG_FEATURE_IPROUTE*/
@@ -1006,7 +1021,7 @@openvpn_execve_check (&argv, es,0 ,"ERROR: Linux route delete command failed" );#elif defined (WIN32 ) - + argv_printf (&argv, "%s%sc DELETE %s MASK %s %s", get_win_sys_path(), WIN_ROUTE_PATH_SUFFIX,
@@ -1253,7 +1268,7 @@ }bool -get_default_gateway (in_addr_t *gw,in_addr_t *netmask) +get_default_gateway (in_addr_t *gw,in_addr_t *netmask,char *gw_ifname) {struct gc_arena gc =gc_new ();bool ret_bool = false;
@@ -1328,7 +1343,7 @@struct gc_arena gc =gc_new ();bool ret = false;DWORD status; -const DWORD if_index =windows_route_find_if_index (r, tt); +const DWORD if_index =windows_route_find_if_index (r, tt);if (if_index != ~0 ) {
@@ -1432,7 +1447,7 @@ format_route_entry (const MIB_IPFORWARDROW *r, struct gc_arena *gc) { struct buffer out = alloc_buf_gc (256, gc); - buf_printf (&out, "%s %s %s p=%d i=%d t=%d pr=%d a=%d h=%d m=%d/%d/%d/%d/%d", + buf_printf (&out, "%s %s %s p=%d i=%d t=%d pr=%d a=%d h=%d m=%d/%d/%d/%d/%d", print_in_addr_t (r->dwForwardDest, IA_NET_ORDER, gc), print_in_addr_t (r->dwForwardMask, IA_NET_ORDER, gc), print_in_addr_t (r->dwForwardNextHop, IA_NET_ORDER, gc),
@@ -1475,7 +1490,7 @@#elif defined(TARGET_LINUX )bool -get_default_gateway (in_addr_t *gateway,in_addr_t *netmask) +get_default_gateway (in_addr_t *gateway,in_addr_t *netmask,char *gw_ifname) {struct gc_arena gc =gc_new ();bool ret = false;
@@ -1516,6 +1531,10 @@if (!net && !mask && metric < lowest_metric) { best_gw = gw; +if (gw_ifname) + { +sscanf (line,"%" IFNAME_MAXLEN_STR "s\t" , gw_ifname); + } lowest_metric = metric; best_count = count; }
@@ -1525,7 +1544,7 @@ }fclose (fp); -if (best_gw) +if (best_count) { *gateway = best_gw;if (netmask)
@@ -1607,12 +1626,12 @@ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))bool -get_default_gateway (in_addr_t *ret,in_addr_t *netmask) +get_default_gateway (in_addr_t *ret,in_addr_t *netmask,char *gw_ifname) {struct gc_arena gc =gc_new ();int s, seq, l, pid, rtm_addrs, i;struct sockaddr so_dst, so_mask; -char *cp = m_rtmsg.m_space; +char *cp = m_rtmsg.m_space;struct sockaddr *gate =NULL , *sa;struct rt_msghdr *rtm_aux;
@@ -1637,7 +1656,7 @@ rtm.rtm_flags =RTF_UP |RTF_GATEWAY ; rtm.rtm_version =RTM_VERSION ; rtm.rtm_seq = ++seq; - rtm.rtm_addrs = rtm_addrs; + rtm.rtm_addrs = rtm_addrs; so_dst.sa_family =AF_INET ; so_dst.sa_len =sizeof (struct sockaddr_in );
@@ -1662,7 +1681,7 @@do { l =read (s, (char *)&m_rtmsg,sizeof (m_rtmsg)); }while (l >0 && (rtm.rtm_seq != seq || rtm.rtm_pid != pid)); - +close (s); rtm_aux = &rtm;
@@ -1769,12 +1788,12 @@ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))bool -get_default_gateway (in_addr_t *ret,in_addr_t *netmask) +get_default_gateway (in_addr_t *ret,in_addr_t *netmask,char *gw_ifname) {struct gc_arena gc =gc_new ();int s, seq, l, pid, rtm_addrs, i;struct sockaddr so_dst, so_mask; -char *cp = m_rtmsg.m_space; +char *cp = m_rtmsg.m_space;struct sockaddr *gate =NULL , *sa;struct rt_msghdr *rtm_aux;
@@ -1799,7 +1818,7 @@ rtm.rtm_flags =RTF_UP |RTF_GATEWAY ; rtm.rtm_version =RTM_VERSION ; rtm.rtm_seq = ++seq; - rtm.rtm_addrs = rtm_addrs; + rtm.rtm_addrs = rtm_addrs; so_dst.sa_family =AF_INET ; so_dst.sa_len =sizeof (struct sockaddr_in );
@@ -1824,7 +1843,7 @@do { l =read (s, (char *)&m_rtmsg,sizeof (m_rtmsg)); }while (l >0 && (rtm.rtm_seq != seq || rtm.rtm_pid != pid)); - +close (s); rtm_aux = &rtm;
@@ -1930,13 +1949,13 @@ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))bool -get_default_gateway (in_addr_t *ret,in_addr_t *netmask) +get_default_gateway (in_addr_t *ret,in_addr_t *netmask,char *gw_ifname) {struct gc_arena gc =gc_new ();int s, seq, l, rtm_addrs, i;pid_t pid;struct sockaddr so_dst, so_mask; -char *cp = m_rtmsg.m_space; +char *cp = m_rtmsg.m_space;struct sockaddr *gate =NULL , *sa;struct rt_msghdr *rtm_aux;
@@ -1961,7 +1980,7 @@ rtm.rtm_flags =RTF_UP |RTF_GATEWAY ; rtm.rtm_version =RTM_VERSION ; rtm.rtm_seq = ++seq; - rtm.rtm_addrs = rtm_addrs; + rtm.rtm_addrs = rtm_addrs; so_dst.sa_family =AF_INET ; so_dst.sa_len =sizeof (struct sockaddr_in );
@@ -1986,7 +2005,7 @@do { l =read (s, (char *)&m_rtmsg,sizeof (m_rtmsg)); }while (l >0 && (rtm.rtm_seq != seq || rtm.rtm_pid != pid)); - +close (s); rtm_aux = &rtm;
@@ -2034,7 +2053,7 @@#else bool -get_default_gateway (in_addr_t *ret,in_addr_t *netmask) +get_default_gateway (in_addr_t *ret,in_addr_t *netmask,char *gw_ifname) {return false; }
@@ -2152,7 +2171,7 @@in_addr_t gwip =0 ;bool ret = false; -if (!get_default_gateway (&gwip,NULL )) +if (!get_default_gateway (&gwip,NULL ,NULL )) {msg (M_WARN ,"GDGMA: get_default_gateway failed" ); goto err;
@@ -2249,7 +2268,7 @@DWORD a_index;const IP_ADAPTER_INFO *ai; -if (!get_default_gateway (&gwip,NULL )) +if (!get_default_gateway (&gwip,NULL ,NULL )) {msg (M_WARN ,"GDGMA: get_default_gateway failed" ); goto err;
route.h +6 -1
@@ -49,6 +49,9 @@*/ #define ROUTE_DELETE_FIRST 4 +#define IFNAME_MAXLEN 32 +#define IFNAME_MAXLEN_STR "32" +struct route_bypass {# define N_ROUTE_BYPASS 8
@@ -61,6 +64,7 @@in_addr_t remote_endpoint;bool remote_endpoint_defined;in_addr_t net_gateway; +char net_gateway_ifname[IFNAME_MAXLEN ];bool net_gateway_defined;in_addr_t remote_host;bool remote_host_defined;
@@ -95,6 +99,7 @@in_addr_t network;in_addr_t netmask;in_addr_t gateway; +char * gateway_ifname;bool metric_defined;int metric; };
@@ -156,7 +161,7 @@bool is_special_addr (const char *addr_str); -bool get_default_gateway (in_addr_t *ip,in_addr_t *netmask); +bool get_default_gateway (in_addr_t *ip,in_addr_t *netmask,char *gw_ifname);#if AUTO_USERID bool get_default_gateway_mac_addr (unsigned char *macaddr);
tun.c +2 -2
@@ -274,7 +274,7 @@in_addr_t lan_gw =0 ;in_addr_t lan_netmask =0 ; -if (get_default_gateway (&lan_gw, &lan_netmask)) +if (get_default_gateway (&lan_gw, &lan_netmask,NULL )) {const in_addr_t lan_network = lan_gw & lan_netmask;const in_addr_t network = ip & netmask;
@@ -301,7 +301,7 @@in_addr_t lan_gw =0 ;in_addr_t lan_netmask =0 ; -if (get_default_gateway (&lan_gw, &lan_netmask)) +if (get_default_gateway (&lan_gw, &lan_netmask,NULL )) {const in_addr_t lan_network = lan_gw & lan_netmask;if (lan_network ==0xC0A80000 || lan_network ==0xC0A80100 )
Re: [Openvpn-devel] [PATCH] Fix for "Cannot read current defaultgateway" problem on Linux
James,
I guess you take over.
There are many lines that does not change anything.
Also, maybe it would be better to have one string variable and one type, (gateway, device) (gateway, address), so that it would be easier to manage if new type comes up.
Alon.
Quoted 49 lines · David Balazic
Quoted 5 lines · James Yonan
David,
A couple issues with the patch:
* sscanf usage doesn't check for buffer overflow.
See below.
Quoted 3 lines
* You use
gw_if_namein some places andgw_ifnamein other places. To
eliminate confusion it would be best to use a consistent form.Done.
Quoted 2 lines
Also, to reiterate, try submitting the patch as an attachment to deal with email client munging issues.
OK.
About the sscanf:
(copied from my earlier message to Alon)Quoted 2 lines
3. Please don't use scanf this way as it may overflow the buffer. Use %##s and check that overflow is avoided.
I use "%32s\t" now.
How do I check for overflow? sscanf always returns 1. Besides, the linux kernel headers declare 32 as maximum iface name length.
Even in case of overflow, what shoudl I do ? Return false ? I think leaving it as is is good for 99,999% of cases and in the rest (in case of overflow), either a gateway IP address is present, so no problem, or the route add command will fail (or use the wrong device). Not perfect, but what is in these days ? ;-)Oh, my patch removes spaces at the end of some lines. My editor did
this automatically. Is that a problem ? I thought to remove it from the patch, but then the next guy to edit it will have the same problem.The patch is attached.
Regards,
David
Re: [Openvpn-devel] [PATCH] Fix for "Cannot read current defaultgateway" problem on Linux
Ping ?
Should I resend the patch without the end-of-line-spaces change ?
Regards,
David
Quoted 73 lines
-----Original Message-----
From: Alon Bar-Lev [mailto:[email protected]...]
Sent: Tuesday, February 03, 2009 7:17 PM
To: David Balazic
Cc: James Yonan; [email protected]
Subject: Re: [PATCH] Fix for "Cannot read current defaultgateway" problem on LinuxJames,
I guess you take over.
There are many lines that does not change anything.
Also, maybe it would be better to have one string variable and one type, (gateway, device) (gateway, address), so that it would be easier to manage if new type comes up.Alon.
Quoted 8 lines · David Balazic
Quoted 5 lines · James Yonan
David,
A couple issues with the patch:
* sscanf usage doesn't check for buffer overflow.
Quoted 9 lines
See below.
Quoted 3 lines
* You use
gw_if_namein some places andgw_ifnamein other places. To
eliminate confusion it would be best to use a consistent form.Done.
Quoted 1 line
Also, to reiterate, try submitting the patch as an
attachment to deal
Quoted 10 lines
Quoted 1 line
with email client munging issues.
OK.
About the sscanf:
(copied from my earlier message to Alon)Quoted 2 lines
3. Please don't use scanf this way as it may overflow the buffer. Use %##s and check that overflow is avoided.
Quoted 6 lines
I use "%32s\t" now.
How do I check for overflow? sscanf always returns 1. Besides, the linux kernel headers declare 32 as maximum iface name length.
Even in case of overflow, what shoudl I do ? Return false ? I think leaving it as is is good for 99,999% of cases andin the rest
Quoted 1 line
(in case of overflow), either a gateway IP address is
present, so no
Quoted 1 line
problem, or the route add command will fail (or use the
wrong device).
Quoted 6 lines
Not perfect, but what is in these days ? ;-)
Oh, my patch removes spaces at the end of some lines. My editor did
this automatically. Is that a problem ? I thought to remove it from the patch, but then the next guy to edit it will have thesame problem.
Quoted 8 lines
The patch is attached.
Regards,
David
Re: [Openvpn-devel] [PATCH] Fix for "Cannot read current defaultgateway" problem on Linux
Quoted 3 lines · On Tuesday 10 February 2009 13:35:35 David Balazic wrote:
Ping ?
Should I resend the patch without the end-of-line-spaces change ?
James has his own response times.
I suggest you have much patience.... :)
Alon.
[Openvpn-devel] Patch Queue, was: Re: [PATCH] Fix for "Cannot read current defaultgateway" problem on Linux
Quoted 9 lines · Alon Bar-Lev
Quoted 3 lines · On Tuesday 10 February 2009 13:35:35 David Balazic wrote:
Ping ?
Should I resend the patch without the end-of-line-spaces change ?
James has his own response times.
I suggest you have much patience.... :)Alon.
I apologize for not having the bandwidth to focus as much on the patch queue as I would like, but please understand that we're on the verge of releasing 2.1 and we have to be very conservative about accepting patches at this point.
I think it's fair to ask that we try to limit ourselves at this late stage to patches that address issues that affect a large number of users, or bug fixes that are sufficiently trivial that there is little or no chance of causing unforeseen breakage. I think there needs to be an argument for why the patch is important right now, as opposed to waiting a while for the 2.2 beta series.
Remember that sometimes just posting a patch here on the list is an optimal solution even if it is not immediately merged into the mainline -- people that need it can always apply it, and this allows the patch to be tested more extensively before it is merged.
James
Re: [Openvpn-devel] Patch Queue, was: Re: [PATCH] Fix for "Cannot read current defaultgateway" problem on Linux
Quoted 2 lines · James Yonan
fixes that are sufficiently trivial that there is little or no chance of causing unforeseen breakage.
Please review the following ones [1][2] for windows compilation. Only renames.
Alon.
[1] http://www.opensc-project.org/build/browser/trunk/patches/openvpn-002-mingw.patch
[2] http://www.opensc-project.org/build/browser/trunk/patches/openvpn-003-windows.patch
Re: [Openvpn-devel] Patch Queue, was: Re: [PATCH] Fix for "Cannot read current defaultgateway" problem on Linux
In reply to James YonanQuoted 18 lines · James Yonan
Quoted 9 lines · Alon Bar-Lev
Quoted 3 lines · On Tuesday 10 February 2009 13:35:35 David Balazic wrote:
Ping ?
Should I resend the patch without the end-of-line-spaces change ?
James has his own response times.
I suggest you have much patience.... :)Alon.
I apologize for not having the bandwidth to focus as much on the patch
queue as I would like, but please understand that we're on the verge of
releasing 2.1 and we have to be very conservative about accepting patches at this point.
Quoted 8 lines
I think it's fair to ask that we try to limit ourselves at this late stage to patches that address issues that affect a large number of users, or bug fixes that are sufficiently trivial that there is little
or no chance of causing unforeseen breakage. I think there needs to be
an argument for why the patch is important right now, as opposed to waiting a while for the 2.2 beta series.
Of course.
- the bug has been reported in several instances (see my first mail)
- the patch affects only one architecture (besides the unused parameter
on others;
I could have made different function declarations for different archs, but that
would be less readable/maintainable IMO)
- the patch affects only one code path, that is taken only when the bug
is triggered
- it is simple:
- a few lines to record the gateway interface name
- a few lines to use it in case the gw addresss is 0.0.0.0
- it is field tested (in a scenario which triggers the bug)
Regards,
David