[PATCH] For NM to take the MTU from vpn-daemon



Please ignore the previous mail sent by me.

Hi,

Currently NetworkManager sets up a route to the VPN gateway through the
real network device without any mtu.

In some cases, mtu setting is needed for this route.

The attached patch makes NM to take the mtu from vpn-daemon and then use
that to set up the route to the VPN gateway through the real network
device. ( MTU = 0 -> No mtu will be set)

Appreciate any comments on this.

Thanks and Regards,
Vinay
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/NetworkManager/ChangeLog,v
retrieving revision 1.875
diff -u -r1.875 ChangeLog
--- ChangeLog	8 Mar 2006 18:36:13 -0000	1.875
+++ ChangeLog	9 Mar 2006 14:58:11 -0000
@@ -1,3 +1,36 @@
+2006-03-09  Vinay A R    <rvinay novell com>
+
+	* src/NetworkManagerSystem.c : 
+		- Changes to the signature of 
+	  	        'nm_system_device_set_ip4_route' & 
+		        'nm_system_device_set_ip4_route_with_iface'
+		        to take additonal argument of 'mtu' to set the route.
+	        - (nm_system_device_set_from_ip4_config) : passed an additional
+		        argument '0' to nm_system_device_set_ip4_route.
+		- (nm_system_device_set_ip4_route) : Edited to take an extra argument 
+			'mtu'and passed	that to 'nm_system_device_set_ip4_route_with_iface'
+		- (nm_system_device_set_ip4_route_with_iface) : Edited to take
+			an extra argument 'mtu' and set the mtu
+			of the route if argument 'mtu' is not 0
+
+	* src/nm-ip4-config.c : 
+		- (struct NMIP4Config)
+			Added mtu to the structure which will be used to set the 
+			mtu of the route to the VPN gateway through the
+			real network device.
+		- Added 'nm_ip4_config_get_mtu' function to get value of mtu in
+			struct NMIP4Config variable.
+		- Added 'nm_ip4_config_set_mtu' function to set the value of mtu
+			in struct NMIP4Config variable.
+		
+	* src/nm-ip4-config.h :
+		- Added signature of 'nm_ip4_config_get_mtu' function. 
+		- Added signature of 'nm_ip4_config_set_mtu' function.
+	
+	* src/vpn-manager/nm-vpn-service.c : 
+		- (nm_vpn_service_stage4_ip_config_get) : Edited to receive the mtu 
+			from vpn daemon.
+
 2006-03-08  Robert Love  <rml novell com>
 
 	* gnome/applet/applet.glade: Hide the password entry text with
Index: src/NetworkManagerSystem.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerSystem.c,v
retrieving revision 1.34
diff -u -r1.34 NetworkManagerSystem.c
--- src/NetworkManagerSystem.c	6 Mar 2006 01:10:58 -0000	1.34
+++ src/NetworkManagerSystem.c	9 Mar 2006 14:58:12 -0000
@@ -52,8 +52,8 @@
 #include <netlink/route/link.h>
 
 
-static gboolean nm_system_device_set_ip4_route					(NMDevice *dev, int ip4_gateway, int ip4_dest, int ip4_netmask);
-static gboolean nm_system_device_set_ip4_route_with_iface			(NMDevice *dev, const char *iface, int ip4_gateway, int ip4_dest, int ip4_netmask);
+static gboolean nm_system_device_set_ip4_route					(NMDevice *dev, int ip4_gateway, int ip4_dest, int ip4_netmask, int mtu);
+static gboolean nm_system_device_set_ip4_route_with_iface			(NMDevice *dev, const char *iface, int ip4_gateway, int ip4_dest, int ip4_netmask, int mtu);
 
 
 static struct nl_cache * get_link_cache (struct nl_handle *nlh)
@@ -212,7 +212,7 @@
 	nl_handle_destroy (nlh);
 
 	sleep (1);
-	nm_system_device_set_ip4_route (dev, nm_ip4_config_get_gateway (config), 0, 0);
+	nm_system_device_set_ip4_route (dev, nm_ip4_config_get_gateway (config), 0, 0, 0);
 
 	nm_named_manager_add_ip4_config (app_data->named_manager, config);
 
@@ -313,7 +313,7 @@
 
 	/* Set up a route to the VPN gateway through the real network device */
 	if (active_device && (ad_config = nm_device_get_ip4_config (active_device)))
-		nm_system_device_set_ip4_route (active_device, nm_ip4_config_get_gateway (ad_config), nm_ip4_config_get_gateway (config), 0xFFFFFFFF);
+		nm_system_device_set_ip4_route (active_device, nm_ip4_config_get_gateway (ad_config), nm_ip4_config_get_gateway (config), 0xFFFFFFFF, nm_ip4_config_get_mtu(config));
 
 	if (iface != NULL && strlen (iface))
 	{
@@ -460,14 +460,14 @@
  * Set the IPv4 broadcast address on a device.
  *
  */
-static gboolean nm_system_device_set_ip4_route (NMDevice *dev, int ip4_gateway, int ip4_dest, int ip4_netmask)
+static gboolean nm_system_device_set_ip4_route (NMDevice *dev, int ip4_gateway, int ip4_dest, int ip4_netmask, int mtu)
 {
 	g_return_val_if_fail (dev != NULL, FALSE);
 
-	return nm_system_device_set_ip4_route_with_iface (dev, nm_device_get_iface (dev), ip4_gateway, ip4_dest, ip4_netmask);
+	return nm_system_device_set_ip4_route_with_iface (dev, nm_device_get_iface (dev), ip4_gateway, ip4_dest, ip4_netmask, mtu);
 }
 
-static gboolean nm_system_device_set_ip4_route_with_iface (NMDevice *dev, const char *iface, int ip4_gateway, int ip4_dest, int ip4_netmask)
+static gboolean nm_system_device_set_ip4_route_with_iface (NMDevice *dev, const char *iface, int ip4_gateway, int ip4_dest, int ip4_netmask, int mtu)
 {
 	NMSock *			sk;
 	gboolean			success = FALSE;
@@ -502,6 +502,12 @@
 	rtent.rt_metric	= 1;
 	rtent.rt_window	= 0;
 	rtent.rt_flags		= RTF_UP | RTF_GATEWAY | (rtent.rt_window ? RTF_WINDOW : 0);
+	
+	if(mtu != 0)
+	{
+		rtent.rt_flags = rtent.rt_flags | RTF_MTU;
+		rtent.rt_mtu = mtu;
+	}
 
 #ifdef IOCTL_DEBUG
 	nm_info ("%s: About to CADDRT\n", nm_device_get_iface (dev));
@@ -529,6 +535,13 @@
 			rtent2.rt_dev		= (char *)iface;
 			rtent2.rt_metric	= 0;
 			rtent2.rt_flags	= RTF_UP | RTF_HOST;
+			
+			if(mtu != 0)
+			{
+				rtent2.rt_flags = rtent2.rt_flags | RTF_MTU;
+				rtent2.rt_mtu = mtu;
+			}
+
 
 #ifdef IOCTL_DEBUG
 			nm_info ("%s: About to CADDRT (2)\n", nm_device_get_iface (dev));
Index: src/nm-ip4-config.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-ip4-config.c,v
retrieving revision 1.13
diff -u -r1.13 nm-ip4-config.c
--- src/nm-ip4-config.c	3 Feb 2006 17:40:30 -0000	1.13
+++ src/nm-ip4-config.c	9 Mar 2006 14:58:12 -0000
@@ -40,6 +40,7 @@
 	guint32	ip4_gateway;
 	guint32	ip4_netmask;
 	guint32	ip4_broadcast;
+	guint32 mtu;	
 
 	GSList *	nameservers;
 	GSList *	domains;
@@ -326,6 +327,19 @@
 	return (g_slist_length (config->domains));
 }
 
+guint32 nm_ip4_config_get_mtu (NMIP4Config *config)
+{
+	g_return_val_if_fail (config != NULL, 0);
+
+	return config->mtu;
+}
+
+void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu)
+{
+	g_return_if_fail (config != NULL);
+
+	config->mtu = mtu;
+}
 
 /* libnl convenience/conversion functions */
 
Index: src/nm-ip4-config.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-ip4-config.h,v
retrieving revision 1.8
diff -u -r1.8 nm-ip4-config.h
--- src/nm-ip4-config.h	3 Feb 2006 17:40:30 -0000	1.8
+++ src/nm-ip4-config.h	9 Mar 2006 14:58:12 -0000
@@ -68,6 +68,8 @@
 const char *	nm_ip4_config_get_domain			(NMIP4Config *config, guint i);
 guint32		nm_ip4_config_get_num_domains		(NMIP4Config *config);
 
+guint32 	nm_ip4_config_get_mtu			(NMIP4Config *config);
+void			nm_ip4_config_set_mtu			(NMIP4Config *config, guint32 mtu);
 
 /* Flags for nm_ip4_config_to_rtnl_addr() */
 #define NM_RTNL_ADDR_NONE		0x0000
Index: src/vpn-manager/nm-vpn-service.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/vpn-manager/nm-vpn-service.c,v
retrieving revision 1.12
diff -u -r1.12 nm-vpn-service.c
--- src/vpn-manager/nm-vpn-service.c	28 Feb 2006 22:20:32 -0000	1.12
+++ src/vpn-manager/nm-vpn-service.c	9 Mar 2006 14:58:13 -0000
@@ -61,6 +61,7 @@
 						guint32 ip4_dns_len,
 						guint32 *ip4_nbns,
 						guint32 ip4_nbns_len,
+						guint32 mtu,
 						const char *dns_domain,
 						const char *login_banner);
 #endif
@@ -809,13 +810,18 @@
 		dbus_message_iter_next (&subiter);
 	}
 
-	/* Eigth arg: DNS Domain (STRING) */
+	/* Eighth arg: MTU (UINT32) */
+	if (!get_dbus_guint32_helper (&iter, &num, "MTU"))
+		goto out;
+	nm_ip4_config_set_mtu (config, num );
+	
+	/* Ninth 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);
 
-	/* Ninth arg: VPN Login Banner (STRING) */
+	/* tenth arg: VPN Login Banner (STRING) */
 	if (!get_dbus_string_helper (&iter, &login_banner, "Login Banner"))
 		goto out;
 
@@ -829,6 +835,7 @@
 	                  ip4_dns_len,
 	                  ip4_nbns,
 	                  ip4_nbns_len,
+			  mtu,
 	                  dns_domain,
 	                  login_banner);
 #endif
@@ -1057,6 +1064,7 @@
 						guint32 ip4_dns_len,
 						guint32 *ip4_nbns,
 						guint32 ip4_nbns_len,
+						guint32 mtu,
 						const char *dns_domain,
 						const char *login_banner)
 {
@@ -1072,6 +1080,7 @@
 	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 ("MTU: %d", mtu);
 
 	for (i = 0; i < ip4_dns_len; i++)
 	{


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