Consistent usage of ip_iface vers iface



Hi,

If I read the sources right, it seems the iface/ip_iface usage is a bit inconsistent. Probably it all started out with iface and later ip_face was added for those parts that needed specifying an network interface because the original interface wasn't.
So, now I stumble into more areas where this change needs to be done.
Attached is a patch for this.

One(?) thing left (you can search for TODO in the patch) is to change in NetworkManagerPolicy.c, function update_default_route(), where the
logic depends on iface != ip_iface to mean ppp...
In my case, I would just like to have the normal path in that function even
though that the iface/ip_iface differs.
Wouldn't it be enough for ppp to set 0 for gateway and we could simplify
this function?

Best regards,
Per
Index: src/dhcp-manager/nm-dhcp-dhclient.c
===================================================================
--- src/dhcp-manager/nm-dhcp-dhclient.c	(revision 4136)
+++ src/dhcp-manager/nm-dhcp-dhclient.c	(working copy)
@@ -45,23 +45,23 @@
 
 
 static char *
-get_pidfile_for_iface (const char * iface)
+get_pidfile_for_iface (const char * ip_iface)
 {
 	return g_strdup_printf ("%s/%s-%s.%s",
 	                        NM_DHCP_MANAGER_RUN_DIR,
 	                        NM_DHCP_MANAGER_PID_FILENAME,
-	                        iface,
+	                        ip_iface,
 	                        NM_DHCP_MANAGER_PID_FILE_EXT);
 }
 
 
 static char *
-get_leasefile_for_iface (const char * iface)
+get_leasefile_for_iface (const char * ip_iface)
 {
 	return g_strdup_printf ("%s/%s-%s.%s",
 	                        NM_DHCP_MANAGER_RUN_DIR,
 	                        NM_DHCP_MANAGER_LEASE_FILENAME,
-	                        iface,
+	                        ip_iface,
 	                        NM_DHCP_MANAGER_LEASE_FILE_EXT);
 }
 
@@ -84,7 +84,7 @@
 	gboolean success = FALSE;
 
 	g_return_val_if_fail (device != NULL, FALSE);
-	g_return_val_if_fail (device->iface != NULL, FALSE);
+	g_return_val_if_fail (device->ip_iface != NULL, FALSE);
 	
 	new_contents = g_string_new (_("# Created by NetworkManager\n"));
 
@@ -157,15 +157,15 @@
 #elif defined(TARGET_DEBIAN)
 	orig = g_strdup (SYSCONFDIR "/dhcp3/dhclient.conf");
 #else
-	orig = g_strdup_printf (SYSCONFDIR "/dhclient-%s.conf", device->iface);
+	orig = g_strdup_printf (SYSCONFDIR "/dhclient-%s.conf", device->ip_iface);
 #endif
 
 	if (!orig) {
-		nm_warning ("%s: not enough memory for dhclient options.", device->iface);
+		nm_warning ("%s: not enough memory for dhclient options.", device->ip_iface);
 		return FALSE;
 	}
 
-	tmp = g_strdup_printf ("nm-dhclient-%s.conf", device->iface);
+	tmp = g_strdup_printf ("nm-dhclient-%s.conf", device->ip_iface);
 	device->conf_file = g_build_filename ("/var", "run", tmp, NULL);
 	g_free (tmp);
 
@@ -174,7 +174,7 @@
 
 	if (!g_file_get_contents (orig, &contents, NULL, &error)) {
 		nm_warning ("%s: error reading dhclient configuration %s: %s",
-		            device->iface, orig, error->message);
+		            device->ip_iface, orig, error->message);
 		g_error_free (error);
 		goto out;
 	}
@@ -185,7 +185,7 @@
 		success = TRUE;
 	else {
 		nm_warning ("%s: error creating dhclient configuration: %s",
-		            device->iface, error->message);
+		            device->ip_iface, error->message);
 		g_error_free (error);
 	}
 
@@ -218,15 +218,15 @@
 		goto out;
 	}
 
-	device->pid_file = get_pidfile_for_iface (device->iface);
+	device->pid_file = get_pidfile_for_iface (device->ip_iface);
 	if (!device->pid_file) {
-		nm_warning ("%s: not enough memory for dhclient options.", device->iface);
+		nm_warning ("%s: not enough memory for dhclient options.", device->ip_iface);
 		goto out;
 	}
 
-	device->lease_file = get_leasefile_for_iface (device->iface);
+	device->lease_file = get_leasefile_for_iface (device->ip_iface);
 	if (!device->lease_file) {
-		nm_warning ("%s: not enough memory for dhclient options.", device->iface);
+		nm_warning ("%s: not enough memory for dhclient options.", device->ip_iface);
 		goto out;
 	}
 
@@ -238,7 +238,7 @@
 		unsigned long int tmp = strtoul (pid_contents, NULL, 10);
 
 		if (!((tmp == ULONG_MAX) && (errno == ERANGE)))
-			nm_dhcp_client_stop (device->iface, (pid_t) tmp);
+			nm_dhcp_client_stop (device->ip_iface, (pid_t) tmp);
 		remove (device->pid_file);
 	}
 
@@ -259,7 +259,7 @@
 	g_ptr_array_add (dhclient_argv, (gpointer) "-cf");	/* Set interface config file */
 	g_ptr_array_add (dhclient_argv, (gpointer) device->conf_file);
 
-	g_ptr_array_add (dhclient_argv, (gpointer) device->iface);
+	g_ptr_array_add (dhclient_argv, (gpointer) device->ip_iface);
 	g_ptr_array_add (dhclient_argv, NULL);
 
 	if (!g_spawn_async (NULL, (char **) dhclient_argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
Index: src/dhcp-manager/nm-dhcp-manager.c
===================================================================
--- src/dhcp-manager/nm-dhcp-manager.c	(revision 4136)
+++ src/dhcp-manager/nm-dhcp-manager.c	(working copy)
@@ -172,7 +172,7 @@
 	nm_dhcp_device_watch_cleanup (device);
 
 	if (device->pid)
-		nm_dhcp_client_stop (device->iface, device->pid);
+		nm_dhcp_client_stop (device->ip_iface, device->pid);
 
 	if (device->options)
 		g_hash_table_destroy (device->options);
@@ -184,7 +184,7 @@
 
 	g_free (device->pid_file);
 	g_free (device->lease_file);
-	g_free (device->iface);
+	g_free (device->ip_iface);
 	g_slice_free (NMDHCPDevice, device);
 }
 
@@ -364,14 +364,14 @@
 
 	device->state = new_state;
 	nm_info ("DHCP: device %s state changed %s -> %s",
-	         device->iface,
+	         device->ip_iface,
 	         state_to_string (old_state),
 	         state_to_string (device->state));
 
 	g_signal_emit (G_OBJECT (device->manager),
 	               signals[STATE_CHANGED],
 	               0,
-	               device->iface,
+	               device->ip_iface,
 	               device->state);
 }
 
@@ -383,7 +383,7 @@
 	NMDHCPManager * manager;
 	NMDHCPManagerPrivate * priv;
 	NMDHCPDevice * device;
-	char * iface = NULL;
+	char * ip_iface = NULL;
 	char * pid_str = NULL;
 	char * reason = NULL;
 	unsigned long temp;
@@ -392,15 +392,15 @@
 	manager = NM_DHCP_MANAGER (user_data);
 	priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
 
-	iface = get_option (options, "interface");
-	if (iface == NULL) {
+	ip_iface = get_option (options, "interface");
+	if (ip_iface == NULL) {
 		nm_warning ("DHCP event didn't have associated interface.");
 		goto out;
 	}
 
-	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, iface);
+	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, ip_iface);
 	if (device == NULL) {
-		nm_warning ("Unhandled DHCP event for interface %s", iface);
+		nm_warning ("Unhandled DHCP event for interface %s", ip_iface);
 		goto out;
 	}
 
@@ -433,7 +433,7 @@
 	handle_options (manager, device, options, reason);
 
 out:
-	g_free (iface);
+	g_free (ip_iface);
 	g_free (pid_str);
 	g_free (reason);
 }
@@ -497,32 +497,32 @@
 	NMDHCPDevice *device = (NMDHCPDevice *) user_data;
 
 	nm_info ("Device '%s' DHCP transaction took too long (>%ds), stopping it.",
-			 device->iface, NM_DHCP_TIMEOUT);
+			 device->ip_iface, NM_DHCP_TIMEOUT);
 
-	nm_dhcp_manager_cancel_transaction (device->manager, device->iface);
+	nm_dhcp_manager_cancel_transaction (device->manager, device->ip_iface);
 
-	g_signal_emit (G_OBJECT (device->manager), signals[TIMEOUT], 0, device->iface);
+	g_signal_emit (G_OBJECT (device->manager), signals[TIMEOUT], 0, device->ip_iface);
 
 	return FALSE;
 }
 
 static NMDHCPDevice *
-nm_dhcp_device_new (NMDHCPManager *manager, const char *iface)
+nm_dhcp_device_new (NMDHCPManager *manager, const char *ip_iface)
 {
 	NMDHCPDevice *device;
 	GHashTable * hash = NM_DHCP_MANAGER_GET_PRIVATE (manager)->devices;
 
 	device = g_slice_new0 (NMDHCPDevice);
 	if (!device) {
-		nm_warning ("%s: Out of memory creating DHCP transaction object.", iface);
+		nm_warning ("%s: Out of memory creating DHCP transaction object.", ip_iface);
 		return NULL;
 	}
 
-	device->iface = g_strdup (iface);
+	device->ip_iface = g_strdup (ip_iface);
 	if (!device) {
 		nm_warning ("%s: Out of memory creating DHCP transaction object "
-		            "property 'iface'.",
-		            iface);
+		            "property 'ip_iface'.",
+		            ip_iface);
 		goto error;
 	}
 	
@@ -536,11 +536,11 @@
 	if (!device->options) {
 		nm_warning ("%s: Out of memory creating DHCP transaction object "
 		            "property 'options'.",
-		            iface);
+		            ip_iface);
 		goto error;
 	}
 
-	g_hash_table_insert (hash, device->iface, device);
+	g_hash_table_insert (hash, device->ip_iface, device);
 	return device;
 
 error:
@@ -568,12 +568,12 @@
 	nm_dhcp_device_watch_cleanup (device);
 	nm_dhcp_device_timeout_cleanup (device);
 
-	g_signal_emit (G_OBJECT (device->manager), signals[STATE_CHANGED], 0, device->iface, device->state);
+	g_signal_emit (G_OBJECT (device->manager), signals[STATE_CHANGED], 0, device->ip_iface, device->state);
 }
 
 gboolean
 nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
-								   const char *iface,
+								   const char *ip_iface,
 								   NMSettingIP4Config *s_ip4,
 								   guint32 timeout)
 {
@@ -581,20 +581,20 @@
 	NMDHCPDevice *device;
 
 	g_return_val_if_fail (NM_IS_DHCP_MANAGER (manager), FALSE);
-	g_return_val_if_fail (iface != NULL, FALSE);
+	g_return_val_if_fail (ip_iface != NULL, FALSE);
 
 	priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
 
-	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, iface);
+	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, ip_iface);
 	if (!device)
-		device = nm_dhcp_device_new (manager, iface);
+		device = nm_dhcp_device_new (manager, ip_iface);
 
 	if (state_is_bound (device->state) || (device->state == DHC_START)) {
 		/* Cancel any DHCP transaction already in progress */
 		nm_dhcp_manager_cancel_transaction_real (device);
 	}
 
-	nm_info ("Activation (%s) Beginning DHCP transaction.", iface);
+	nm_info ("Activation (%s) Beginning DHCP transaction.", ip_iface);
 
 	if (timeout == 0)
 		timeout = NM_DHCP_TIMEOUT;
@@ -612,7 +612,7 @@
 }
 
 void
-nm_dhcp_client_stop (const char * iface, pid_t pid)
+nm_dhcp_client_stop (const char * ip_iface, pid_t pid)
 {
 	int i = 15; /* 3 seconds */
 
@@ -639,7 +639,7 @@
 	}
 
 	if (i <= 0) {
-		nm_warning ("%s: dhcp client pid %d didn't exit, will kill it.", iface, pid);
+		nm_warning ("%s: dhcp client pid %d didn't exit, will kill it.", ip_iface, pid);
 		kill (pid, SIGKILL);
 
 		nm_debug ("waiting for dhcp client pid %d to exit", pid);
@@ -654,10 +654,10 @@
 	if (!device->pid)
 		return;
 
-	nm_dhcp_client_stop (device->iface, device->pid);
+	nm_dhcp_client_stop (device->ip_iface, device->pid);
 
 	nm_info ("%s: canceled DHCP transaction, dhcp client pid %d",
-	         device->iface,
+	         device->ip_iface,
 	         device->pid);
 
 	device->pid = 0;
@@ -695,17 +695,17 @@
  */
 void
 nm_dhcp_manager_cancel_transaction (NMDHCPManager *manager,
-                                    const char *iface)
+                                    const char *ip_iface)
 {
 	NMDHCPDevice *device;
 	NMDHCPManagerPrivate *priv;
 
 	g_return_if_fail (NM_IS_DHCP_MANAGER (manager));
-	g_return_if_fail (iface != NULL);
+	g_return_if_fail (ip_iface != NULL);
 
 	priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
 
-	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, iface);
+	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, ip_iface);
 
 	if (!device || !device->pid)
 		return;
@@ -722,7 +722,7 @@
  */
 NMIP4Config *
 nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager,
-                                const char *iface)
+                                const char *ip_iface)
 {
 	NMDHCPManagerPrivate *priv;
 	NMDHCPDevice *device;
@@ -732,30 +732,30 @@
 	char *str = NULL;
 
 	g_return_val_if_fail (NM_IS_DHCP_MANAGER (manager), NULL);
-	g_return_val_if_fail (iface != NULL, NULL);
+	g_return_val_if_fail (ip_iface != NULL, NULL);
 
 	priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
 
-	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, iface);
+	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, ip_iface);
 	if (!device) {
-		nm_warning ("Device '%s' transaction not started.", iface);
+		nm_warning ("Device '%s' transaction not started.", ip_iface);
 		return NULL;
 	}
 
 	if (!state_is_bound (device->state)) {
-		nm_warning ("%s: dhcp client didn't bind to a lease.", device->iface);
+		nm_warning ("%s: dhcp client didn't bind to a lease.", device->ip_iface);
 		return NULL;
 	}
 
 	ip4_config = nm_ip4_config_new ();
 	if (!ip4_config) {
-		nm_warning ("%s: couldn't allocate memory for an IP4Config!", device->iface);
+		nm_warning ("%s: couldn't allocate memory for an IP4Config!", device->ip_iface);
 		return NULL;
 	}
 
 	addr = g_malloc0 (sizeof (NMSettingIP4Address));
 	if (!addr) {
-		nm_warning ("%s: couldn't allocate memory for an IP4 Address!", device->iface);
+		nm_warning ("%s: couldn't allocate memory for an IP4 Address!", device->ip_iface);
 		goto error;
 	}
 
@@ -931,26 +931,26 @@
 
 gboolean
 nm_dhcp_manager_set_dhcp4_config (NMDHCPManager *self,
-                                  const char *iface,
+                                  const char *ip_iface,
                                   NMDHCP4Config *config)
 {
 	NMDHCPManagerPrivate *priv;
 	NMDHCPDevice *device;
 
 	g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), FALSE);
-	g_return_val_if_fail (iface != NULL, FALSE);
+	g_return_val_if_fail (ip_iface != NULL, FALSE);
 	g_return_val_if_fail (config != NULL, FALSE);
 
 	priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
 
-	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, iface);
+	device = (NMDHCPDevice *) g_hash_table_lookup (priv->devices, ip_iface);
 	if (!device) {
-		nm_warning ("Device '%s' transaction not started.", iface);
+		nm_warning ("Device '%s' transaction not started.", ip_iface);
 		return FALSE;
 	}
 
 	if (!state_is_bound (device->state)) {
-		nm_warning ("%s: dhclient didn't bind to a lease.", device->iface);
+		nm_warning ("%s: dhclient didn't bind to a lease.", device->ip_iface);
 		return FALSE;
 	}
 
Index: src/dhcp-manager/nm-dhcp-manager.h
===================================================================
--- src/dhcp-manager/nm-dhcp-manager.h	(revision 4136)
+++ src/dhcp-manager/nm-dhcp-manager.h	(working copy)
@@ -66,12 +66,12 @@
 	GObjectClass parent;
 
 	/* Signals */
-	void (*state_changed) (NMDHCPManager *manager, char *iface, NMDHCPState state);
-	void (*timeout)       (NMDHCPManager *manager, char *iface);
+	void (*state_changed) (NMDHCPManager *manager, char *ip_iface, NMDHCPState state);
+	void (*timeout)       (NMDHCPManager *manager, char *ip_iface);
 } NMDHCPManagerClass;
 
 typedef struct {
-        char *			iface;
+        char *			ip_iface;
         guchar			state;
         GPid			pid;
         char *			pid_file;
@@ -87,21 +87,21 @@
 
 NMDHCPManager *nm_dhcp_manager_get                  (void);
 gboolean       nm_dhcp_manager_begin_transaction    (NMDHCPManager *manager,
-                                                     const char *iface,
+                                                     const char *ip_iface,
                                                      NMSettingIP4Config *s_ip4,
                                                      guint32 timeout);
 void           nm_dhcp_manager_cancel_transaction   (NMDHCPManager *manager,
-                                                     const char *iface);
-NMIP4Config *  nm_dhcp_manager_get_ip4_config       (NMDHCPManager *manager, const char *iface);
-NMDHCPState    nm_dhcp_manager_get_state_for_device (NMDHCPManager *manager, const char *iface);
+                                                     const char *ip_iface);
+NMIP4Config *  nm_dhcp_manager_get_ip4_config       (NMDHCPManager *manager, const char *ip_iface);
+NMDHCPState    nm_dhcp_manager_get_state_for_device (NMDHCPManager *manager, const char *ip_iface);
 
 gboolean       nm_dhcp_manager_set_dhcp4_config     (NMDHCPManager *manager,
-                                                     const char *iface,
+                                                     const char *ip_iface,
                                                      NMDHCP4Config *config);
 
 gboolean       nm_dhcp_manager_process_signal       (NMDHCPManager *manager, DBusMessage *message);
 
 gboolean       nm_dhcp_client_start                 (NMDHCPDevice *device, NMSettingIP4Config *s_ip4);
-void           nm_dhcp_client_stop                  (const char *iface, pid_t pid);
+void           nm_dhcp_client_stop                  (const char *ip_iface, pid_t pid);
 
 #endif /* NM_DHCP_MANAGER_H */
Index: src/dhcp-manager/nm-dhcp-dhcpcd.c
===================================================================
--- src/dhcp-manager/nm-dhcp-dhcpcd.c	(revision 4136)
+++ src/dhcp-manager/nm-dhcp-dhcpcd.c	(working copy)
@@ -40,11 +40,11 @@
 
 
 static char *
-get_pidfile_for_iface (const char * iface)
+get_pidfile_for_iface (const char * ip_iface)
 {
 	return g_strdup_printf ("/var/run/%s-%s.%s",
 	                        NM_DHCP_MANAGER_PID_FILENAME,
-	                        iface,
+	                        ip_iface,
 	                        NM_DHCP_MANAGER_PID_FILE_EXT);
 }
 
@@ -72,9 +72,9 @@
 		goto out;
 	}
 
-	device->pid_file = get_pidfile_for_iface (device->iface);
+	device->pid_file = get_pidfile_for_iface (device->ip_iface);
 	if (!device->pid_file) {
-		nm_warning ("%s: not enough memory for dhcpcd options.", device->iface);
+		nm_warning ("%s: not enough memory for dhcpcd options.", device->ip_iface);
 		goto out;
 	}
 
@@ -83,7 +83,7 @@
 		unsigned long int tmp = strtoul (pid_contents, NULL, 10);
 
 		if (!((tmp == ULONG_MAX) && (errno == ERANGE)))
-			nm_dhcp_client_stop (device->iface, (pid_t) tmp);
+			nm_dhcp_client_stop (device->ip_iface, (pid_t) tmp);
 		remove (device->pid_file);
 	}
 
@@ -99,7 +99,7 @@
 	g_ptr_array_add (argv, (gpointer) "-c");	/* Set script file */
 	g_ptr_array_add (argv, (gpointer) ACTION_SCRIPT_PATH );
 
-	g_ptr_array_add (argv, (gpointer) device->iface);
+	g_ptr_array_add (argv, (gpointer) device->ip_iface);
 	g_ptr_array_add (argv, NULL);
 
 	if (!g_spawn_async (NULL, (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
Index: src/nm-hal-manager.c
===================================================================
--- src/nm-hal-manager.c	(revision 4136)
+++ src/nm-hal-manager.c	(working copy)
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
 
 #include <signal.h>
+#include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <libhal.h>
@@ -333,6 +334,7 @@
 		device = (GObject *) nm_cdma_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
 
 out:
+	libhal_free_string (parent_udi);
 	libhal_free_string (serial_device);
 	libhal_free_string (driver_name);
 
Index: src/NetworkManagerPolicy.c
===================================================================
--- src/NetworkManagerPolicy.c	(revision 4136)
+++ src/NetworkManagerPolicy.c	(working copy)
@@ -470,9 +470,14 @@
 	   treat it as such. However, if they differ, it's most likely something like
 	   a serial device with ppp interface, so route all the traffic to it. */
 	ip_iface = nm_device_get_ip_iface (new);
+#if 0
+TODO
 	if (strcmp (ip_iface, nm_device_get_iface (new))) {
 		nm_system_device_replace_default_ip4_route (ip_iface, 0, 0);
 	} else {
+#else
+	{
+#endif
 		NMIP4Config *config;
 		const NMSettingIP4Address *def_addr;
 
@@ -527,7 +532,7 @@
 		nm_act_request_set_default (best_req, TRUE);
 
 	nm_info ("Policy set (%s) as default device for routing and DNS.",
-	         nm_device_get_iface (best));
+	         nm_device_get_ip_iface (best));
 
 out:
 	/* Update the system hostname */
Index: src/nm-device.c
===================================================================
--- src/nm-device.c	(revision 4136)
+++ src/nm-device.c	(working copy)
@@ -248,7 +248,6 @@
 	return self->priv->iface;
 }
 
-
 const char *
 nm_device_get_ip_iface (NMDevice *self)
 {
@@ -263,12 +262,10 @@
 nm_device_set_ip_iface (NMDevice *self, const char *iface)
 {
 	g_return_if_fail (NM_IS_DEVICE (self));
-
 	g_free (self->priv->ip_iface);
 	self->priv->ip_iface = iface ? g_strdup (iface) : NULL;
 }
 
-
 /*
  * Get/set functions for driver
  */
@@ -835,11 +832,11 @@
 	NMSettingIP4Config *s_ip4;
 	NMActRequest *req;
 	NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
-	const char *iface;
+	const char *ip_iface;
 
 	g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
 
-	iface = nm_device_get_iface (self);
+	ip_iface = nm_device_get_ip_iface (self);
 
 	req = nm_device_get_act_request (self);
 	s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (nm_act_request_get_connection (req),
@@ -856,7 +853,7 @@
 		/* DHCP manager will cancel any transaction already in progress and we do not
 		   want to cancel this activation if we get "down" state from that. */
 		g_signal_handler_block (priv->dhcp_manager, priv->dhcp_state_sigid);
-		success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, iface, s_ip4, 45);
+		success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, ip_iface, s_ip4, 45);
 		g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid);
 
 		if (success) {
@@ -874,11 +871,11 @@
 		/* Start avahi-autoipd */
 		if (aipd_exec (self, &error)) {
 			nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) started"
-			         " avahi-autoipd...", iface);
+			         " avahi-autoipd...", ip_iface);
 			ret = NM_ACT_STAGE_RETURN_POSTPONE;
 		} else {
 			nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) failed"
-			         " to start avahi-autoipd: %s", iface, error->message);
+			         " to start avahi-autoipd: %s", ip_iface, error->message);
 			g_error_free (error);
 			aipd_cleanup (self);
 			*reason = NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED;
@@ -900,7 +897,7 @@
 nm_device_activate_stage3_ip_config_start (gpointer user_data)
 {
 	NMDevice *self = NM_DEVICE (user_data);
-	const char *iface;
+	const char *ip_iface;
 	NMActStageReturn ret;
 	NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
 
@@ -908,8 +905,8 @@
 	if (self->priv->act_source_id > 0)
 		self->priv->act_source_id = 0;
 
-	iface = nm_device_get_iface (self);
-	nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) started...", iface);
+	ip_iface = nm_device_get_ip_iface (self);
+	nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) started...", ip_iface);
 	nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
 
 	ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip_config_start (self, &reason);
@@ -925,7 +922,7 @@
 	nm_device_activate_schedule_stage4_ip_config_get (self);
 
 out:
-	nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) complete.", iface);
+	nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) complete.", ip_iface);
 	return FALSE;
 }
 
@@ -948,7 +945,7 @@
 	self->priv->act_source_id = g_idle_add (nm_device_activate_stage3_ip_config_start, self);
 
 	nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) scheduled.",
-	         nm_device_get_iface (self));
+	         nm_device_get_ip_iface (self));
 }
 
 static GHashTable *shared_ips = NULL;
@@ -1017,13 +1014,13 @@
 	NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
 	NMConnection *connection;
 	NMSettingIP4Config *s_ip4;
-	const char *iface;
+	const char *ip_iface;
 
 	g_return_val_if_fail (config != NULL, NM_ACT_STAGE_RETURN_FAILURE);
 	g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
 	g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
 
-	iface = nm_device_get_iface (self);
+	ip_iface = nm_device_get_ip_iface (self);
 
 	connection = nm_act_request_get_connection (nm_device_get_act_request (self));
 	g_assert (connection);
@@ -1031,11 +1028,11 @@
 	s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
 
 	if (nm_device_get_use_dhcp (self)) {
-		*config = nm_dhcp_manager_get_ip4_config (priv->dhcp_manager, iface);
+		*config = nm_dhcp_manager_get_ip4_config (priv->dhcp_manager, ip_iface);
 		if (*config) {
 			nm_utils_merge_ip4_config (*config, s_ip4);
 
-			nm_dhcp_manager_set_dhcp4_config (priv->dhcp_manager, iface, priv->dhcp4_config);
+			nm_dhcp_manager_set_dhcp4_config (priv->dhcp_manager, ip_iface, priv->dhcp4_config);
 			/* Notify of new DHCP4 config */
 			g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP4_CONFIG);
 		} else
@@ -1055,7 +1052,7 @@
 		} else if (!strcmp (s_ip4->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
 			*config = nm_device_new_ip4_shared_config (self, reason);
 			if (*config)
-				priv->dnsmasq_manager = nm_dnsmasq_manager_new (iface);
+				priv->dnsmasq_manager = nm_dnsmasq_manager_new (ip_iface);
 		}
 	}
 
@@ -1081,15 +1078,15 @@
 	NMDevice *self = NM_DEVICE (user_data);
 	NMIP4Config *ip4_config = NULL;
 	NMActStageReturn ret;
-	const char *iface = NULL;
+	const char *ip_iface = NULL;
 	NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
 
 	/* Clear the activation source ID now that this stage has run */
 	if (self->priv->act_source_id > 0)
 		self->priv->act_source_id = 0;
 
-	iface = nm_device_get_iface (self);
-	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) started...", iface);
+	ip_iface = nm_device_get_ip_iface (self);
+	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) started...", ip_iface);
 
 	ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip4_config (self, &ip4_config, &reason);
 	if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
@@ -1107,7 +1104,7 @@
 	nm_device_activate_schedule_stage5_ip_config_commit (self);
 
 out:
-	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) complete.", iface);
+	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) complete.", ip_iface);
 	return FALSE;
 }
 
@@ -1131,7 +1128,7 @@
 	priv->act_source_id = g_idle_add (nm_device_activate_stage4_ip_config_get, self);
 
 	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) scheduled...",
-	         nm_device_get_iface (self));
+	         nm_device_get_ip_iface (self));
 }
 
 
@@ -1163,7 +1160,7 @@
 {
 	NMDevice *self = NM_DEVICE (user_data);
 	NMIP4Config *ip4_config = NULL;
-	const char *iface;
+	const char *ip_iface;
 	NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
 	NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
 
@@ -1171,8 +1168,8 @@
 	if (self->priv->act_source_id > 0)
 		self->priv->act_source_id = 0;
 
-	iface = nm_device_get_iface (self);
-	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) started...", iface);
+	ip_iface = nm_device_get_ip_iface (self);
+	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) started...", ip_iface);
 
 	ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip_config_timeout (self, &ip4_config, &reason);
 	if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
@@ -1190,7 +1187,7 @@
 	nm_device_activate_schedule_stage5_ip_config_commit (self);
 
 out:
-	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) complete.", iface);
+	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) complete.", ip_iface);
 	return FALSE;
 }
 
@@ -1214,7 +1211,7 @@
 	priv->act_source_id = g_idle_add (nm_device_activate_stage4_ip_config_timeout, self);
 
 	nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) scheduled...",
-	         nm_device_get_iface (self));
+	         nm_device_get_ip_iface (self));
 }
 
 static void
@@ -1298,11 +1295,11 @@
 	guint32 netmask, network;
 	NMIP4Config *ip4_config;
 	const NMSettingIP4Address *ip4_addr;
-	const char *iface;
+	const char *ip_iface;
 
-	iface = nm_device_get_ip_iface (self);
-	if (!iface)
-		iface = nm_device_get_iface (self);
+	ip_iface = nm_device_get_ip_iface (self);
+	if (!ip_iface)
+		ip_iface = nm_device_get_ip_iface (self);
 
 	ip4_config = nm_device_get_ip4_config (self);
 	if (!ip4_config)
@@ -1326,21 +1323,21 @@
 	req = nm_device_get_act_request (self);
 	g_assert (req);
 
-	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 53 --jump ACCEPT", iface);
-	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 53 --jump ACCEPT", iface);
-	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 67 --jump ACCEPT", iface);
-	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 67 --jump ACCEPT", iface);
-	add_share_rule (req, "filter", "FORWARD --in-interface %s --jump REJECT", iface);
-	add_share_rule (req, "filter", "FORWARD --out-interface %s --jump REJECT", iface);
-	add_share_rule (req, "filter", "FORWARD --in-interface %s --out-interface %s --jump ACCEPT", iface, iface);
-	add_share_rule (req, "filter", "FORWARD --source %s/%s --in-interface %s --jump ACCEPT", str_addr, str_mask, iface);
-	add_share_rule (req, "filter", "FORWARD --destination %s/%s --out-interface %s --match state --state ESTABLISHED,RELATED --jump ACCEPT", str_addr, str_mask, iface);
+	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 53 --jump ACCEPT", ip_iface);
+	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 53 --jump ACCEPT", ip_iface);
+	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 67 --jump ACCEPT", ip_iface);
+	add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 67 --jump ACCEPT", ip_iface);
+	add_share_rule (req, "filter", "FORWARD --in-interface %s --jump REJECT", ip_iface);
+	add_share_rule (req, "filter", "FORWARD --out-interface %s --jump REJECT", ip_iface);
+	add_share_rule (req, "filter", "FORWARD --in-interface %s --out-interface %s --jump ACCEPT", ip_iface, ip_iface);
+	add_share_rule (req, "filter", "FORWARD --source %s/%s --in-interface %s --jump ACCEPT", str_addr, str_mask, ip_iface);
+	add_share_rule (req, "filter", "FORWARD --destination %s/%s --out-interface %s --match state --state ESTABLISHED,RELATED --jump ACCEPT", str_addr, str_mask, ip_iface);
 	add_share_rule (req, "nat", "POSTROUTING --source %s/%s --destination ! %s/%s --jump MASQUERADE", str_addr, str_mask, str_addr, str_mask);
 
 	nm_act_request_set_shared (req, TRUE);
 
 	if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, ip4_config, &error)) {
-		nm_warning ("(%s): failed to start dnsmasq: %s", iface, error->message);
+		nm_warning ("(%s): failed to start dnsmasq: %s", ip_iface, error->message);
 		g_error_free (error);
 		nm_act_request_set_shared (req, FALSE);
 		return FALSE;
@@ -1364,7 +1361,7 @@
 	NMDevice *self = NM_DEVICE (user_data);
 	NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
 	NMIP4Config *ip4_config = NULL;
-	const char *iface;
+	const char *ip_iface;
 	NMConnection *connection;
 	NMSettingIP4Config *s_ip4;
 	NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
@@ -1377,9 +1374,9 @@
 	if (priv->act_source_id > 0)
 		priv->act_source_id = 0;
 
-	iface = nm_device_get_iface (self);
+	ip_iface = nm_device_get_ip_iface (self);
 	nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) started...",
-	         iface);
+	         ip_iface);
 
 	if (!nm_device_set_ip4_config (self, ip4_config, &reason)) {
 		nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
@@ -1390,7 +1387,7 @@
 	s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
 	if (s_ip4 && !strcmp (s_ip4->method, "shared")) {
 		if (!start_sharing (self)) {
-			nm_warning ("Activation (%s) Stage 5 of 5 (IP Configure Commit) start sharing failed.", iface);
+			nm_warning ("Activation (%s) Stage 5 of 5 (IP Configure Commit) start sharing failed.", ip_iface);
 			nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
 			goto out;
 		}
@@ -1400,7 +1397,7 @@
 
 out:
 	nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) complete.",
-	         iface);
+	         ip_iface);
 
 	/* Balance IP4Config creation; device takes ownership in set_ip4_config() */
 	g_object_unref (ip4_config);
@@ -1427,7 +1424,7 @@
 	priv->act_source_id = g_idle_add (nm_device_activate_stage5_ip_config_commit, self);
 
 	nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) scheduled...",
-	         nm_device_get_iface (self));
+	         nm_device_get_ip_iface (self));
 }
 
 
@@ -1492,7 +1489,7 @@
 	/* Stop any ongoing DHCP transaction on this device */
 	if (nm_device_get_act_request (self)) {
 		if (nm_device_get_use_dhcp (self)) {
-			nm_dhcp_manager_cancel_transaction (priv->dhcp_manager, nm_device_get_iface (self));
+			nm_dhcp_manager_cancel_transaction (priv->dhcp_manager, nm_device_get_ip_iface (self));
 			nm_device_set_use_dhcp (self, FALSE);
 			/* Notify of invalid DHCP4 config */
 			g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP4_CONFIG);
@@ -1716,8 +1713,7 @@
 		return;
 	}
 
-	config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (device)->dhcp_manager,
-											 nm_device_get_iface (device));
+	config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (device)->dhcp_manager, nm_device_get_ip_iface (device));
 	if (!config) {
 		nm_warning ("failed to get DHCP config for rebind");
 		nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
@@ -1739,12 +1735,12 @@
 		nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
 	}
 
-	nm_dhcp_manager_set_dhcp4_config (priv->dhcp_manager, nm_device_get_iface (device), priv->dhcp4_config);
+	nm_dhcp_manager_set_dhcp4_config (priv->dhcp_manager, nm_device_get_ip_iface (device), priv->dhcp4_config);
 }
 
 static void
 dhcp_state_changed (NMDHCPManager *dhcp_manager,
-					const char *iface,
+					const char *ip_iface,
 					NMDHCPState state,
 					gpointer user_data)
 {
@@ -1752,7 +1748,7 @@
 	NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
 	NMDeviceState dev_state;
 
-	if (strcmp (nm_device_get_iface (device), iface) != 0)
+	if (strcmp (nm_device_get_ip_iface (device), ip_iface) != 0)
 		return;
 
 	if (!nm_device_get_act_request (device))
@@ -1797,12 +1793,12 @@
 
 static void
 dhcp_timeout (NMDHCPManager *dhcp_manager,
-              const char *iface,
+              const char *ip_iface,
               gpointer user_data)
 {
 	NMDevice * device = NM_DEVICE (user_data);
 
-	if (strcmp (nm_device_get_iface (device), iface) != 0)
+	if (strcmp (nm_device_get_ip_iface (device), ip_iface) != 0)
 		return;
 
 	if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG)
@@ -1960,7 +1956,7 @@
 	}
 
 	memset (&req, 0, sizeof (struct ifreq));
-	strncpy (req.ifr_name, nm_device_get_iface (self), IFNAMSIZ);
+	strncpy (req.ifr_name, nm_device_get_ip_iface (self), IFNAMSIZ);
 	err = ioctl (fd, SIOCGIFADDR, &req);
 	close (fd);
 
@@ -1994,7 +1990,7 @@
 	if (nm_device_hw_is_up (self))
 		goto out;
 
-	nm_info ("(%s): bringing up device.", nm_device_get_iface (self));
+	nm_info ("(%s): bringing up device.", nm_device_get_ip_iface (self));
 
 	if (NM_DEVICE_GET_CLASS (self)->hw_bring_up) {
 		success = NM_DEVICE_GET_CLASS (self)->hw_bring_up (self, no_firmware);
@@ -2007,7 +2003,7 @@
 		g_usleep (200);
 
 	if (!nm_device_hw_is_up (self)) {
-		nm_warning ("(%s): device not up after timeout!", nm_device_get_iface (self));
+		nm_warning ("(%s): device not up after timeout!", nm_device_get_ip_iface (self));
 		return FALSE;
 	}
 
@@ -2030,7 +2026,7 @@
 	if (!nm_device_hw_is_up (self))
 		return;
 
-	nm_info ("(%s): taking down device.", nm_device_get_iface (self));
+	nm_info ("(%s): taking down device.", nm_device_get_ip_iface (self));
 
 	if (NM_DEVICE_GET_CLASS (self)->hw_take_down)
 		NM_DEVICE_GET_CLASS (self)->hw_take_down (self);
@@ -2053,7 +2049,7 @@
 	if (nm_device_is_up (self))
 		return TRUE;
 
-	nm_info ("(%s): preparing device.", nm_device_get_iface (self));
+	nm_info ("(%s): preparing device.", nm_device_get_ip_iface (self));
 
 	if (NM_DEVICE_GET_CLASS (self)->bring_up)
 		success = NM_DEVICE_GET_CLASS (self)->bring_up (self);
@@ -2070,7 +2066,7 @@
 		nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self));
 
 	if (nm_device_is_up (self)) {
-		nm_info ("(%s): cleaning up...", nm_device_get_iface (self));
+		nm_info ("(%s): cleaning up...", nm_device_get_ip_iface (self));
 
 		if (NM_DEVICE_GET_CLASS (self)->take_down)
 			NM_DEVICE_GET_CLASS (self)->take_down (self);
@@ -2165,6 +2161,8 @@
 	case NM_DEVICE_INTERFACE_PROP_IFACE:
 		g_free (priv->iface);
 		priv->iface = g_value_dup_string (value);
+		g_free (priv->ip_iface);
+		priv->ip_iface = g_value_dup_string (value);
 		break;
 	case NM_DEVICE_INTERFACE_PROP_DRIVER:
 		priv->driver = g_strdup (g_value_get_string (value));


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