patch for bug #93: up-restart env vars
hi all,
here's my patch for bug #93: missing ifconfig_* env vars after up-restart. Tested with both IPv4, IPv6, topology subnet and topology net30
cheers,
JJK
src/openvpn/init.c +3 -0
@@ -1486,6 +1486,9 @@ do_open_tun (struct context *c)msg (M_INFO ,"Preserving previous TUN/TAP instance: %s" , c->c1.tuntap->actual_name); +/* explicitly set the ifconfig_* env vars */ +do_ifconfig_setenv (c->c1.tuntap, c->c2.es); +/* run the up script if user specified --up-restart */ if (c->options.up_restart) run_up_down (c->options.up_script,
src/openvpn/tun.c +45 -44
135 lines not on this page · raw message
src/openvpn/tun.h +3 -0
@@ -241,6 +241,9 @@ void init_tun_post (struct tuntap *tt,const struct frame *frame, const struct tuntap_options *options); +void do_ifconfig_setenv (const struct tuntap *tt, +struct env_set *es); + void do_ifconfig (struct tuntap *tt, const char *actual, /* actual device name */ int tun_mtu,
Hi,
Quoted 2 lines · Jan Just Keijser
here's my patch for bug #93: missing ifconfig_* env vars after up-restart. Tested with both IPv4, IPv6, topology subnet and topology net30
Reading through #93, I'm wondering - what about the other environment variables mentioned, like "route_gateway" etc.?
In other words, your patch looks like it will nicely fix the missing ifconfig_* variables (by ensuring that what close_instance() destroyed is re-initialized even if not calling init_tun() - and cleaning up that one a bit while at it :-) ), but I wonder if more needs to be done?
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi Gert,
Quoted 5 lines · Gert Doering
Hi,
Quoted 2 lines · Jan Just Keijser
here's my patch for bug #93: missing ifconfig_* env vars after up-restart. Tested with both IPv4, IPv6, topology subnet and topology net30
Quoted 8 lines
Reading through #93, I'm wondering - what about the other environment variables mentioned, like "
route_gateway" etc.?In other words, your patch looks like it will nicely fix the missing ifconfig_* variables (by ensuring that what
close_instance()destroyed is re-initialized even if not callinginit_tun()- and cleaning up that one a bit while at it :-) ), but I wonder if more needs to be done?
I did look into that - a 'restart' occurs only if 'persist-tun' is used and in that case the routes are not re-added . If you look at the flow of code of 'do_open_tun' in init.c you'll see that all routing stuff is *not* re-run, hence those environment variables are not present anymore - but then again, the routes are still there, as the system routing tables were not affected because the tun device was never closed in the first place.
My guestimation was that there are no other *important* env vars that get lost during a soft restart.
JJK
Hi,
Quoted 13 lines · Jan Just Keijser
Quoted 11 lines · Gert Doering
Quoted 3 lines · Jan Just Keijser
here's my patch for bug #93: missing ifconfig_* env vars after up-restart. Tested with both IPv4, IPv6, topology subnet and topology net30
Reading through #93, I'm wondering - what about the other environment variables mentioned, like "
route_gateway" etc.?In other words, your patch looks like it will nicely fix the missing ifconfig_* variables (by ensuring that what
close_instance()destroyed is re-initialized even if not callinginit_tun()- and cleaning up that one a bit while at it :-) ), but I wonder if more needs to be done?
Quoted 7 lines
I did look into that - a 'restart' occurs only if 'persist-tun' is used and in that case the routes are not re-added . If you look at the flow of code of '
do_open_tun' ininit.cyou'll see that all routing stuff is *not* re-run, hence those environment variables are not present anymore
- but then again, the routes are still there, as the system routing tables were not affected because the tun device was never closed in the first place.
OK, so these get lost, but are set elsewhere, and would need an extra patch...
Quoted 2 lines
My guestimation was that there are no other *important* env vars that get lost during a soft restart.
Well, what's important to some is not to others (I could care less about "ifconfig_local", as tun.c does that for me :-) )... this ticket is all about consistency, *or* documenting that --up-restart will not see the environment variables that --up has "because you do not need them"...
I'm not sure what the best path forward is, TBH...
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi,
Quoted 23 lines · Gert Doering
Quoted 12 lines · Jan Just Keijser
Quoted 11 lines · Gert Doering
Quoted 3 lines · Jan Just Keijser
here's my patch for bug #93: missing ifconfig_* env vars after up-restart. Tested with both IPv4, IPv6, topology subnet and topology net30
Reading through #93, I'm wondering - what about the other environment variables mentioned, like "
route_gateway" etc.?In other words, your patch looks like it will nicely fix the missing ifconfig_* variables (by ensuring that what
close_instance()destroyed is re-initialized even if not callinginit_tun()- and cleaning up that one a bit while at it :-) ), but I wonder if more needs to be done?Quoted 7 lines
I did look into that - a 'restart' occurs only if 'persist-tun' is used and in that case the routes are not re-added . If you look at the flow of code of '
do_open_tun' ininit.cyou'll see that all routing stuff is *not* re-run, hence those environment variables are not present anymore
- but then again, the routes are still there, as the system routing tables were not affected because the tun device was never closed in the first place.OK, so these get lost, but are set elsewhere, and would need an extra patch...
Quoted 9 lines
Quoted 2 lines
My guestimation was that there are no other *important* env vars that get lost during a soft restart.
Well, what's important to some is not to others (I could care less about "
ifconfig_local", astun.cdoes that for me :-) )... this ticket is all about consistency, *or* documenting that --up-restart will not see the environment variables that --up has "because you do not need them"...I'm not sure what the best path forward is, TBH...
--up-restart *is* different from --up in several ways:
- runs as the user+group that is specified in the config file
- the 'tun' device is persistent so it's not "fresh"
- routes are not reset during a "persistent" restart, so are still present
I agree that I am not sure that the best path forward is, but I think the route of "make sure everything looks the same as in --up script" is not the right way. The 'do_open_tun' flow of code could also be improved, by the way, but I did not want to do that for this bug report.
cheers,
JJK
Hi,
Quoted 7 lines · Jan Just Keijser
Quoted 1 line
I'm not sure what the best path forward is, TBH...
--up-restart *is* different from --up in several ways:
- runs as the user+group that is specified in the config file
- the 'tun' device is persistent so it's not "fresh"
- routes are not reset during a "persistent" restart, so are still present
- IP addresses are not reset (as the tun device is pesistent)
so indeed, lots of differences here.
What about this:
- take your patch as it is (because it's not very intrusive, provides variables people are asking for, and cleans up tun.c a bit :-) )
- add a patch to openvpn.8 that explains the differences in --up-restart (so people will know that the lack of route env vars is not a bug)
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Quoted 15 lines · Gert Doering
Hi,
Quoted 8 lines · Jan Just Keijser
Quoted 2 lines
I'm not sure what the best path forward is, TBH...
--up-restart *is* different from --up in several ways:
- runs as the user+group that is specified in the config file
- the 'tun' device is persistent so it's not "fresh"
- routes are not reset during a "persistent" restart, so are still present- IP addresses are not reset (as the tun device is pesistent)
Quoted 9 lines
so indeed, lots of differences here.
What about this:
- take your patch as it is (because it's not very intrusive, provides variables people are asking for, and cleans up
tun.ca bit :-) )
- add a patch to openvpn.8 that explains the differences in --up-restart (so people will know that the lack of route env vars is not a bug)
agreed, but do we patch openvpn.8 before or after the documentation split ;) ?
JJK
Hi,
Quoted 5 lines · Jan Just Keijser
Quoted 2 lines
- add a patch to openvpn.8 that explains the differences in --up-restart (so people will know that the lack of route env vars is not a bug)
agreed, but do we patch openvpn.8 before or after the documentation split ;) ?
Before, so we can close #93 and ship the change in 2.3.7 :-)
I'll send a doc patch tonight.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...PATCH 1/1 Document differences between --up-restart and --up in openvpn.8
In reply to Jan Just KeijserSee trac #93 and the discussion starting with <[email protected]...> on the openvpn-devel mailing list.
--- doc/openvpn.8 | 6 ++++++ 1 file changed, 6 insertions(+)
doc/openvpn.8 +6 -0
@@ -1817,6 +1817,12 @@ has been specified, the up script will be called with .I restart as the last parameter. +NOTE: on restart, OpenVPN will not pass the full set of environment +variables to the script. Namely, everything related to routing and +gateways will not be passed, as nothing needs to be done anyway - all +the routing setup is already in place. Additionally, the up\-restart +script will run with the downgraded UID/GID settings (if configured). + The following standalone example shows how the .B \-\-up script can be called in both an initialization and restart context.
Signature · 1 line
2.0.5
Re: [Openvpn-devel] [PATCH] Document differences between --up-restart and --up in openvpn.8
Quoted 15 lines · Gert Doering
See trac #93 and the discussion starting with <[email protected]...> on the openvpn-devel mailing list.
Signed-off-by Gert Doering <[email protected]...>--- doc/openvpn.8 | 6 ++++++ 1 file changed, 6 insertions(+)doc/openvpn.8 +0
-0@@ -1817,6 +1817,12 @@ has been specified, the up script will be called with .I restart as the last parameter.
doc/openvpn.8 has been specified, the up script will be called with · line 1828
Quoted 10 lines
doc/openvpn.8 +6
-0+NOTE: on restart, OpenVPN will not pass the full set of environment +variables to the script. Namely, everything related to routing and +gateways will not be passed, as nothing needs to be done anyway - all +the routing setup is already in place. Additionally, the up\-restart +script will run with the downgraded UID/GID settings (if configured). + The following standalone example shows how the .B \-\-up script can be called in both an initialization and restart context.
ACK
JJK
ACK.
Your patch has been applied to the master and release/2.3 branches.
I have taken a few liberties here - namely, merging the openvpn.8 patch into yours as it's sort sort of "one big change" anyway, and reformatting do_ifconfig_setenv() according to our new and improved coding style (it didn't follow the old one or the new one, and if I reformat it anyway, go for the new one). The code is unchanged, just indenting.
commit db950be85d37eab40d8fffe0bc2060059f8a7e10 (master) commit 30256bede8f7ef6c82f1c2ed0d9f6c2177002926 (release/2.3)
Author: Jan Just Keijser Date: Wed May 20 04:33:20 2015 +0200
patch for bug #93: up-restart env vars
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9705
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 1/1 repair --dev null breakage caused by db950be85d37
In reply to Jan Just Keijser"make check" self-test was broken after commit db950be85d37 due to do_ifconfig_setenv() not checking whether tt->did_ifconfig_setup was set (which isn't, for "dev null" type setups)
--- src/openvpn/tun.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
src/openvpn/tun.c +14 -10
@@ -403,23 +403,27 @@ void do_ifconfig_setenv (const struct tuntap *tt, struct env_set *es) { struct gc_arena gc = gc_new (); -bool tun =is_tun_p2p (tt);const char *ifconfig_local =print_in_addr_t (tt->local,0 , &gc);const char *ifconfig_remote_netmask =print_in_addr_t (tt->remote_netmask,0 , &gc);/* * Set environmental variables with ifconfig parameters. */ -setenv_str (es,"ifconfig_local" , ifconfig_local); -if (tun) +if (tt->did_ifconfig_setup) { -setenv_str (es,"ifconfig_remote" , ifconfig_remote_netmask); - } -else - { -const char *ifconfig_broadcast =print_in_addr_t (tt->broadcast,0 , &gc); -setenv_str (es,"ifconfig_netmask" , ifconfig_remote_netmask); -setenv_str (es,"ifconfig_broadcast" , ifconfig_broadcast); +bool tun =is_tun_p2p (tt); + +setenv_str (es,"ifconfig_local" , ifconfig_local); +if (tun) + { +setenv_str (es,"ifconfig_remote" , ifconfig_remote_netmask); + } +else + { +const char *ifconfig_broadcast =print_in_addr_t (tt->broadcast,0 , &gc); +setenv_str (es,"ifconfig_netmask" , ifconfig_remote_netmask); +setenv_str (es,"ifconfig_broadcast" , ifconfig_broadcast); + } }if (tt->did_ifconfig_ipv6_setup)
Signature · 1 line
2.3.6
Re: [Openvpn-devel] [PATCH] repair --dev null breakage caused by db950be85d37
ACK
Quoted 53 lines · Gert Doering
"make check" self-test was broken after commit
db950be85d37due todo_ifconfig_setenv()not checking whethertt->did_ifconfig_setupwas set (which isn't, for "dev null" type setups)Signed-off-by Gert Doering <[email protected]...>--- src/openvpn/tun.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)src/openvpn/tun.c +14
-11@@ -403,23 +403,27 @@ void do_ifconfig_setenv (const struct tuntap *tt, struct env_set *es) { struct gc_arena gc = gc_new (); -bool tun =is_tun_p2p (tt);const char *ifconfig_local =print_in_addr_t (tt->local,0 , &gc);const char *ifconfig_remote_netmask =print_in_addr_t (tt->remote_netmask,0 , &gc);/* * Set environmental variables with ifconfig parameters. */ -setenv_str (es,"ifconfig_local" , ifconfig_local); -if (tun) +if (tt->did_ifconfig_setup) { -setenv_str (es,"ifconfig_remote" , ifconfig_remote_netmask); - } -else - { -const char *ifconfig_broadcast =print_in_addr_t (tt->broadcast,0 , &gc); -setenv_str (es,"ifconfig_netmask" , ifconfig_remote_netmask); -setenv_str (es,"ifconfig_broadcast" , ifconfig_broadcast); +bool tun =is_tun_p2p (tt); + +setenv_str (es,"ifconfig_local" , ifconfig_local); +if (tun) + { +setenv_str (es,"ifconfig_remote" , ifconfig_remote_netmask); + } +else + { +const char *ifconfig_broadcast =print_in_addr_t (tt->broadcast,0 , &gc); +setenv_str (es,"ifconfig_netmask" , ifconfig_remote_netmask); +setenv_str (es,"ifconfig_broadcast" , ifconfig_broadcast); + } }if (tt->did_ifconfig_ipv6_setup) --2.3.6
Re: [Openvpn-devel] [PATCH] repair --dev null breakage caused by db950be85d37
In reply to Gert DoeringHi,
Quoted 3 lines · Gert Doering
"make check" self-test was broken after commit
db950be85d37due todo_ifconfig_setenv()not checking whethertt->did_ifconfig_setupwas set (which isn't, for "dev null" type setups)
Applied to master and release/2.3 branches. Tested with "make check".
commit 970c4bd2e473f625699bd56db44c1970a9e10ed9 (master) commit 7b285112d22f74c19dd5b1476ddbf1bd83339c84 (release/3.)
Author: Gert Doering <[email protected]...> Date: Sat May 23 19:35:05 2015 +0200
repair --dev null breakage caused by db950be85d37
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Steffan Karger <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9718gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...