Merge branch 'issue247' into 'master'

Resolves: #247 - Bound negotiated MTU between RFC 791 defined minimum and configured maximum.

Closes #247

See merge request openconnect/ocserv!135
This commit is contained in:
Nikos Mavrogiannopoulos
2020-02-20 16:46:07 +00:00
2 changed files with 16 additions and 0 deletions

View File

@@ -26,6 +26,10 @@
#include <netinet/in.h>
#define MAX_IP_STR 46
// Lower MTU bound is the value defined in RFC 791
#define RFC_791_MTU (68)
// Upper bound is the maximum DTLS frame size
#define MAX_DTLS_MTU (1<<14)
void set_mtu_disc(int fd, int family, int val);
int ip_route_sanity_check(void *pool, char **_route);

View File

@@ -317,6 +317,11 @@ int handle_worker_commands(main_server_st * s, struct proc_st *proc)
break;
case CMD_TUN_MTU:{
TunMtuMsg *tmsg;
unsigned minimum_mtu = RFC_791_MTU;
unsigned maximum_mtu =
proc->vhost->perm_config.config->default_mtu != 0 ?
proc->vhost->perm_config.config->default_mtu :
MAX_DTLS_MTU;
if (proc->status != PS_AUTH_COMPLETED) {
mslog(s, proc, LOG_ERR,
@@ -332,6 +337,13 @@ int handle_worker_commands(main_server_st * s, struct proc_st *proc)
goto cleanup;
}
if (tmsg->mtu < minimum_mtu || tmsg->mtu > maximum_mtu) {
mslog(s, proc, LOG_ERR,
"worker process invalid MTU %d", (int)tmsg->mtu);
ret = ERR_BAD_COMMAND;
goto cleanup;
}
set_tun_mtu(s, proc, tmsg->mtu);
tun_mtu_msg__free_unpacked(tmsg, &pa);