Ver Fonte

- disable by default path MTU discovery on linux (unfortunately on linux path
MTU discovery is enabled by default even for udp, which produces packets
with the DF flag set). It can be re-enabled using the new pmtu_discovery
config option.
Patch from Hendrik Scholz (hscholz).
Closes SER-275.

Andrei Pelinescu-Onciul há 18 anos atrás
pai
commit
f3a267970e
6 ficheiros alterados com 24 adições e 1 exclusões
  1. 2 0
      NEWS
  2. 3 0
      cfg.lex
  3. 3 0
      cfg.y
  4. 1 0
      globals.h
  5. 1 0
      main.c
  6. 14 1
      udp_server.c

+ 2 - 0
NEWS

@@ -4,6 +4,7 @@ Release notes for SIP Express Router (ser)
 $Id$
 
 
+
 2.1.0 changes
 
 modules:
@@ -104,6 +105,7 @@ core:
                long held locks, almost no performance impact otherwise)
 
 new config variables:
+  pmtu_discovery = 0 | 1 (default 0) - set DF bit in outbound IP if enabled
   dns_srv_lb = yes | no (default no) - enable dns srv weight based load 
     balancing (see doc/dns.txt)
   dns_try_naptr = yes | no (default no) - enable naptr support 

+ 3 - 0
cfg.lex

@@ -313,6 +313,7 @@ RT_TIMER2_POLICY	"rt_timer2_policy"|"rt_stimer_policy"
 MCAST_LOOPBACK		"mcast_loopback"
 MCAST_TTL		"mcast_ttl"
 TOS			"tos"
+PMTU_DISCOVERY	"pmtu_discovery"
 KILL_TIMEOUT	"exit_timeout"|"ser_kill_timeout"
 
 /* stun config variables */
@@ -591,6 +592,8 @@ EAT_ABLE	[\ \t\b\r]
 									return MCAST_TTL; }
 <INITIAL>{TOS}			{	count(); yylval.strval=yytext;
 									return TOS; }
+<INITIAL>{PMTU_DISCOVERY}		{	count(); yylval.strval=yytext;
+									return PMTU_DISCOVERY; }
 <INITIAL>{KILL_TIMEOUT}			{	count(); yylval.strval=yytext;
 									return KILL_TIMEOUT; }
 <INITIAL>{LOADMODULE}	{ count(); yylval.strval=yytext; return LOADMODULE; }

+ 3 - 0
cfg.y

@@ -357,6 +357,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %token MCAST_LOOPBACK
 %token MCAST_TTL
 %token TOS
+%token PMTU_DISCOVERY
 %token KILL_TIMEOUT
 
 %token FLAGS_DECL
@@ -969,6 +970,8 @@ assign_stm:
 	| MCAST_TTL EQUAL error { yyerror("number expected"); }
 	| TOS EQUAL NUMBER { tos=$3; }
 	| TOS EQUAL error { yyerror("number expected"); }
+	| PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
+	| PMTU_DISCOVERY error { yyerror("number expected"); }
 	| KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
 	| KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
 	| STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }

+ 1 - 0
globals.h

@@ -121,6 +121,7 @@ extern int stun_allow_fp;
 #endif
 
 extern int tos;
+extern int pmtu_discovery;
 
 /*
  * debug & log_stderr moved to dprint.h*/

+ 1 - 0
main.c

@@ -370,6 +370,7 @@ int use_dst_blacklist=0; /* 1 if the blacklist is enabled */
 #endif
 
 int tos = IPTOS_LOWDELAY;
+int pmtu_discovery = 0;
 
 #if 0
 char* names[MAX_LISTEN];              /* our names */

+ 14 - 1
udp_server.c

@@ -38,6 +38,9 @@
  *  2005-06-26  failure to set mcast options is not an error anymore (andrei)
  *  2006-04-12  udp_send() switched to struct dest_info (andrei)
  *  2006-10-13  added STUN support (vlada)
+ *  2007-08-28  disable/set MTU discover option for the udp sockets
+ *               (in linux it's enabled by default which produces udp packets
+ *                with the DF flag ser) (patch from hscholz)
  */
 
 
@@ -309,7 +312,7 @@ int udp_init(struct socket_info* sock_info)
 		LOG(L_WARN, "WARNING: udp_init: setsockopt tos: %s\n", strerror(errno));
 		/* continue since this is not critical */
 	}
-#if defined (__linux__) && defined(UDP_ERRORS)
+#if defined (__OS_linux) && defined(UDP_ERRORS)
 	optval=1;
 	/* enable error receiving on unconnected sockets */
 	if(setsockopt(sock_info->socket, SOL_IP, IP_RECVERR,
@@ -318,6 +321,16 @@ int udp_init(struct socket_info* sock_info)
 		goto error;
 	}
 #endif
+#if defined (__OS_linux)
+	/* if pmtu_discovery=1 then set DF bit and do Path MTU discovery
+	 * disabled by default */
+	optval= (pmtu_discovery) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
+	if(setsockopt(sock_info->socket, IPPROTO_IP, IP_MTU_DISCOVER,
+			(void*)&optval, sizeof(optval)) ==-1){
+		LOG(L_ERR, "ERROR: udp_init: setsockopt: %s\n", strerror(errno));
+		goto error;
+	}
+#endif
 
 #ifdef USE_MCAST
 	if ((sock_info->flags & SI_IS_MCAST)