Skip to content

Commit e5ff824

Browse files
itsGiaancron2
authored andcommitted
Deprecate --fast-io option
Recent changes to the event loop revealed that the --fast-io option is now partially broken and may cause "unroutable control packet" issues. As agreed during the last hackathon, this patch turns --fast-io into a no-op and emits a warning when it is used. Additionally, the MPP_CONDITIONAL_PRE_SELECT flag has been removed as it was part of the same code path and no longer needed. Change-Id: I2c0a0b55ad56e704d4bd19f1fbc1c30c83fae14c Signed-off-by: Gianmarco De Gregori <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1425 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg35024.html Signed-off-by: Gert Doering <[email protected]>
1 parent 309c233 commit e5ff824

File tree

11 files changed

+18
-126
lines changed

11 files changed

+18
-126
lines changed

doc/man-sections/generic-options.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,6 @@ which mode OpenVPN is configured as.
211211
``--show-engines`` standalone option to list the crypto engines which
212212
are supported by OpenSSL.
213213

214-
--fast-io
215-
Optimize TUN/TAP/UDP I/O writes by avoiding a call to
216-
poll/epoll/select prior to the write operation. The purpose of such a
217-
call would normally be to block until the device or socket is ready to
218-
accept the write. Such blocking is unnecessary on some platforms which
219-
don't support write blocking on UDP sockets or TUN/TAP devices. In such
220-
cases, one can optimize the event loop by avoiding the poll/epoll/select
221-
call, improving CPU efficiency by 5% to 10%.
222-
223-
This option can only be used on non-Windows systems, when ``--proto
224-
udp`` is specified, and when ``--shaper`` is *NOT* specified.
225-
226214
--group group
227215
Similar to the ``--user`` option, this option changes the group ID of
228216
the OpenVPN process to ``group`` after initialization.

doc/man-sections/unsupported-options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ longer supported
99
Removed in OpenVPN 2.5. This should be replaced with
1010
``--verify-client-cert none``.
1111

12+
--fast-io
13+
Ignored since OpenVPN 2.7. This option became broken due to changes
14+
to the event loop.
15+
1216
--http-proxy-retry
1317
Removed in OpenVPN 2.4. All retries are controlled by ``--max-connect-retry``.
1418

src/openvpn/forward.c

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,47 +2154,25 @@ multi_io_process_flags(struct context *c, struct event_set *es, const unsigned i
21542154
}
21552155

21562156
/*
2157-
* Wait for I/O events. Used for both TCP & UDP sockets
2158-
* in point-to-point mode and for UDP sockets in
2157+
* Wait for I/O events. Used for UDP sockets in
21592158
* point-to-multipoint mode.
21602159
*/
21612160

21622161
void
2163-
get_io_flags_dowork_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
2162+
get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
21642163
{
21652164
unsigned int out_socket;
21662165

21672166
multi_io_process_flags(c, multi_io->es, flags, &out_socket, NULL);
21682167
multi_io->udp_flags = (out_socket << SOCKET_SHIFT);
21692168
}
21702169

2170+
/*
2171+
* This is the core I/O wait function, used for all I/O waits except
2172+
* for the top-level server sockets.
2173+
*/
21712174
void
2172-
get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
2173-
{
2174-
multi_io->udp_flags = ES_ERROR;
2175-
if (c->c2.fast_io && (flags & (IOW_TO_TUN | IOW_TO_LINK | IOW_MBUF)))
2176-
{
2177-
/* fast path -- only for TUN/TAP/UDP writes */
2178-
unsigned int ret = 0;
2179-
if (flags & IOW_TO_TUN)
2180-
{
2181-
ret |= TUN_WRITE;
2182-
}
2183-
if (flags & (IOW_TO_LINK | IOW_MBUF))
2184-
{
2185-
ret |= SOCKET_WRITE;
2186-
}
2187-
multi_io->udp_flags = ret;
2188-
}
2189-
else
2190-
{
2191-
/* slow path - delegate to io_wait_dowork_udp to calculate flags */
2192-
get_io_flags_dowork_udp(c, multi_io, flags);
2193-
}
2194-
}
2195-
2196-
void
2197-
io_wait_dowork(struct context *c, const unsigned int flags)
2175+
io_wait(struct context *c, const unsigned int flags)
21982176
{
21992177
unsigned int out_socket;
22002178
unsigned int out_tuntap;

src/openvpn/forward.h

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,9 @@ extern counter_type link_read_bytes_global;
6868

6969
extern counter_type link_write_bytes_global;
7070

71-
void get_io_flags_dowork_udp(struct context *c, struct multi_io *multi_io,
72-
const unsigned int flags);
73-
7471
void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags);
7572

76-
void io_wait_dowork(struct context *c, const unsigned int flags);
73+
void io_wait(struct context *c, const unsigned int flags);
7774

7875
void pre_select(struct context *c);
7976

@@ -382,34 +379,6 @@ p2p_iow_flags(const struct context *c)
382379
return flags;
383380
}
384381

385-
/*
386-
* This is the core I/O wait function, used for all I/O waits except
387-
* for the top-level server sockets.
388-
*/
389-
static inline void
390-
io_wait(struct context *c, const unsigned int flags)
391-
{
392-
if (proto_is_dgram(c->c2.link_sockets[0]->info.proto) && c->c2.fast_io
393-
&& (flags & (IOW_TO_TUN | IOW_TO_LINK | IOW_MBUF)))
394-
{
395-
/* fast path -- only for TUN/TAP/UDP writes */
396-
unsigned int ret = 0;
397-
if (flags & IOW_TO_TUN)
398-
{
399-
ret |= TUN_WRITE;
400-
}
401-
if (flags & (IOW_TO_LINK | IOW_MBUF))
402-
{
403-
ret |= SOCKET_WRITE;
404-
}
405-
c->c2.event_set_status = ret;
406-
}
407-
else
408-
{
409-
/* slow path */
410-
io_wait_dowork(c, flags);
411-
}
412-
}
413382

414383
static inline bool
415384
connection_established(struct context *c)

src/openvpn/init.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4139,34 +4139,6 @@ do_env_set_destroy(struct context *c)
41394139
}
41404140
}
41414141

4142-
/*
4143-
* Fast I/O setup. Fast I/O is an optimization which only works
4144-
* if all of the following are true:
4145-
*
4146-
* (1) The platform is not Windows
4147-
* (2) --proto udp is enabled
4148-
* (3) --shaper is disabled
4149-
*/
4150-
static void
4151-
do_setup_fast_io(struct context *c)
4152-
{
4153-
if (c->options.fast_io)
4154-
{
4155-
#ifdef _WIN32
4156-
msg(M_INFO, "NOTE: --fast-io is disabled since we are running on Windows");
4157-
#else
4158-
if (c->options.shaper)
4159-
{
4160-
msg(M_INFO, "NOTE: --fast-io is disabled since we are using --shaper");
4161-
}
4162-
else
4163-
{
4164-
c->c2.fast_io = true;
4165-
}
4166-
#endif
4167-
}
4168-
}
4169-
41704142
static void
41714143
do_signal_on_tls_errors(struct context *c)
41724144
{
@@ -4513,12 +4485,6 @@ init_instance(struct context *c, const struct env_set *env, const unsigned int f
45134485
}
45144486
#endif
45154487

4516-
/* should we enable fast I/O? */
4517-
if (c->mode == CM_P2P || c->mode == CM_TOP)
4518-
{
4519-
do_setup_fast_io(c);
4520-
}
4521-
45224488
/* should we throw a signal on TLS errors? */
45234489
do_signal_on_tls_errors(c);
45244490

src/openvpn/mudp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,7 @@ void
339339
multi_process_io_udp(struct multi_context *m, struct link_socket *sock)
340340
{
341341
const unsigned int status = m->multi_io->udp_flags;
342-
const unsigned int mpp_flags = m->top.c2.fast_io
343-
? (MPP_CONDITIONAL_PRE_SELECT | MPP_CLOSE_ON_SIGNAL)
344-
: (MPP_PRE_SELECT | MPP_CLOSE_ON_SIGNAL);
342+
const unsigned int mpp_flags = (MPP_PRE_SELECT | MPP_CLOSE_ON_SIGNAL);
345343

346344
/* UDP port ready to accept write */
347345
if (status & SOCKET_WRITE)

src/openvpn/multi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,8 +3008,7 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const uns
30083008
bool ret = true;
30093009

30103010
if (!IS_SIG(&mi->context)
3011-
&& ((flags & MPP_PRE_SELECT)
3012-
|| ((flags & MPP_CONDITIONAL_PRE_SELECT) && !ANY_OUT(&mi->context))))
3011+
&& ((flags & MPP_PRE_SELECT)))
30133012
{
30143013
#if defined(ENABLE_ASYNC_PUSH)
30153014
bool was_unauthenticated = true;

src/openvpn/multi.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,9 @@ void multi_close_instance(struct multi_context *m, struct multi_instance *mi, bo
271271

272272
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags);
273273

274-
#define MPP_PRE_SELECT (1 << 0)
275-
#define MPP_CONDITIONAL_PRE_SELECT (1 << 1)
276-
#define MPP_CLOSE_ON_SIGNAL (1 << 2)
277-
#define MPP_RECORD_TOUCH (1 << 3)
274+
#define MPP_PRE_SELECT (1 << 0)
275+
#define MPP_CLOSE_ON_SIGNAL (1 << 1)
276+
#define MPP_RECORD_TOUCH (1 << 2)
278277

279278

280279
/**************************************************************************/

src/openvpn/openvpn.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,6 @@ struct context_2
420420
struct env_set *es;
421421
bool es_owned;
422422

423-
/* don't wait for TUN/TAP/UDP to be ready to accept write */
424-
bool fast_io;
425-
426423
/* --ifconfig endpoints to be pushed to client */
427424
bool push_request_received;
428425
bool push_ifconfig_defined;

src/openvpn/options.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ static const char usage_message[] =
285285
#if ENABLE_IP_PKTINFO
286286
"--multihome : Configure a multi-homed UDP server.\n"
287287
#endif
288-
"--fast-io : Optimize TUN/TAP/UDP writes.\n"
289288
"--remap-usr1 s : On SIGUSR1 signals, remap signal (s='SIGHUP' or 'SIGTERM').\n"
290289
"--persist-tun : Keep tun/tap device open across SIGUSR1 or --ping-restart.\n"
291290
"--persist-remote-ip : Keep remote IP address across SIGUSR1 or --ping-restart.\n"
@@ -1795,8 +1794,6 @@ show_settings(const struct options *o)
17951794
#endif
17961795
SHOW_INT(sockflags);
17971796

1798-
SHOW_BOOL(fast_io);
1799-
18001797
SHOW_INT(comp.alg);
18011798
SHOW_INT(comp.flags);
18021799

@@ -6592,7 +6589,7 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
65926589
else if (streq(p[0], "fast-io") && !p[1])
65936590
{
65946591
VERIFY_PERMISSION(OPT_P_GENERAL);
6595-
options->fast_io = true;
6592+
msg(M_WARN, "DEPRECATED OPTION: --fast-io option ignored.");
65966593
}
65976594
else if (streq(p[0], "inactive") && p[1] && !p[3])
65986595
{

0 commit comments

Comments
 (0)