[patch] Respect MTU set by VPN connections



Though an mtu setting exists in the NMIP4Config structure, the VPN
code in all cases overwrites the MTU on the interface to 1412 bytes.

Almost all PPTP require an MTU setting of 1000 (over PPP) and hence
996 bytes on the interface. (4 bytes for PPP stuff)

The hard coded setting of 1412 bytes breaks such connections. The attached patch adds the mtu setting to the VPN_IP4_CONFIG
signal.  If the mtu is set !=0 then the provided setting is used,
otherwise the original if mtu is set to zero the 1412-byte behaviour
prevails.

The patch also contain consistent changed in the vpnc, openvpn and
pptp plugins.
The patch was made against the HEAD. Could/should be back ported
to 0.6.x too?

tOnY
Index: src/NetworkManagerSystem.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerSystem.c,v
retrieving revision 1.38
diff -u -p -r1.38 NetworkManagerSystem.c
--- src/NetworkManagerSystem.c	9 Jun 2006 14:24:18 -0000	1.38
+++ src/NetworkManagerSystem.c	12 Jun 2006 11:49:27 -0000
@@ -405,6 +405,7 @@ out:
 gboolean nm_system_vpn_device_set_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config, char **routes, int num_routes)
 {
 	NMIP4Config *		ad_config = NULL;
+    guint32             mtu = 0;
 	struct nl_handle *	nlh = NULL;
 	struct rtnl_addr *	addr = NULL;
 	struct rtnl_link *	request = NULL;
@@ -436,9 +437,14 @@ gboolean nm_system_vpn_device_set_from_i
 		if ((request = rtnl_link_alloc ()))
 		{
 			struct rtnl_link * old;
+            mtu = nm_ip4_config_get_mtu(config); 
+            if (mtu==0) {
+                mtu = 1412;
+                nm_ip4_config_set_mtu(config,mtu);
+            }
 
 			old = iface_to_rtnl_link (iface, nlh);
-			rtnl_link_set_mtu (request, 1412);
+			rtnl_link_set_mtu (request, mtu);
 			rtnl_link_change (nlh, old, request, 0);
 
 			rtnl_link_put (old);
Index: src/vpn-manager/nm-vpn-service.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/vpn-manager/nm-vpn-service.c,v
retrieving revision 1.13
diff -u -p -r1.13 nm-vpn-service.c
--- src/vpn-manager/nm-vpn-service.c	29 Mar 2006 19:26:51 -0000	1.13
+++ src/vpn-manager/nm-vpn-service.c	12 Jun 2006 11:49:27 -0000
@@ -61,6 +61,7 @@ static void print_vpn_config (guint32 ip
 						guint32 ip4_dns_len,
 						guint32 *ip4_nbns,
 						guint32 ip4_nbns_len,
+						guint32 mtu,
 						guint32 mss,
 						const char *dns_domain,
 						const char *login_banner);
@@ -810,18 +811,24 @@ nm_vpn_service_stage4_ip_config_get (NMV
 		dbus_message_iter_next (&subiter);
 	}
 
-	/* Eighth arg: MSS (UINT32) */
+		nm_warning ("At eighth arg");
+	/* Eighth arg: MTU (UINT32) */
+	if (!get_dbus_guint32_helper (&iter, &num, "MTU"))
+		goto out;
+	nm_ip4_config_set_mtu (config, num);
+	
+	/* Ninth arg: MSS (UINT32) */
 	if (!get_dbus_guint32_helper (&iter, &num, "MSS"))
 		goto out;
 	nm_ip4_config_set_mss (config, num);
 	
-	/* Ninth arg: DNS Domain (STRING) */
+	/* Tenth arg: DNS Domain (STRING) */
 	if (!get_dbus_string_helper (&iter, &str, "DNS Domain"))
 		goto out;
 	if (strlen (str))
 		nm_ip4_config_add_domain (config, str);
 
-	/* Tenth arg: VPN Login Banner (STRING) */
+	/* Eleventh arg: VPN Login Banner (STRING) */
 	if (!get_dbus_string_helper (&iter, &login_banner, "Login Banner"))
 		goto out;
 
@@ -835,6 +842,7 @@ nm_vpn_service_stage4_ip_config_get (NMV
 	                  ip4_dns_len,
 	                  ip4_nbns,
 	                  ip4_nbns_len,
+	                  mtu,
 	                  mss,
 	                  dns_domain,
 	                  login_banner);
@@ -1064,6 +1072,7 @@ static void print_vpn_config (guint32 ip
 						guint32 ip4_dns_len,
 						guint32 *ip4_nbns,
 						guint32 ip4_nbns_len,
+						guint32 mtu,
 						guint32 mss,
 						const char *dns_domain,
 						const char *login_banner)
@@ -1080,6 +1089,7 @@ static void print_vpn_config (guint32 ip
 	nm_info ("Internal IP4 Netmask: %s", inet_ntoa (temp_addr));
 	temp_addr.s_addr = ip4_ptp_address;
 	nm_info ("Internal IP4 Point-to-Point Address: %s", inet_ntoa (temp_addr));
+    nm_info ("Maximum Transmit Unit (MTU): %d  (0 => default = 1412)", mtu);
 	nm_info ("Maximum Segment Size (MSS): %d", mss);
 
 	for (i = 0; i < ip4_dns_len; i++)
Index: vpn-daemons/vpnc/src/nm-vpnc-service.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/vpnc/src/nm-vpnc-service.c,v
retrieving revision 1.19
diff -u -p -r1.19 nm-vpnc-service.c
--- vpn-daemons/vpnc/src/nm-vpnc-service.c	21 May 2006 20:28:25 -0000	1.19
+++ vpn-daemons/vpnc/src/nm-vpnc-service.c	12 Jun 2006 11:49:27 -0000
@@ -878,6 +878,7 @@ static void nm_vpnc_dbus_process_helper_
 	guint32		ip4_dns_len;
 	guint32 *		ip4_nbns;
 	guint32		ip4_nbns_len;
+	guint32		mtu;
 	guint32		mss;
 	char *		cisco_def_domain;
 	char *		cisco_banner;
@@ -908,8 +909,9 @@ static void nm_vpnc_dbus_process_helper_
 	/* For Cisco/vpnc, PtP address == local VPN address */
 	ip4_ptp_address = ip4_address;
 
-	/* and we don't specify an MSS */
+	/* and we don't specify an MSS or MTU */
 	mss = 0;
+	mtu = 0;
 
 #if 0
 	print_vpn_config (ip4_vpn_gateway, tundev, ip4_address, ip4_netmask,
@@ -928,7 +930,8 @@ static void nm_vpnc_dbus_process_helper_
 	                          DBUS_TYPE_UINT32, &ip4_netmask,
 	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_dns, ip4_dns_len,
 	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_nbns, ip4_nbns_len,
-						 DBUS_TYPE_UINT32, &mss,
+						      DBUS_TYPE_UINT32, &mtu,
+   						      DBUS_TYPE_UINT32, &mss,
 	                          DBUS_TYPE_STRING, &cisco_def_domain,
 	                          DBUS_TYPE_STRING, &cisco_banner, DBUS_TYPE_INVALID);
 	if (!dbus_connection_send (data->con, signal, NULL))
Index: vpn-daemons/openvpn/src/nm-openvpn-service.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/openvpn/src/nm-openvpn-service.c,v
retrieving revision 1.12
diff -u -p -r1.12 nm-openvpn-service.c
--- vpn-daemons/openvpn/src/nm-openvpn-service.c	11 May 2006 17:19:17 -0000	1.12
+++ vpn-daemons/openvpn/src/nm-openvpn-service.c	12 Jun 2006 11:49:27 -0000
@@ -1254,6 +1254,7 @@ nm_openvpn_dbus_process_helper_ip4_confi
   guint32		ip4_dns_len;
   guint32 *		ip4_nbns;
   guint32		ip4_nbns_len;
+  guint32		mtu;
   guint32		mss;
   gboolean		success = FALSE;
   char *                empty = "";
@@ -1290,6 +1291,9 @@ nm_openvpn_dbus_process_helper_ip4_confi
 	/* OpenVPN does not care about the MSS */
 	mss = 0;
 
+	/* OpenVPN can use the default MTU (1492) */
+	mtu = 0;
+
       dbus_message_append_args (signal,
 				DBUS_TYPE_UINT32, &ip4_vpn_gateway,
 				DBUS_TYPE_STRING, &tundev,
@@ -1298,6 +1302,7 @@ nm_openvpn_dbus_process_helper_ip4_confi
 				DBUS_TYPE_UINT32, &ip4_netmask,
 				DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_dns, ip4_dns_len,
 				DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_nbns, ip4_nbns_len,
+				DBUS_TYPE_UINT32, &mtu,
 				DBUS_TYPE_UINT32, &mss,
 				DBUS_TYPE_STRING, &empty,
 				DBUS_TYPE_STRING, &empty,
Index: vpn-daemons/pptp/src/nm-ppp-starter.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/pptp/src/nm-ppp-starter.c,v
retrieving revision 1.4
diff -u -p -r1.4 nm-ppp-starter.c
--- vpn-daemons/pptp/src/nm-ppp-starter.c	12 Jun 2006 10:59:53 -0000	1.4
+++ vpn-daemons/pptp/src/nm-ppp-starter.c	12 Jun 2006 11:49:27 -0000
@@ -81,6 +81,7 @@ typedef struct NmPPPData
   GPid				pid;
   guint		     	quit_timer;
   guint			    helper_timer;
+  guint32		    mtu;
   char              *str_ip4_vpn_gateway;
   char              *connection_type;
   struct in_addr    ip4_vpn_gateway;
@@ -671,6 +672,9 @@ static gint nm_ppp_get_cmdline_ppp (NmPP
 		(strlen( data_items[++i] ) > 0) ) {
       g_ptr_array_add (ppp_argv, (gpointer) "mtu");
       g_ptr_array_add (ppp_argv, (gpointer) data_items[i]);
+// Set the mtu value for return to NM.
+//   (Subtract 4 for PPP header)
+      data->mtu=atoi(data_items[i])-4;
     } else if ( (strcmp( data_items[i], "lcp-echo-failure" ) == 0) &&
 		(strlen( data_items[++i] ) > 0) ) {
       g_ptr_array_add (ppp_argv, (gpointer) "lcp-echo-failure");
@@ -1322,6 +1326,7 @@ static void nm_ppp_dbus_process_helper_i
   guint32		    ip4_nbns_len;
   guint32 		    ip4_nbns1;
   guint32 		    ip4_nbns2;
+  guint32			mtu;
   guint32			mss;
   gboolean		    success = FALSE;
   char *            empty = "";
@@ -1377,6 +1382,8 @@ static void nm_ppp_dbus_process_helper_i
 
 	/* PPP does not care about the MSS */
 	mss = 0;
+	if (data->mtu <= 0) data->mtu=1500-4;
+    mtu = data->mtu;
 
       ip4_vpn_gateway=data->ip4_vpn_gateway.s_addr;
       dbus_message_append_args (signal, 
@@ -1387,6 +1394,7 @@ static void nm_ppp_dbus_process_helper_i
 				DBUS_TYPE_UINT32, &ip4_netmask,
 				DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_dns, ip4_dns_len,
 				DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_nbns, ip4_nbns_len,
+				DBUS_TYPE_UINT32, &mtu,
 				DBUS_TYPE_UINT32, &mss,
 				DBUS_TYPE_STRING, &empty,
 				DBUS_TYPE_STRING, &empty,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]