Skip to contentSkip to conversation

- (ticket #29) - Fix for --push-reset resetting --topology and --route-gateway

RFC David Sommerseth 3 participants 4 messages Jul 23, 2010 – Jul 30, 2010

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

In yesterdays developer meeting we discussed Trac ticket #29:
<https://community.openvpn.net/openvpn/ticket/29>

The issue is that when using --topology subnet together with
- --client-config-dir together with a client configuration using
- --push-reset, a little bit too much is removed from the PUSH_REPLY to the client.

Currently, the --push-reset feature will remove *all* options from the PUSH_REPLY. This will harm setup where --topology subnet is used, as this will implicit do a 'push "topology subnet"' and 'push "route-gateway X.X.X.X"' to the clients. When this push is removed via
- --push-reset, it will break the tunnel from function.

A working workaround now is to manually add the needed 'push' statements in the client configs after --push-reset have been added.

However, we did agree on that this is a misbehaviour and needs a fix. We discussed three scenarios, and would like some input on which solution might be most beneficial.

1) Adding a new configure option which "unpush" chosen elements This will make it possible to do, f.ex '--push-filter route' in ccd based client configs, which will remove only routes from the inherited main configuration.

Pro: Very flexible and do not lock certain OpenVPN options as immutable against a --push-reset

Cons: Adds complexity to those configuring OpenVPN and adds a parsing overhead to each option when preparing the PUSH_REPLY, to filter out selected --push statements.

2) Add a new immutable option list for PUSH_REPLY
Currently there are one list which contains all options to be pushed. This idea is to add a second list which will contain immutable options when preparing PUSH_REPLY. If --push-reset is used, this immutable option list will be pushed anyway.

Pro: No configuration changes is needed.

Cons: Makes the PUSH_REPLY generator a bit more complex, as it needs to parse two lists. Need to consider which options should be immutable and if they should always be immutable or not, depending on other used options.

3) Add a flag to the PUSH_REPLY list indicating if it is immutable This is a variant of suggestion 2), but uses only one list which is extended with an immutable boolean flag. The idea here is that when adding elements to the PUSH_REPLY list, it will be indicated if this option is immutable or not by a true/false value. When preparing the PUSH_REPLY, the elements which are flagged as non-immutable will be skipped if --push-reset is activated.

Pro: No configuration changes. Compared to suggestion 2), it simplifies the PUSH_REPLY function by just adding an if() statement, compared to parsing two separate lists.

Cons: All places calling push_option() needs to be adopted to the new immutable flag argument - or changed to use yet another function, push_option_immutable(), which will set the immutable flag. Need to consider which options should be immutable and if they should always be immutable or not, depending on other used options.

Does anyone see another solution which is better? Or which suggestion do you consider preferable?

kind regards,

David Sommerseth

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkxJTCwACgkQDC186MBRfro1ywCeKHXJJh20TaWwgpqCEaSm1iWf ql8AmwfcS5mOlZe/zWHZiVtqqutUH8Zz
=ByJh
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 3 lines · David Sommerseth

1) Adding a new configure option which "unpush" chosen elements
2) Add a new immutable option list for PUSH_REPLY
3) Add a flag to the PUSH_REPLY list indicating if it is immutable

..

Quoted 2 lines

Does anyone see another solution which is better? Or which suggestion do you consider preferable?

The problem in this particular case seems to be that push-reset is removing options that were added to the push list *implicitly* by other configuration directives.

Would it make sense to simply treat all implicitly added elements as immutable?

As for how to make elements immutable I prefer option 3, adding a flag to the existing data structure.

//Peter

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 8 lines · Peter Stuge
Quoted 3 lines · David Sommerseth

1) Adding a new configure option which "unpush" chosen elements
2) Add a new immutable option list for PUSH_REPLY
3) Add a flag to the PUSH_REPLY list indicating if it is immutable

..

Quoted 2 lines

Does anyone see another solution which is better? Or which suggestion do you consider preferable?

Quoted 6 lines

The problem in this particular case seems to be that push-reset is removing options that were added to the push list *implicitly* by other configuration directives.

Would it make sense to simply treat all implicitly added elements as immutable?

That is what we're looking into now. After having spent some time in the code today, this looks more and more like the obvious way how to solve it.

Quoted 2 lines

As for how to make elements immutable I prefer option 3, adding a flag to the existing data structure.

That makes sense for me too. And the developer who proposed two lists seems to have changed opinion as well after digging deeper.

Thank you for your input!

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkxJwTkACgkQDC186MBRfrrjdACfa2uj2F2kQJ+PpKFIHGn/rQsX FWEAoJU9dicfTqI6Lsep1vqvmHRNpf9H
=pGJd
-----END PGP SIGNATURE-----

#3 lore raw
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

3) Add a flag to the PUSH_REPLY list indicating if it is immutable

I cooked up a patch that would do that:
https://community.openvpn.net/openvpn/attachment/ticket/29/0001-Make-some-push-options-not-resetable-by-ccd-config.patch

Make some push options not resetable by ccd config

Fixes bug ticket 29
<https://community.openvpn.net/openvpn/ticket/29>

When client configuration has a 'push-reset' option, non-immutable global options will not be pushed to client.

Only options added after the *last* push-reset will be set immutable.

This way, if push-reset is given in ccd files and plugin returned list, only the configuration options from the plugin will be set immutable.

I tried the following scenarios (in topology subnet):
client with no ccd file and no options returned by connect_v2 plugin call -> OK
client with push-reset in ccd file and push reset in connect_v2 plugin call -> OK (only connect_v2 options are pushed to client) client with push-reset in ccd file and no push-reset in connect_v2 plugin call -> OK (only got options from ccd file and connect_v2) client with ccd file and options returned by connect_v2 plugin call (no push-reset in either case) -> OK (got global config + ccd file config + connect_v2 config)

I am not really happy with all those
last_option = mi->context.options.push_list.tail;
...
if (mi->context.options.push_reset){}

But this is the only way I can think off in order to make sure that the latest push-reset will take precedence.

Any comments are welcome.

Tks

chantra

Signature · 1 line
http://www.debuntu.org

From 05a33ce2a522e404d99b0815f4dca8eb914bd642 Mon Sep 17 00:00:00 2001
From: chantra <[email protected]...>
Date: Thu, 29 Jul 2010 10:14:26 +0200
Subject: [PATCH] Make some push options not resetable by ccd config

Fixes bug ticket 29
<https://community.openvpn.net/openvpn/ticket/29>

When client configuration has a 'push-reset' option, non-immutable global options will not be pushed to client.

Only options added after the *last* push-reset will be set immutable.

This way, if push-reset is given in ccd files and plugin returned list, only the configuration options from the plugin will be set immutable.

---
 helper.c   |    5 ++++
 multi.c    |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 options.c  |    3 +-
 options.h  |    1 +
 push.c     |    3 +-
 pushlist.h |    1 +
 6 files changed, 76 insertions(+), 3 deletions(-)
helper.c +5 -0
index a9d7fd9..44723b4 100644
@@ -256,11 +256,13 @@ helper_client_server (struct options *o)
 	      o->ifconfig_pool_netmask = o->server_netmask;
 		  
 	      push_option (o, print_opt_route_gateway (o->server_network + 1, &o->gc), M_USAGE);
+	      o->push_list.tail->immutable = true;
 	    }
 	  else
 	    ASSERT (0);
 
 	  push_option (o, print_opt_topology (topology, &o->gc), M_USAGE);
+	  o->push_list.tail->immutable = true;
 	}
       else if (dev == DEV_TYPE_TAP)
 	{
@@ -283,6 +285,7 @@ helper_client_server (struct options *o)
 	  o->ifconfig_pool_netmask = o->server_netmask;
 
 	  push_option (o, print_opt_route_gateway (o->server_network + 1, &o->gc), M_USAGE);
+	  o->push_list.tail->immutable = true;
 	}
       else
 	{
@@ -355,10 +358,12 @@ helper_client_server (struct options *o)
 	  ifconfig_pool_verify_range (M_USAGE, o->ifconfig_pool_start, o->ifconfig_pool_end);
 	  o->ifconfig_pool_netmask = o->server_bridge_netmask;
 	  push_option (o, print_opt_route_gateway (o->server_bridge_ip, &o->gc), M_USAGE);
+	  o->push_list.tail->immutable = true;
 	}
       else if (o->server_bridge_proxy_dhcp && !(o->server_flags & SF_NO_PUSH_ROUTE_GATEWAY))
 	{
 	  push_option (o, print_opt_route_gateway_dhcp (&o->gc), M_USAGE);
+	  o->push_list.tail->immutable = true;
 	}
     }
   else
multi.c +65 -1

139 lines not on this page · raw message

options.c +2 -1
index b78158e..20c5f60 100644
@@ -691,6 +691,7 @@ init_options (struct options *o, const bool init_gc)
   o->route_delay_window = 30;
   o->max_routes = MAX_ROUTES_DEFAULT;
   o->resolve_retry_seconds = RESOLV_RETRY_INFINITE;
+  o->push_reset = false;
 #ifdef ENABLE_OCC
   o->occ = true;
 #endif
@@ -4789,7 +4790,7 @@ add_option (struct options *options,
   else if (streq (p[0], "push-reset"))
     {
       VERIFY_PERMISSION (OPT_P_INSTANCE);
-      push_reset (options);
+      options->push_reset = true;
     }
   else if (streq (p[0], "ifconfig-pool") && p[1] && p[2])
     {
options.h +1 -0
index 240f3bb..4b1597f 100644
@@ -378,6 +378,7 @@ struct options
   in_addr_t server_bridge_pool_end;
 
   struct push_list push_list;
+  bool push_reset;
   bool ifconfig_pool_defined;
   in_addr_t ifconfig_pool_start;
   in_addr_t ifconfig_pool_end;
push.c +2 -1
index 1320bec..9d994a5 100644
@@ -183,7 +183,7 @@ send_push_reply (struct context *c)
 
   while (e)
     {
-      if (e->enable)
+      if (e->enable && (!c->options.push_reset || e->immutable))
 	{
 	  const int l = strlen (e->option);
 	  if (BLEN (&buf) + l >= safe_cap)
@@ -290,6 +290,7 @@ clone_push_list (struct options *o)
       while (e)
 	{
 	  push_option_ex (o, string_alloc (e->option, &o->gc), true, M_FATAL);
+	  o->push_list.tail->immutable = e->immutable;
 	  e = e->next;
 	}
     }
pushlist.h +1 -0
index b252676..11356dd 100644
@@ -30,6 +30,7 @@
 struct push_entry {
   struct push_entry *next;
   bool enable;
+  bool immutable;
   const char *option;
 };
 
Signature · 1 line
1.5.6.5