Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2336?usp=email
to review the following change.
Change subject: init: deduplicate crypto param update and noexec driver checks
......................................................................
init: deduplicate crypto param update and noexec driver checks
do_deferred_p2p_ncp() now calls do_deferred_options_part2() instead of
open-coding the peer-id sync and tls_session_update_crypto_params()
call. The error message moves to the caller in do_up().
Factor the AF_UNIX/null driver test shared by route_noexec_enabled()
and ifconfig_noexec_enabled() into tun_driver_noexec(), and fix the
truncated ifconfig_noexec_enabled() doc comment.
Change-Id: Id36f1ae9b90be55cb7e77baa6f212bc1f06e2c6b
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M src/openvpn/init.c
1 file changed, 16 insertions(+), 30 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/36/2336/1
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index e1052c5..c3927cc 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -1589,6 +1589,13 @@
#endif /* ifdef ENABLE_MANAGEMENT */
}
+/** Backend drivers that take no ifconfig or route commands */
+static bool
+tun_driver_noexec(const struct tuntap *tt)
+{
+ return tt && (tt->backend_driver == DRIVER_AFUNIX || tt->backend_driver ==
DRIVER_NULL);
+}
+
/**
* Determine if external route commands should be executed based on
* configured options and backend driver
@@ -1596,8 +1603,7 @@
static bool
route_noexec_enabled(const struct options *o, const struct tuntap *tt)
{
- return o->route_noexec || (tt && tt->backend_driver == DRIVER_AFUNIX)
- || (tt && tt->backend_driver == DRIVER_NULL);
+ return o->route_noexec || tun_driver_noexec(tt);
}
/*
@@ -1766,16 +1772,13 @@
}
/**
- * Determines if ifconfig execution should be disabled because of a
- * @param c
- * @return
+ * Determine if ifconfig execution should be disabled, either by
+ * --ifconfig-noexec or by the backend driver
*/
static bool
ifconfig_noexec_enabled(const struct context *c)
{
- return c->options.ifconfig_noexec
- || (c->c1.tuntap && c->c1.tuntap->backend_driver == DRIVER_AFUNIX)
- || (c->c1.tuntap && c->c1.tuntap->backend_driver == DRIVER_NULL);
+ return c->options.ifconfig_noexec || tun_driver_noexec(c->c1.tuntap);
}
static void
@@ -2290,15 +2293,9 @@
c->options.use_peer_id = c->c2.tls_multi->use_peer_id;
struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE];
- if (!tls_session_update_crypto_params(c->c2.tls_multi, session,
&c->options, &c->c2.frame,
- frame_fragment,
get_link_socket_info(c),
- &c->c1.tuntap->dco))
- {
- msg(D_TLS_ERRORS, "OPTIONS ERROR: failed to import crypto options");
- return false;
- }
-
- return true;
+ return tls_session_update_crypto_params(c->c2.tls_multi, session,
&c->options, &c->c2.frame,
+ frame_fragment,
get_link_socket_info(c),
+ &c->c1.tuntap->dco);
}
bool
@@ -2386,6 +2383,7 @@
{
if (!do_deferred_options_part2(c))
{
+ msg(D_TLS_ERRORS, "OPTIONS ERROR: failed to import crypto
options");
return false;
}
}
@@ -2518,8 +2516,6 @@
return true;
}
- c->options.use_peer_id = c->c2.tls_multi->use_peer_id;
-
struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE];
const char *ncp_cipher =
@@ -2537,17 +2533,7 @@
return false;
}
- struct frame *frame_fragment = NULL;
-#ifdef ENABLE_FRAGMENT
- if (c->options.ce.fragment)
- {
- frame_fragment = &c->c2.frame_fragment;
- }
-#endif
-
- if (!tls_session_update_crypto_params(c->c2.tls_multi, session,
&c->options, &c->c2.frame,
- frame_fragment,
get_link_socket_info(c),
- &c->c1.tuntap->dco))
+ if (!do_deferred_options_part2(c))
{
msg(D_TLS_ERRORS, "ERROR: failed to set crypto cipher");
return false;
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2336?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id36f1ae9b90be55cb7e77baa6f212bc1f06e2c6b
Gerrit-Change-Number: 2336
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel