Browse code

- 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 authored on 27/08/2007 23:05:59
Showing 6 changed files
... ...
@@ -4,6 +4,7 @@ Release notes for SIP Express Router (ser)
4 4
 $Id$
5 5
 
6 6
 
7
+
7 8
 2.1.0 changes
8 9
 
9 10
 modules:
... ...
@@ -104,6 +105,7 @@ core:
104 104
                long held locks, almost no performance impact otherwise)
105 105
 
106 106
 new config variables:
107
+  pmtu_discovery = 0 | 1 (default 0) - set DF bit in outbound IP if enabled
107 108
   dns_srv_lb = yes | no (default no) - enable dns srv weight based load 
108 109
     balancing (see doc/dns.txt)
109 110
   dns_try_naptr = yes | no (default no) - enable naptr support 
... ...
@@ -313,6 +313,7 @@ RT_TIMER2_POLICY	"rt_timer2_policy"|"rt_stimer_policy"
313 313
 MCAST_LOOPBACK		"mcast_loopback"
314 314
 MCAST_TTL		"mcast_ttl"
315 315
 TOS			"tos"
316
+PMTU_DISCOVERY	"pmtu_discovery"
316 317
 KILL_TIMEOUT	"exit_timeout"|"ser_kill_timeout"
317 318
 
318 319
 /* stun config variables */
... ...
@@ -591,6 +592,8 @@ EAT_ABLE	[\ \t\b\r]
591 591
 									return MCAST_TTL; }
592 592
 <INITIAL>{TOS}			{	count(); yylval.strval=yytext;
593 593
 									return TOS; }
594
+<INITIAL>{PMTU_DISCOVERY}		{	count(); yylval.strval=yytext;
595
+									return PMTU_DISCOVERY; }
594 596
 <INITIAL>{KILL_TIMEOUT}			{	count(); yylval.strval=yytext;
595 597
 									return KILL_TIMEOUT; }
596 598
 <INITIAL>{LOADMODULE}	{ count(); yylval.strval=yytext; return LOADMODULE; }
... ...
@@ -357,6 +357,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
357 357
 %token MCAST_LOOPBACK
358 358
 %token MCAST_TTL
359 359
 %token TOS
360
+%token PMTU_DISCOVERY
360 361
 %token KILL_TIMEOUT
361 362
 
362 363
 %token FLAGS_DECL
... ...
@@ -969,6 +970,8 @@ assign_stm:
969 969
 	| MCAST_TTL EQUAL error { yyerror("number expected"); }
970 970
 	| TOS EQUAL NUMBER { tos=$3; }
971 971
 	| TOS EQUAL error { yyerror("number expected"); }
972
+	| PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
973
+	| PMTU_DISCOVERY error { yyerror("number expected"); }
972 974
 	| KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
973 975
 	| KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
974 976
 	| STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
... ...
@@ -121,6 +121,7 @@ extern int stun_allow_fp;
121 121
 #endif
122 122
 
123 123
 extern int tos;
124
+extern int pmtu_discovery;
124 125
 
125 126
 /*
126 127
  * debug & log_stderr moved to dprint.h*/
... ...
@@ -370,6 +370,7 @@ int use_dst_blacklist=0; /* 1 if the blacklist is enabled */
370 370
 #endif
371 371
 
372 372
 int tos = IPTOS_LOWDELAY;
373
+int pmtu_discovery = 0;
373 374
 
374 375
 #if 0
375 376
 char* names[MAX_LISTEN];              /* our names */
... ...
@@ -38,6 +38,9 @@
38 38
  *  2005-06-26  failure to set mcast options is not an error anymore (andrei)
39 39
  *  2006-04-12  udp_send() switched to struct dest_info (andrei)
40 40
  *  2006-10-13  added STUN support (vlada)
41
+ *  2007-08-28  disable/set MTU discover option for the udp sockets
42
+ *               (in linux it's enabled by default which produces udp packets
43
+ *                with the DF flag ser) (patch from hscholz)
41 44
  */
42 45
 
43 46
 
... ...
@@ -309,7 +312,7 @@ int udp_init(struct socket_info* sock_info)
309 309
 		LOG(L_WARN, "WARNING: udp_init: setsockopt tos: %s\n", strerror(errno));
310 310
 		/* continue since this is not critical */
311 311
 	}
312
-#if defined (__linux__) && defined(UDP_ERRORS)
312
+#if defined (__OS_linux) && defined(UDP_ERRORS)
313 313
 	optval=1;
314 314
 	/* enable error receiving on unconnected sockets */
315 315
 	if(setsockopt(sock_info->socket, SOL_IP, IP_RECVERR,
... ...
@@ -318,6 +321,16 @@ int udp_init(struct socket_info* sock_info)
318 318
 		goto error;
319 319
 	}
320 320
 #endif
321
+#if defined (__OS_linux)
322
+	/* if pmtu_discovery=1 then set DF bit and do Path MTU discovery
323
+	 * disabled by default */
324
+	optval= (pmtu_discovery) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
325
+	if(setsockopt(sock_info->socket, IPPROTO_IP, IP_MTU_DISCOVER,
326
+			(void*)&optval, sizeof(optval)) ==-1){
327
+		LOG(L_ERR, "ERROR: udp_init: setsockopt: %s\n", strerror(errno));
328
+		goto error;
329
+	}
330
+#endif
321 331
 
322 332
 #ifdef USE_MCAST
323 333
 	if ((sock_info->flags & SI_IS_MCAST)