mirror of
https://github.com/ntop/n2n.git
synced 2024-09-20 00:51:10 +02:00
Disable PMTU in other platforms
This commit is contained in:
parent
252ee3e82f
commit
0538c5261d
8
edge.c
8
edge.c
|
@ -140,9 +140,7 @@ static void help() {
|
||||||
"-l <supernode host:port>\n"
|
"-l <supernode host:port>\n"
|
||||||
" "
|
" "
|
||||||
"[-p <local port>] [-M <mtu>] "
|
"[-p <local port>] [-M <mtu>] "
|
||||||
#ifdef __linux__
|
|
||||||
"[-D] "
|
"[-D] "
|
||||||
#endif
|
|
||||||
"[-r] [-E] [-v] [-i <reg_interval>] [-t <mgmt port>] [-A] [-h]\n\n");
|
"[-r] [-E] [-v] [-i <reg_interval>] [-t <mgmt port>] [-A] [-h]\n\n");
|
||||||
|
|
||||||
#if defined(N2N_CAN_NAME_IFACE)
|
#if defined(N2N_CAN_NAME_IFACE)
|
||||||
|
@ -166,10 +164,8 @@ static void help() {
|
||||||
printf("-m <MAC address> | Fix MAC address for the TAP interface (otherwise it may be random)\n"
|
printf("-m <MAC address> | Fix MAC address for the TAP interface (otherwise it may be random)\n"
|
||||||
" | eg. -m 01:02:03:04:05:06\n");
|
" | eg. -m 01:02:03:04:05:06\n");
|
||||||
printf("-M <mtu> | Specify n2n MTU of edge interface (default %d).\n", DEFAULT_MTU);
|
printf("-M <mtu> | Specify n2n MTU of edge interface (default %d).\n", DEFAULT_MTU);
|
||||||
#ifdef __linux__
|
|
||||||
printf("-D | Enable PMTU discovery. PMTU discovery can reduce fragmentation but\n"
|
printf("-D | Enable PMTU discovery. PMTU discovery can reduce fragmentation but\n"
|
||||||
" | causes connections stall when not properly supported.\n");
|
" | causes connections stall when not properly supported.\n");
|
||||||
#endif
|
|
||||||
printf("-r | Enable packet forwarding through n2n community.\n");
|
printf("-r | Enable packet forwarding through n2n community.\n");
|
||||||
#ifdef N2N_HAVE_AES
|
#ifdef N2N_HAVE_AES
|
||||||
printf("-A | Use AES CBC for encryption (default=use twofish).\n");
|
printf("-A | Use AES CBC for encryption (default=use twofish).\n");
|
||||||
|
@ -257,13 +253,11 @@ static int setOption(int optkey, char *optargument, n2n_priv_config_t *ec, n2n_e
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
case 'D' : /* enable PMTU discovery */
|
case 'D' : /* enable PMTU discovery */
|
||||||
{
|
{
|
||||||
conf->disable_pmtu_discovery = 0;
|
conf->disable_pmtu_discovery = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
case 'k': /* encrypt key */
|
case 'k': /* encrypt key */
|
||||||
{
|
{
|
||||||
|
@ -393,7 +387,7 @@ static int loadFromCLI(int argc, char *argv[], n2n_edge_conf_t *conf, n2n_priv_c
|
||||||
u_char c;
|
u_char c;
|
||||||
|
|
||||||
while((c = getopt_long(argc, argv,
|
while((c = getopt_long(argc, argv,
|
||||||
"k:a:bc:Eu:g:m:M:s:d:l:p:fvhrt:i:S"
|
"k:a:bc:Eu:g:m:M:s:d:l:p:fvhrt:i:SD"
|
||||||
#ifdef N2N_HAVE_AES
|
#ifdef N2N_HAVE_AES
|
||||||
"A"
|
"A"
|
||||||
#endif
|
#endif
|
||||||
|
|
15
edge_utils.c
15
edge_utils.c
|
@ -1799,6 +1799,8 @@ void edge_term(n2n_edge_t * eee) {
|
||||||
/* ************************************** */
|
/* ************************************** */
|
||||||
|
|
||||||
static int edge_init_sockets(n2n_edge_t *eee, int udp_local_port, int mgmt_port, uint8_t tos) {
|
static int edge_init_sockets(n2n_edge_t *eee, int udp_local_port, int mgmt_port, uint8_t tos) {
|
||||||
|
int sockopt;
|
||||||
|
|
||||||
if(udp_local_port > 0)
|
if(udp_local_port > 0)
|
||||||
traceEvent(TRACE_NORMAL, "Binding to local port %d", udp_local_port);
|
traceEvent(TRACE_NORMAL, "Binding to local port %d", udp_local_port);
|
||||||
|
|
||||||
|
@ -1808,10 +1810,9 @@ static int edge_init_sockets(n2n_edge_t *eee, int udp_local_port, int mgmt_port,
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
if(tos) {
|
if(tos) {
|
||||||
/* https://www.tucny.com/Home/dscp-tos */
|
/* https://www.tucny.com/Home/dscp-tos */
|
||||||
int sockopt = tos;
|
sockopt = tos;
|
||||||
|
|
||||||
if(setsockopt(eee->udp_sock, IPPROTO_IP, IP_TOS, &sockopt, sizeof(sockopt)) == 0)
|
if(setsockopt(eee->udp_sock, IPPROTO_IP, IP_TOS, &sockopt, sizeof(sockopt)) == 0)
|
||||||
traceEvent(TRACE_NORMAL, "TOS set to 0x%x", tos);
|
traceEvent(TRACE_NORMAL, "TOS set to 0x%x", tos);
|
||||||
|
@ -1819,15 +1820,13 @@ static int edge_init_sockets(n2n_edge_t *eee, int udp_local_port, int mgmt_port,
|
||||||
traceEvent(TRACE_ERROR, "Could not set TOS 0x%x[%d]: %s", tos, errno, strerror(errno));
|
traceEvent(TRACE_ERROR, "Could not set TOS 0x%x[%d]: %s", tos, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eee->conf.disable_pmtu_discovery) {
|
sockopt = (eee->conf.disable_pmtu_discovery) ? IP_PMTUDISC_DONT : IP_PMTUDISC_DO;
|
||||||
int sockopt = 0;
|
|
||||||
|
|
||||||
if(setsockopt(eee->udp_sock, IPPROTO_IP, IP_MTU_DISCOVER, &sockopt, sizeof(sockopt)) < 0)
|
if(setsockopt(eee->udp_sock, IPPROTO_IP, IP_MTU_DISCOVER, &sockopt, sizeof(sockopt)) < 0)
|
||||||
traceEvent(TRACE_WARNING, "Could not disable PMTU discovery[%d]: %s", errno, strerror(errno));
|
traceEvent(TRACE_WARNING, "Could not %s PMTU discovery[%d]: %s",
|
||||||
|
(eee->conf.disable_pmtu_discovery) ? "disable" : "enable", errno, strerror(errno));
|
||||||
else
|
else
|
||||||
traceEvent(TRACE_DEBUG, "PMTU discovery disabled");
|
traceEvent(TRACE_DEBUG, "PMTU discovery %s", (eee->conf.disable_pmtu_discovery) ? "disabled" : "enabled");
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
eee->udp_mgmt_sock = open_socket(mgmt_port, 0 /* bind LOOPBACK */);
|
eee->udp_mgmt_sock = open_socket(mgmt_port, 0 /* bind LOOPBACK */);
|
||||||
if(eee->udp_mgmt_sock < 0) {
|
if(eee->udp_mgmt_sock < 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user