From: "mrbff (Code Review)" Date: Thu, 21 Nov 2024 18:24:42 +0000 In-Reply-To: References: Reply-To: marco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <87cb438bf4acc2da4d734ad954fefbbfe782b3b3-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="+qH2bw4TTcA="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: PUSH_UPDATE: Added remove_option() and do_update(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --+qH2bw4TTcA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/809?usp=3Demail to look at the new patch set (#2). Change subject: PUSH_UPDATE: Added remove_option() and do_update(). ...................................................................... PUSH_UPDATE: Added remove_option() and do_update(). * Added remove_option() function and some utility functions to remove optio= ns at runtime following the push-update logic. * Added do_update() function to close and reopen the tun and apply option u= pdates. Change-Id: I507180d7397b6959844a30908010132bc3411067 Signed-off-by: Marco Baffo --- M src/openvpn/init.c M src/openvpn/init.h M src/openvpn/options.c M src/openvpn/push.c M src/openvpn/route.c M src/openvpn/route.h 6 files changed, 354 insertions(+), 32 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/09/809/2 diff --git a/src/openvpn/init.c b/src/openvpn/init.c index f8d9d06..b95a61a 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -2567,6 +2567,47 @@ return true; } +bool +do_update(struct context *c, unsigned int option_types_found) +{ + /* Not necessary since to receive the update the openvpn + * instance must be up and running but just in case + */ + if (!c->c2.do_up_ran) + { + return false; + } + + bool tt_dco_win =3D tuntap_is_dco_win(c->c1.tuntap); + if (tt_dco_win) + { + msg(M_NONFATAL, "dco-win doesn't yet support reopening TUN device"= ); + return false; + } + + if (!do_deferred_options(c, option_types_found)) + { + msg(D_PUSH_ERRORS, "ERROR: Failed to apply push options"); + return false; + } + + do_close_tun(c, true); + + management_sleep(1); + int error_flags =3D 0; + c->c2.did_open_tun =3D do_open_tun(c, &error_flags); + update_time(); + + if (c->c2.did_open_tun) + { + initialization_sequence_completed(c, error_flags); + } + + CLEAR(c->c1.pulled_options_digest_save); + + return true; +} + /* * These are the option categories which will be accepted by pull. */ diff --git a/src/openvpn/init.h b/src/openvpn/init.h index ea7eb30..3d0206e 100644 --- a/src/openvpn/init.h +++ b/src/openvpn/init.h @@ -86,6 +86,8 @@ bool pulled_options, unsigned int option_types_found); +bool do_update(struct context *c, unsigned int option_types_found); + unsigned int pull_permission_mask(const struct context *c); const char *format_common_name(struct context *c, struct gc_arena *gc); diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 8dea578..5b4419d 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -1055,6 +1055,40 @@ gc_free(&gc); } } + +static void +delete_all_dhcp_fo(struct options *o, struct env_item **list) +{ + struct env_item *current, *prev; + + ASSERT(list); + + for (current =3D *list, prev =3D NULL; current !=3D NULL; current =3D = current->next) + { + char *tmp_value =3D NULL; + if (!strncmp(current->string, "foreign_option_", sizeof("foreign_o= ption_")-1)) + { + tmp_value =3D strchr(current->string, '=3D'); + if (tmp_value && ++tmp_value) + { + if (!strncmp(tmp_value, "dhcp-option ", sizeof("dhcp-optio= n ")-1)) + { + if (prev) + { + prev->next =3D current->next; + } + else + { + *list =3D current->next; + } + o->foreign_option_index--; + } + } + } + prev =3D current; + } +} + #endif /* ifndef _WIN32 */ static in_addr_t @@ -3260,8 +3294,16 @@ msg(M_INFO, "Flag 'def1' added to --redirect-gateway (iservice is = in use)"); opt->routes->flags |=3D RG_DEF1; } + else if ((!opt->routes + || opt->route_method !=3D ROUTE_METHOD_SERVICE + || !(opt->routes->flags & RG_REROUTE_GW)) + && (opt->routes->flags & RG_DEF1)) + { + msg(M_INFO, "Flag 'def1' removed from --redirect-gateway"); + opt->routes->flags &=3D ~RG_DEF1; + } } -#endif +#endif /* ifdef _WIN32 */ /* * Save/Restore certain option defaults before --pull is applied. @@ -5452,37 +5494,6 @@ } } -void -options_server_import(struct options *o, - const char *filename, - int msglevel, - unsigned int permission_mask, - unsigned int *option_types_found, - struct env_set *es) -{ - msg(D_PUSH, "OPTIONS IMPORT: reading client specific options from: %s"= , filename); - read_config_file(o, - filename, - 0, - filename, - 0, - msglevel, - permission_mask, - option_types_found, - es); -} - -void -options_string_import(struct options *options, - const char *config, - const int msglevel, - const unsigned int permission_mask, - unsigned int *option_types_found, - struct env_set *es) -{ - read_config_string("[CONFIG-STRING]", options, config, msglevel, permi= ssion_mask, option_types_found, es); -} - #define VERIFY_PERMISSION(mask) { = \ if (!verify_permission(p[0], file, line, (mask), permission_mask, = \ option_types_found, msglevel, options, is_i= nline)) \ @@ -5585,6 +5596,169 @@ return options->forward_compatible ? M_WARN : msglevel; } +static void +remove_option(struct context *c, + struct options *options, + char *p[], + bool is_inline, + const char *file, + int line, + const int msglevel, + const unsigned int permission_mask, + unsigned int *option_types_found, + struct env_set *es) +{ + int msglevel_fc =3D msglevel_forward_compatible(options, msglevel); + + if (streq(p[0], "ifconfig") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_UP); + options->ifconfig_local =3D NULL; + options->ifconfig_remote_netmask =3D NULL; + } + else if (streq(p[0], "ifconfig-ipv6") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_UP); + options->ifconfig_ipv6_local =3D NULL; + options->ifconfig_ipv6_netbits =3D 0; + options->ifconfig_ipv6_remote =3D NULL; + } + else if (streq(p[0], "route") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_ROUTE); + if (c->c1.route_list) + { + destroy_routes_v4(c->c1.route_list, c->c1.tuntap, + ROUTE_OPTION_FLAGS(&c->options), + es, &c->net_ctx, options); + } + } + else if (streq(p[0], "route-ipv6") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_ROUTE); + if (c->c1.route_ipv6_list) + { + destroy_routes_v6(c->c1.route_ipv6_list, c->c1.tuntap, + ROUTE_OPTION_FLAGS(&c->options), + es, &c->net_ctx, options); + } + } + else if (streq(p[0], "route-gateway") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_ROUTE_EXTRAS); + options->route_gateway_via_dhcp =3D false; + options->route_default_gateway =3D NULL; + } + else if (streq(p[0], "route-metric") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_ROUTE); + options->route_default_metric =3D 0; + } + else if (streq(p[0], "push-continuation") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_PULL_MODE); + options->push_continuation =3D 0; + } + else if ((streq(p[0], "redirect-gateway") || streq(p[0], "redirect-pri= vate")) && !p[1]) + { + VERIFY_PERMISSION(OPT_P_ROUTE); + if (options->routes) + { + options->routes->flags =3D 0; + } + if (options->routes_ipv6) + { + options->routes_ipv6->flags =3D 0; + } + } + else if (streq(p[0], "dns") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_DHCPDNS); + gc_free(&options->dns_options.gc); + CLEAR(options->dns_options); + } + else if (streq(p[0], "topology") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_UP); + options->topology =3D TOP_UNDEF; + helper_setdefault_topology(options); + } + else if (streq(p[0], "tun-mtu") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_PUSH_MTU|OPT_P_CONNECTION); + options->ce.tun_mtu =3D TUN_MTU_DEFAULT; + options->ce.tun_mtu_defined =3D false; + options->ce.occ_mtu =3D 0; + } + else if (streq(p[0], "block-ipv6") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_ROUTE); + options->block_ipv6 =3D false; + } +#if defined(_WIN32) || defined(TARGET_ANDROID) + else if (streq(p[0], "dhcp-option") && !p[1]) + { + struct tuntap_options *o =3D &options->tuntap_options; + VERIFY_PERMISSION(OPT_P_DHCPDNS); + + o->domain =3D NULL; + o->netbios_scope =3D NULL; + o->netbios_node_type =3D 0; + o->dns6_len =3D 0; + memset(o->dns6, 0, sizeof(o->dns6)); + o->dns_len =3D 0; + memset(o->dns, 0, sizeof(o->dns)); + o->wins_len =3D 0; + memset(o->wins, 0, sizeof(o->wins)); + o->ntp_len =3D 0; + memset(o->ntp, 0, sizeof(o->ntp)); + o->nbdd_len =3D 0; + memset(o->nbdd, 0, sizeof(o->nbdd)); + while (o->domain_search_list_len-- > 0) + { + o->domain_search_list[o->domain_search_list_len] =3D NULL; + } + o->disable_nbt =3D 0; + o->dhcp_options =3D 0; +#if defined(TARGET_ANDROID) + o->http_proxy_port =3D 0; + o->http_proxy =3D NULL; +#endif + } +#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +#ifdef _WIN32 + else if (streq(p[0], "block-outside-dns") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_DHCPDNS); + options->block_outside_dns =3D false; + } +#else /* ifdef _WIN32 */ + else if (streq(p[0], "dhcp-option") && !p[1]) + { + VERIFY_PERMISSION(OPT_P_DHCPDNS); + delete_all_dhcp_fo(options, &es->list); + } +#endif + else + { + int i; + int msglevel_unknown =3D msglevel_fc; + /* Check if an option is in --ignore-unknown-option and + * set warning level to non fatal */ + for (i =3D 0; options->ignore_unknown_option && options->ignore_un= known_option[i]; i++) + { + if (streq(p[0], options->ignore_unknown_option[i])) + { + msglevel_unknown =3D M_WARN; + break; + } + } + msg(msglevel_unknown, "Unrecognized option or missing or extra par= ameter(s) in %s:%d: -%s (%s)", file, line, p[0], PACKAGE_VERSION); + } + return; +err: + msg(msglevel, "Error occurred trying to remove %s option", p[0]); +} bool apply_push_options(struct context *c, struct options *options, @@ -5618,11 +5792,47 @@ add_option(options, p, false, file, line_num, 0, msglevel, permission_mask, option_types_found, es); } + else if (push_update_option_flags & PUSH_OPT_TO_REMOVE) + { + remove_option(c, options, p, false, file, line_num, msglev= el, + permission_mask, option_types_found, es); + } } } return true; } +void +options_server_import(struct options *o, + const char *filename, + int msglevel, + unsigned int permission_mask, + unsigned int *option_types_found, + struct env_set *es) +{ + msg(D_PUSH, "OPTIONS IMPORT: reading client specific options from: %s"= , filename); + read_config_file(o, + filename, + 0, + filename, + 0, + msglevel, + permission_mask, + option_types_found, + es); +} + +void +options_string_import(struct options *options, + const char *config, + const int msglevel, + const unsigned int permission_mask, + unsigned int *option_types_found, + struct env_set *es) +{ + read_config_string("[CONFIG-STRING]", options, config, msglevel, permi= ssion_mask, option_types_found, es); +} + static void set_user_script(struct options *options, const char **script, diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 71a0372..69ea4bf 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -542,6 +542,11 @@ { msg(M_WARN, "No option found"); } + else if (!do_update(c, option_types_found)) + { + msg(D_PUSH_ERRORS, "Failed to update options"); + goto error; + } } } event_timeout_clear(&c->c2.push_request_interval); diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 2e584c7..0cd71d2 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1291,6 +1291,60 @@ } } +void +destroy_routes_v4(struct route_list *rl, const struct tuntap *tt, + unsigned int flags, const struct env_set *es, + openvpn_net_ctx_t *ctx, struct options *options) +{ + if (rl && (rl->iflags & RL_ROUTES_ADDED)) + { + struct route_ipv4 *r; + for (r =3D rl->routes; r; r =3D r->next) + { + delete_route(r, tt, flags, &rl->rgi, es, ctx); + } + rl->iflags &=3D ~RL_ROUTES_ADDED; + } + + undo_redirect_default_route_to_vpn(rl, tt, flags, es, ctx); + + if (rl) + { + clear_route_list(rl); + } + if (options->routes) + { + options->routes->routes =3D NULL; + options->routes->flags =3D 0; + } +} + +void +destroy_routes_v6(struct route_ipv6_list *rl6, const struct tuntap *tt, + unsigned int flags, const struct env_set *es, + openvpn_net_ctx_t *ctx, struct options *options) +{ + if (rl6 && (rl6->iflags & RL_ROUTES_ADDED)) + { + struct route_ipv6 *r6; + for (r6 =3D rl6->routes_ipv6; r6; r6 =3D r6->next) + { + delete_route_ipv6(r6, tt, flags, es, ctx); + } + rl6->iflags &=3D ~RL_ROUTES_ADDED; + } + + if (rl6) + { + clear_route_ipv6_list(rl6); + } + if (options->routes_ipv6) + { + options->routes_ipv6->routes_ipv6 =3D NULL; + options->routes_ipv6->flags =3D 0; + } +} + #ifndef ENABLE_SMALL static const char * diff --git a/src/openvpn/route.h b/src/openvpn/route.h index 421e7d2..b798c9d 100644 --- a/src/openvpn/route.h +++ b/src/openvpn/route.h @@ -321,6 +321,16 @@ const struct env_set *es, openvpn_net_ctx_t *ctx); +void +destroy_routes_v4(struct route_list *rl, const struct tuntap *tt, + unsigned int flags, const struct env_set *es, + openvpn_net_ctx_t *ctx, struct options *options); + +void +destroy_routes_v6(struct route_ipv6_list *rl6, const struct tuntap *tt, + unsigned int flags, const struct env_set *es, + openvpn_net_ctx_t *ctx, struct options *options); + void setenv_routes(struct env_set *es, const struct route_list *rl); void setenv_routes_ipv6(struct env_set *es, const struct route_ipv6_list *= rl6); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/809?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I507180d7397b6959844a30908010132bc3411067 Gerrit-Change-Number: 809 Gerrit-PatchSet: 2 Gerrit-Owner: mrbff Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --+qH2bw4TTcA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

mrbff uploaded patch set #2 to this change.

View Change

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/09/8=
09/2
diff --git a/src/openvpn/init.c b/src/openvpn/init.cindex f8d9d06..b95a61a 100644
--- a/src/openvpn/init= .c
+++ b/src/openvpn/init.c
@@ -2567,6 +256= 7,47 @@
return true;
}

+bool
<= span style=3D"color: hsl(120, 100%, 40%);">+do_update(struct context *c, un= signed int option_types_found)
+{
+ /* = Not necessary since to receive the update the openvpn
+ * instance must be up and running bu= t just in case
+ = */
+ if (!c->c2= .do_up_ran)
+ {
+ return false;<= /span>
+ }
+

+ bool tt_dco_win =3D tuntap_is_dco_win(c->c1.tu= ntap);
+ if (tt_dc= o_win)
+ {<= br>+ msg(M_NONFATAL, &qu= ot;dco-win doesn't yet support reopening TUN device");
<= span style=3D"color: hsl(120, 100%, 40%);">+ return false;
+ }
+
+ if (!do_deferred_options(c, option_types_found))<= br>+ {
+ msg(D_PUSH_ERRORS, "ERROR: F= ailed to apply push options");
+ return false;
+ }
+
+ do_close_tu= n(c, true);
+<= br>+ management_sleep(1);
+ int error_flags = =3D 0;
+ c->c2.= did_open_tun =3D do_open_tun(c, &error_flags);
+ update_time();
+
+ if (c->c2.did_open_tun)
+ {
+ initialization_sequence_completed(c, error_flags);+ }
+
+ CLEAR(c->c1.pulled_options_digest_save);
+

+ return true;
+}
+bool do_update(struct context *c, unsigned int option_ty= pes_found);
+<= br> unsigned int pull_permission_mask(const struct context *c);

const char *format_common_name(struct context= *c, struct gc_arena *gc);
diff --git a/src/openvpn/options= .c b/src/openvpn/options.c
index 8dea578..5b4419d 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn= /options.c
@@ -1055,6 +1055,40 @@
= gc_free(&gc);
}
}
+

+static void
+delete_all_dhcp_fo(struct options *o, struct env_item **list)<= /span>
+{
+ struct env_item *current, *prev;
+
+ ASSERT(list);
+
+ for (current =3D *list, prev =3D NULL; current !=3D NULL= ; current =3D current->next)
+ {
+ = char *tmp_value =3D NULL;
+ if (!strncmp(current->string, "foreign_option_&= quot;, sizeof("foreign_option_")-1))
+ {
+ tmp_value =3D strchr(current->string, '= =3D');
+ = if (tmp_value && ++tmp_value)
+ {
+ if (!strncmp(tmp_value, "dhcp-option &q= uot;, sizeof("dhcp-option ")-1))
+ {
+ if (prev)
+ {
+ prev->next =3D= current->next;
+ = }
= + else
+ {
+ *list =3D current->next;
+ }

+ o->foreign= _option_index--;

+ = }
+ = }
+ }
+ prev =3D curr= ent;
+ }+}
+
#endif /* ifndef _WIN32 */

static in_addr_t
@@ -3260,= 8 +3294,16 @@
msg(M_INFO, "Flag 'def1'= ; added to --redirect-gateway (iservice is in use)");
= opt->routes->flags |=3D RG_DEF1;
}

+ else if ((!opt->r= outes
+ = || opt->route_method !=3D ROUTE_METHOD_SERVICE
+ || !(opt->routes->flags &= amp; RG_REROUTE_GW))
= + && (opt->routes->flags & RG_DEF1))+ {
+ msg(M_INFO, "Flag 'def1&= #39; removed from --redirect-gateway");
+ opt->routes->flags &=3D ~RG_DEF1= ;
+ }
}
-#endif+#endif /* ifdef _WIN32 */


/*
* Save/Restore certai= n option defaults before --pull is applied.
@@ -5452,37 +54= 94,6 @@
}
}
<= br>-void
-options_server_import(struct options *o,
- const= char *filename,
- = int msglevel,
- unsigned int permission_mask,
- unsigned int *= option_types_found,

- = struct env_set *es)
-{
- = msg(D_PUSH, "OPTIONS IMPORT: reading client specific options from: %= s", filename);
- = read_config_file(o,
-= filename,
- 0,
- filename,
- 0,
- msglevel,
- permission_mask,
- option= _types_found,
- = es);
-}
-
-void
-options_string_import(struct options *options,
- const char *c= onfig,

- = const int msglevel,
- const unsigned int permission_mask,
- unsigned int= *option_types_found,

-= struct env_set *es)
-{
-= read_config_string("[CONFIG-STRING]", options, config, msglev= el, permission_mask, option_types_found, es);
-}
-
#define VERIFY_PERMISSION(mask) { = \
if (!verify_permission(p= [0], file, line, (mask), permission_mask, \
= option_types_found, msglevel, options, is_inline)) = \
@@ -5585,6 +5596,169 @@
return optio= ns->forward_compatible ? M_WARN : msglevel;
}
+static void=
+remove_option(struc= t context *c,
+ = struct options *options,
+ char *p[],
+ bool is_inline,
+ const char *file,
+ int line,
<= span style=3D"color: hsl(120, 100%, 40%);">+ const int msgleve= l,
+ con= st unsigned int permission_mask,
+ unsigned int *option_types_found,
+ struct env_set *es)<= /span>
+{
+ int msglevel_fc =3D msglevel_forwa= rd_compatible(options, msglevel);
+
+ i= f (streq(p[0], "ifconfig") && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_UP);
+ options->ifconfig_local = =3D NULL;
+ op= tions->ifconfig_remote_netmask =3D NULL;
+ }
+ else if (streq(p[0], "ifconfig-ipv6") && !p= [1])
+ {+ VERIFY_PERMISSION(OPT= _P_UP);
+ opti= ons->ifconfig_ipv6_local =3D NULL;
+ options->ifconfig_ipv6_netbits =3D 0;+ options->ifconfig= _ipv6_remote =3D NULL;
+ else if= (streq(p[0], "route") && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_ROUTE);
+ if (c->c1.route_list)

+ {
+ destroy_routes_v4(c->= ;c1.route_list, c->c1.tuntap,
+ ROUTE_OPTION_FLAGS(&c->op= tions),
+ = es, &c->net_ctx, options);
+ }
+ }
+ else if (streq(p[0], "route-ipv6") && !p[1]= )
+ {
+ VERIFY_PERMISSION(OPT_P_= ROUTE);
+ if (= c->c1.route_ipv6_list)
+ {
+ = destroy_routes_v6(c->c1.route_ipv6_list, c->c1.tuntap,=
+ = ROUTE_OPTION_FLAGS(&c->options),
+ es, &c->net_ct= x, options);
+ = }
+ }
<= span style=3D"color: hsl(120, 100%, 40%);">+ else if (streq(p[0], "= route-gateway") && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_ROUTE_EXTRAS);
+ options->route_gateway_via_dhc= p =3D false;
+ = options->route_default_gateway =3D NULL;
+ }
+ else if (streq(p[0], "route-metric") && !p= [1])
+ {+ VERIFY_PERMISSION(OPT= _P_ROUTE);
+ o= ptions->route_default_metric =3D 0;
+ }
+ else if (streq(p[0], "push-continuation") && !p[= 1])
+ {
= + VERIFY_PERMISSION(OPT_= P_PULL_MODE);
+ = options->push_continuation =3D 0;
+ }
+ else if ((streq(p[0], "redirect-gateway") || streq(p[0],= "redirect-private")) && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_ROUTE);
+ if (options->routes)<= br>+ {
+ options->routes->fl= ags =3D 0;
+ }=
+ if (options= ->routes_ipv6)
+ = {
+ = options->routes_ipv6->flags =3D 0;
+ }
+ }
+ = else if (streq(p[0], "dns") && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_DHCPDNS);
= + gc_free(&options-&= gt;dns_options.gc);
+= CLEAR(options->dns_options);
+ }
+ else if (streq(p[0], "topology") && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_UP);
+ options->t= opology =3D TOP_UNDEF;
+ }
+ else if (streq(p[0], "tun-mtu") && !p[1= ])
+ {
<= span style=3D"color: hsl(120, 100%, 40%);">+ VERIFY_PERMISSION(OPT_P= _PUSH_MTU|OPT_P_CONNECTION);

+ options->ce.tun_mtu =3D TUN_MTU_DEFAULT;
+ options->ce.tun_mtu_def= ined =3D false;

+ = options->ce.occ_mtu =3D 0;
+ }
+= else if (streq(p[0], "block-ipv6") && !p[1])+ {
+ VERIFY_PERMISSION(OPT_P_ROUTE);
+ options->b= lock_ipv6 =3D false;
= + }
+#if defined(_= WIN32) || defined(TARGET_ANDROID)
+ else if (streq(p[0], "dhcp-option") && = !p[1])
+ {<= br>+ struct tuntap_optio= ns *o =3D &options->tuntap_options;
+ VERIFY_PERMISSION(OPT_P_DHCPDNS);
= +
+ o->domain =3D NULL;
+ o->netbios_scope =3D NULL;<= /span>
+ o->netbio= s_node_type =3D 0;
+ = o->dns6_len =3D 0;
+ memset(o->dns6, 0, sizeof(o->dns6));
+ o->dns_len =3D 0;
=
+ memset(o->dns, = 0, sizeof(o->dns));
+ memset(o->wins, 0, sizeof(o->wins));
<= span style=3D"color: hsl(120, 100%, 40%);">+ o->ntp_len =3D 0;

+ memset(o->n= tp, 0, sizeof(o->ntp));
+ o->nbdd_len =3D 0;
+ memset(o->nbdd, 0, sizeof(o->nbdd));<= br>+ while (o->domain= _search_list_len-- > 0)
+ {
+ = o->domain_search_list[o->domain_search_list_len] =3D NULL;
+ }
<= span style=3D"color: hsl(120, 100%, 40%);">+ o->disable_nbt =3D 0= ;

+ o->dhcp= _options =3D 0;
+#if = defined(TARGET_ANDROID)
+ o->http_proxy_port =3D 0;
+ o->http_proxy =3D NULL;
+#endif
+ }
+#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */<= br>+#ifdef _WIN32
+ else if (streq(p[0], "bl= ock-outside-dns") && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_DHCPDNS);
+ options->block_outside_dns =3D fals= e;
+ }
<= span style=3D"color: hsl(120, 100%, 40%);">+#else /* ifdef _WIN32 */=
+ else if (streq(p[0], &= quot;dhcp-option") && !p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_DHCPDNS);
+ delete_all_dhcp_fo(options, &es-&= gt;list);
+ }
+#endif
+ else
+ {
+ int i;
+ int msglevel_unknown =3D msglevel_fc;
+ /* Check if an option is in --ign= ore-unknown-option and
+ for (i =3D 0; options->ignore_unknow= n_option && options->ignore_unknown_option[i]; i++)
+ {

+ if (streq(p[0], options->i= gnore_unknown_option[i]))
+ {
+= msglevel_unknown =3D M_WARN;
+ break;
+ }
+ }
+ msg(msglevel_unknown, "Unrecognized option or miss= ing or extra parameter(s) in %s:%d: -%s (%s)", file, line, p[0], PACKA= GE_VERSION);
+ }
+ return;+err:
+ msg(msglevel, "Error occurred tryin= g to remove %s option", p[0]);
+}
bool
apply_push_options= (struct context *c,
struct options *opt= ions,
@@ -5618,11 +5792,47 @@
= add_option(options, p, false, file, line_num, 0, msglevel,
permission_mask, option_types_found, es);
}
+ else if (push_update_option_flags & PUSH_OPT_TO_R= EMOVE)
+ {=
+ rem= ove_option(c, options, p, false, file, line_num, msglevel,
+ permis= sion_mask, option_types_found, es);
+ }
}
= }
return true;
}
=
+void
+options_server_import(struct optio= ns *o,

+ = const char *filename,
+ int msglevel,
+ unsigned int permission_ma= sk,
+ = unsigned int *option_types_found,
+ struct env_set *es)
+{
+ msg(D_PUSH, "OPTIONS IMPORT: reading clien= t specific options from: %s", filename);
+ read_config_file(o,
+ filename,
+ 0,
= + filename,=
+ = 0,
+ = msglevel,
+ = permission_mask,
+ option_types_found,
+ es);
+}
+
+void
+options_str= ing_import(struct options *options,
+ const char *config,
+ const int msgle= vel,
+ = const unsigned int permission_mask,
+ unsigned int *option_types_fou= nd,
+ = struct env_set *es)
+{
+ read_con= fig_string("[CONFIG-STRING]", options, config, msglevel, permissi= on_mask, option_types_found, es);
+}
+

static void
set_user_script(struct options *= options,
const char **script,
diff --git a/src/openvpn/push.c b/src/openvpn/push.c
in= dex 71a0372..69ea4bf 100644
--- a/src/openvpn/push.c=
+++ b/src/openvpn/push.c
@@ -542,6 +542,11 @@

{
msg(M_= WARN, "No option found");
}
+ else if = (!do_update(c, option_types_found))
+ {
+ msg(D_PUSH_ERRORS, "Failed to update= options");
+ = goto error;
+ }
}
= }
event_timeout_clear(&c->c2.push_r= equest_interval);
diff --git a/src/openvpn/route.c b/src/op= envpn/route.c
index 2e584c7..0cd71d2 100644
--- a/src/openvpn/route.c

+++ b/src/openvpn/route.c=
@@ -1291,6 +1291,60 @@
}
}<= /span>

+vo= id
+destroy_routes_v4= (struct route_list *rl, const struct tuntap *tt,
+ unsigned int flags, const st= ruct env_set *es,
+ = openvpn_net_ctx_t *ctx, struct options *options)
= +{
+ if (rl && (rl->iflags & RL_RO= UTES_ADDED))
+ {
+ struct route_= ipv4 *r;
+ for= (r =3D rl->routes; r; r =3D r->next)
+ {
+ delete_route(r, tt, flags, &rl->rgi, es, c= tx);
+ }

+ rl->iflags &am= p;=3D ~RL_ROUTES_ADDED;
+ }
++ undo_redirect_default_rou= te_to_vpn(rl, tt, flags, es, ctx);
+
+ = if (rl)
+ {=
+ clear_route_list(r= l);
+ }
= + if (options->routes)
+ {
+ options->routes->route= s =3D NULL;
+ = options->routes->flags =3D 0;
+ }
+}
+
+void

+destroy_routes_v6(struct route_ipv6_list *rl6, con= st struct tuntap *tt,
+ unsigned int flags, const struct env_set *es,+ openvpn_net= _ctx_t *ctx, struct options *options)
+{
+= if (rl6 && (rl6->iflags & RL_ROUTES_ADDED))
+ {
+ struct route_ipv6 *r6;
+ for (r6 =3D rl6->routes_= ipv6; r6; r6 =3D r6->next)
+ {
+= delete_route_ipv6(r6, tt, flags, es, ctx);
+ }
+ rl6->iflags &=3D ~RL_ROUTES_ADDED;<= /span>
+ }
+

+ if (rl6)
+ {
= + clear_route_ipv6_list(rl6);
+ }
+ {
+ options->routes_ipv6->routes_ipv6 =3D NULL;
+ options->routes_ipv6->= ;flags =3D 0;
+ }<= /span>
+}
+
#ifndef ENABLE_SMALL=

static const char *
dif= f --git a/src/openvpn/route.h b/src/openvpn/route.h
index 4= 21e7d2..b798c9d 100644
--- a/src/openvpn/route.h
= +++ b/src/openvpn/route.h
@@ -321,6 +321,16 @@=
const struct env_set *es,
= openvpn_net_ctx_t *ctx);

+void

+destroy_routes_v4(struct route_list *rl, const str= uct tuntap *tt,
+ = unsigned int flags, const struct env_set *es,
+ openvpn_net_ctx_t= *ctx, struct options *options);
+
+void
+destroy_routes_v6(str= uct route_ipv6_list *rl6, const struct tuntap *tt,
+ unsigned int flags, const = struct env_set *es,
+= openvpn_net_ctx_t *ctx, struct options *options);<= br>+
void sete= nv_routes(struct env_set *es, const struct route_list *rl);

void setenv_routes_ipv6(struct env_set *es, const struc= t route_ipv6_list *rl6);

To view, visit= change 8= 09. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I507180d7397b6959844a3090801= 0132bc3411067
Gerrit-Change-Number: 809
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <marco@...2726...> <= /div>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--+qH2bw4TTcA=--