From 1b49b37a75efbfe4f7ba35fa7b9dfa5426de17e8 Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Tue, 24 Sep 2019 09:50:29 +0200 Subject: [PATCH] Disable PMTU options on apple to fix compilation issues --- edge.c | 6 ++++++ edge_utils.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/edge.c b/edge.c index c5184ca..c4889c8 100644 --- a/edge.c +++ b/edge.c @@ -140,7 +140,9 @@ static void help() { "-l \n" " " "[-p ] [-M ] " +#ifndef __APPLE__ "[-D] " +#endif "[-r] [-E] [-v] [-i ] [-t ] [-A] [-h]\n\n"); #if defined(N2N_CAN_NAME_IFACE) @@ -164,8 +166,10 @@ static void help() { printf("-m | Fix MAC address for the TAP interface (otherwise it may be random)\n" " | eg. -m 01:02:03:04:05:06\n"); printf("-M | Specify n2n MTU of edge interface (default %d).\n", DEFAULT_MTU); +#ifndef __APPLE__ printf("-D | Enable PMTU discovery. PMTU discovery can reduce fragmentation but\n" " | causes connections stall when not properly supported.\n"); +#endif printf("-r | Enable packet forwarding through n2n community.\n"); #ifdef N2N_HAVE_AES printf("-A | Use AES CBC for encryption (default=use twofish).\n"); @@ -253,11 +257,13 @@ static int setOption(int optkey, char *optargument, n2n_priv_config_t *ec, n2n_e break; } +#ifndef __APPLE__ case 'D' : /* enable PMTU discovery */ { conf->disable_pmtu_discovery = 0; break; } +#endif case 'k': /* encrypt key */ { diff --git a/edge_utils.c b/edge_utils.c index 9e7dc0a..c20b2b0 100644 --- a/edge_utils.c +++ b/edge_utils.c @@ -1816,6 +1816,7 @@ 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)); } +#ifndef __APPLE__ sockopt = (eee->conf.disable_pmtu_discovery) ? IP_PMTUDISC_DONT : IP_PMTUDISC_DO; if(setsockopt(eee->udp_sock, IPPROTO_IP, IP_MTU_DISCOVER, &sockopt, sizeof(sockopt)) < 0) @@ -1823,6 +1824,7 @@ static int edge_init_sockets(n2n_edge_t *eee, int udp_local_port, int mgmt_port, (eee->conf.disable_pmtu_discovery) ? "disable" : "enable", errno, strerror(errno)); else 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 */); if(eee->udp_mgmt_sock < 0) {