On 28/04/13 16:32, Arne Schwabe wrote:
> ---
>  src/openvpn/init.c |   13 ++++++++++---
>  src/openvpn/tun.h  |   11 +++++++++++
>  2 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/src/openvpn/init.c b/src/openvpn/init.c
> index 979ba23..33725e2 100644
> --- a/src/openvpn/init.c
> +++ b/src/openvpn/init.c
> @@ -1428,7 +1428,14 @@ do_open_tun (struct context *c)
>                                               &gc);
>         do_ifconfig (c->c1.tuntap, guess, TUN_MTU_SIZE (&c->c2.frame), 
> c->c2.es);
>       }
> -
> +      
> +      /* possibly add routes */
> +      if (route_order() == ROUTE_BEFORE_TUN) {
> +        /* Ignore route_delay, would cause ROUTE_BEFORE_TUN to be ignored */
> +        do_route (&c->options, c->c1.route_list, c->c1.route_ipv6_list,
> +                  c->c1.tuntap, c->plugins, c->c2.es);
> +      }
> +      
>        /* open the tun device */
>        open_tun (c->options.dev, c->options.dev_type, c->options.dev_node,
>               c->c1.tuntap);
> @@ -1460,7 +1467,7 @@ do_open_tun (struct context *c)
>                  c->c2.es);
>  
>        /* possibly add routes */
> -      if (!c->options.route_delay_defined)
> +      if ((route_order() == ROUTE_AFTER_TUN) && 
> (!c->options.route_delay_defined))
>       do_route (&c->options, c->c1.route_list, c->c1.route_ipv6_list,
>                 c->c1.tuntap, c->plugins, c->c2.es);
>  
> @@ -1668,7 +1675,7 @@ do_up (struct context *c, bool pulled_options, unsigned 
> int option_types_found)
>  #endif
>  
>         /* if --route-delay was specified, start timer */
> -       if (c->options.route_delay_defined)
> +       if ((route_order() == ROUTE_AFTER_TUN) && 
> c->options.route_delay_defined)
>           {
>             event_timeout_init (&c->c2.route_wakeup, c->options.route_delay, 
> now);
>             event_timeout_init (&c->c2.route_wakeup_expire, 
> c->options.route_delay + c->options.route_delay_window, now);
> diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h
> index c3fc62e..63e4b5c 100644
> --- a/src/openvpn/tun.h
> +++ b/src/openvpn/tun.h
> @@ -297,6 +297,17 @@ ifconfig_order(void)
>  #endif
>  }
>  
> +#define ROUTE_BEFORE_TUN 0
> +#define ROUTE_AFTER_TUN 1
> +#define ROUTE_ORDER_DEFAULT ROUTE_AFTER_TUN
> +
> +static inline int
> +route_order(void)
> +{
> +    return ROUTE_ORDER_DEFAULT;
> +}

I remember we discussed this oddity a long time ago, but I acknowledge
this is the "coding style" used with ifconfig_order().  We could
probably solve this in a cleaner way avoiding calling a function to get
a constant returned (even though, I hope the compiler optimises this).

Other than that, I presume this is well tested code which has been a
part of the OpenVPN for Android for a while, and I otherwise think the
code looks sane.


-- 
kind regards,

David Sommerseth

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to