Added environment variable for IPv6 route metric.
PATCH 1/1 Added environment variable for IPv6 route metric.
--- doc/man-sections/script-options.rst | 4 ++-- src/openvpn/route.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-)
doc/man-sections/script-options.rst +2 -2
@@ -710,10 +710,10 @@ instances. A set of variables which define each IPv6 route to be added, and are set prior to **--up** script execution. - ``parm`` will be one of :code:`network` or :code:`gateway` + ``parm`` will be one of :code:`network`, :code:`gateway` (:code:`netmask` is contained as :code:`/nnn` in the ``route_ipv6_network_{n}``, unlike IPv4 where it is passed in a - separate environment variable). + separate environment variable) or :code:`metric`. ``n`` is the OpenVPN route number, starting from 1.
src/openvpn/route.c +6 -0
@@ -1463,6 +1463,7 @@ setenv_route_ipv6(struct env_set *es, const struct route_ipv6 *r6, int i)struct buffer name1 =alloc_buf_gc (256 , &gc );struct buffer val =alloc_buf_gc (256 , &gc );struct buffer name2 =alloc_buf_gc (256 , &gc ); +struct buffer name3 =alloc_buf_gc (256 , &gc );buf_printf ( &name1,"route_ipv6_network_%d" , i ); buf_printf( &val, "%s/%d", print_in6_addr( r6->network, 0, &gc ),
@@ -1471,6 +1472,11 @@ setenv_route_ipv6(struct env_set *es, const struct route_ipv6 *r6, int i)buf_printf ( &name2,"route_ipv6_gateway_%d" , i );setenv_str ( es,BSTR (&name2),print_in6_addr ( r6->gateway,0 , &gc )); + +if (r6->flags &RT_METRIC_DEFINED ) { +buf_printf ( &name3,"route_ipv6_metric_%d" , i) ; +setenv_int ( es,BSTR (&name3), r6->metric); + } }gc_free (&gc); }
Signature · 1 line
2.26.2
Hi,
Quoted 11 lines · Jan Seeger
src/openvpn/route.c +1
-0@@ -1463,6 +1463,7 @@ setenv_route_ipv6(struct env_set *es, const struct route_ipv6 *r6, int i)struct buffer name1 =alloc_buf_gc (256 , &gc );struct buffer val =alloc_buf_gc (256 , &gc );struct buffer name2 =alloc_buf_gc (256 , &gc ); +struct buffer name3 =alloc_buf_gc (256 , &gc );buf_printf ( &name1,"route_ipv6_network_%d" , i ); buf_printf( &val, "%s/%d", print_in6_addr( r6->network, 0, &gc ),
src/openvpn/route.c setenv_route_ipv6(struct env_set *es, const struct route_ipv6 *r6, int i) · line 1479
Quoted 8 lines
src/openvpn/route.c +5
-0@@ -1471,6 +1472,11 @@ setenv_route_ipv6(struct env_set *es, const struct route_ipv6 *r6, int i)buf_printf ( &name2,"route_ipv6_gateway_%d" , i );setenv_str ( es,BSTR (&name2),print_in6_addr ( r6->gateway,0 , &gc )); + +if (r6->flags &RT_METRIC_DEFINED ) { +buf_printf ( &name3,"route_ipv6_metric_%d" , i) ; +setenv_int ( es,BSTR (&name3), r6->metric); + }
style guide demands "{" on a separate line, so
if (r6->flags & RT_METRIC_DEFINED)
{also, I'd move the allocation of "name3" into this block.
if (r6->flags & RT_METRIC_DEFINED)
{
struct buffer name3 = alloc_buf_gc( 256, &gc );
...(no need to allocate memory if this is never used - also, with our move towards C99, new code is encouraged to declare variables where first needed, not "at the top of the function")
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...PATCH 1/1 Added environment variable for IPv6 route metric.
Hello!
Thanks for your feedback. I've added the necessary changes.
Best regards,
Jan
PATCH 1/1 Added environment variable for IPv6 route metric.
--- doc/man-sections/script-options.rst | 4 ++-- src/openvpn/route.c | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
doc/man-sections/script-options.rst +2 -2
@@ -709,10 +709,10 @@ instances. A set of variables which define each IPv6 route to be added, and are set prior to **--up** script execution. - ``parm`` will be one of :code:`network` or :code:`gateway` + ``parm`` will be one of :code:`network`, :code:`gateway` (:code:`netmask` is contained as :code:`/nnn` in the ``route_ipv6_network_{n}``, unlike IPv4 where it is passed in a - separate environment variable). + separate environment variable) or :code:`metric`. ``n`` is the OpenVPN route number, starting from 1.
src/openvpn/route.c +7 -0
@@ -1479,6 +1479,13 @@ setenv_route_ipv6(struct env_set *es, const struct route_ipv6 *r6, int i)buf_printf ( &name2,"route_ipv6_gateway_%d" , i );setenv_str ( es,BSTR (&name2),print_in6_addr ( r6->gateway,0 , &gc )); + +if (r6->flags &RT_METRIC_DEFINED ) + { +struct buffer name3 =alloc_buf_gc (256 , &gc ); +buf_printf ( &name3,"route_ipv6_metric_%d" , i) ; +setenv_int ( es,BSTR (&name3), r6->metric); + } }gc_free (&gc); }
Signature · 1 line
2.26.2
doc/man-sections/script-options.rst instances. · line 715
Quoted 12 lines · Jan Seeger
doc/man-sections/script-options.rst +2
-2@@ -709,10 +709,10 @@ instances. A set of variables which define each IPv6 route to be added, and are set prior to **--up** script execution. - ``parm`` will be one of :code:`network` or :code:`gateway` + ``parm`` will be one of :code:`network`, :code:`gateway` (:code:`netmask` is contained as :code:`/nnn` in the ``route_ipv6_network_{n}``, unlike IPv4 where it is passed in a - separate environment variable). + separate environment variable) or :code:`metric`.
I would suggest to rewrite this slightly, to make it clearer. The () sentence should be incorporated as a normal sentence.
So the (text/plain) result will be something like:
param will be one of network, code or metric. The netmask is contained as /nnn in the route_ipv6_network_{n}, unlike IPv4 where it is passed in a separate environment variable.
Or maybe even (why do we highlight IPv4 differences so much?):
param will be one of network, code or metric. The netmask is not provided and is preserved as /nnn in the IPv6 range in route_ipv6_network_{n}.
(These examples needs the proper :code:value and ``value`` highlighting, removed here for clarity)
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc