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/+/2054?usp=email
to review the following change.
Change subject: options: add support for --transport-plugin
......................................................................
options: add support for --transport-plugin
Add a new config option to allow the user to specify a transport plugin
implementing the new API. This plugin can be used to manipulate traffic
in any way, as designed by the plugin developer.
The fondamental advantage of this plugin is that the core codebase does
not need to know anything about its implementation, as soon as it
implements the transport API properly.
A plugin specified with --transport-plugin must be already loaded via
--plugin. --transport-plugin is a per-connection-block option and
specifies which plugin to use for this particular connection.
It can take additional arguments, if required by the specific plugin.
The manpage has been extended accordingly.
Change-Id: If09735841cd90aa4b07e85448ccf3b2f5944528e
Signed-off-by: Robin Tarsiger <[email protected]>
[[email protected]: refactored commits, restyled code]
[[email protected]: rebased, adapted to multisocket]
---
M src/openvpn/dco.c
M src/openvpn/options.c
M src/openvpn/options.h
M src/openvpn/socket.c
4 files changed, 38 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/54/2054/1
diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c
index f3b5d44..d9e4729 100644
--- a/src/openvpn/dco.c
+++ b/src/openvpn/dco.c
@@ -270,6 +270,12 @@
return false;
}
+ if (ce->transport_plugin_argv)
+ {
+ msg(msglevel, "Note: --transport-plugin disables data channel
offload.");
+ return false;
+ }
+
#if defined(TARGET_FREEBSD)
if (ce->local_list)
{
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 912d8e0..1720fc3 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -430,6 +430,9 @@
#ifdef ENABLE_PLUGIN
"--plugin m [str]: Load plug-in module m passing str as an argument\n"
" to its initialization function.\n"
+ "--transport-plugin m [args]: Use plug-in module m to provide the
transport\n"
+ " layer, with optional per-connection args.
The\n"
+ " module must already be loaded with
--plugin.\n"
#endif
"--vlan-tagging : Enable 802.1Q-based VLAN tagging.\n"
"--vlan-accept tagged|untagged|all : Set VLAN tagging mode. Default is
'all'.\n"
@@ -1622,6 +1625,22 @@
msg(M_USAGE, "multiple --local statements only allowed in --server
mode");
}
+#ifdef ENABLE_PLUGIN
+ /*
+ * "proto indirect" may not be specified directly without a
+ * transport-plugin, and vice versa.
+ */
+ if (ce->proto == PROTO_INDIRECT && !ce->transport_plugin_argv)
+ {
+ msg(M_USAGE, "--proto indirect may not be used without a
transport-plugin line");
+ }
+
+ if (ce->transport_plugin_argv && ce->proto != PROTO_INDIRECT)
+ {
+ msg(M_USAGE, "--transport-plugin must be used with --proto indirect");
+ }
+#endif
+
if (options->lladdr && dev != DEV_TYPE_TAP)
{
msg(M_USAGE, "--lladdr can only be used in --dev tap mode");
@@ -4424,7 +4443,17 @@
goto err;
}
}
-#endif
+ else if (streq(p[0], "transport-plugin") && p[1])
+ {
+ VERIFY_PERMISSION(OPT_P_PLUGIN | OPT_P_CONNECTION);
+
+ /* p[1] is the shared object name, which becomes
+ * argv[0]. p[2..] are connection-specific transport
+ * parameters, which become argv[1..].
+ */
+ options->ce.transport_plugin_argv = make_extended_arg_array(&p[1],
false, &options->gc);
+ }
+#endif /* ifdef ENABLE_PLUGIN */
else if (streq(p[0], "mode") && p[1] && !p[2])
{
VERIFY_PERMISSION(OPT_P_GENERAL);
diff --git a/src/openvpn/options.h b/src/openvpn/options.h
index c58530a..b117fa4 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/options.h
@@ -112,6 +112,7 @@
sa_family_t af;
const char *local_port;
bool local_port_defined;
+ const char **transport_plugin_argv;
const char *remote_port;
const char *remote;
bool remote_float;
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 9629cb3..07090f6 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -1105,6 +1105,7 @@
sock->info.bind_ipv6_only = o->ce.bind_ipv6_only;
sock->info.ipchange_command = o->ipchange;
sock->info.plugins = c->plugins;
+ sock->info.transport_plugin_argv = o->ce.transport_plugin_argv;
sock->server_poll_timeout = &c->c2.server_poll_interval;
sock->mode = mode;
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2054?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: If09735841cd90aa4b07e85448ccf3b2f5944528e
Gerrit-Change-Number: 2054
Gerrit-PatchSet: 1
Gerrit-Owner: Gianmarco De Gregori <[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