[PATCH] /proc entries and renaming interfaces

Ian Rawley chrysis
Mon Jan 30 19:59:50 PST 2006


Sorry about the last patch.  Was having difficulties getting the diff to
ignore the whitespace I wanted ignored and so was playing around with the
options.  Looks like I forgot to include unified when I made the final
patch.  Attached is the unified version.

Thanks,
Ian Rawley.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.shmoo.com/pipermail/hostap/attachments/20060131/32783afc/attachment.htm 
-------------- next part --------------
Index: hostap_working/driver/modules/hostap.c
===================================================================
RCS file: /cvs/hostap/driver/modules/hostap.c,v
retrieving revision 1.78
diff -u -w -b -B -r1.78 hostap.c
--- hostap_working/driver/modules/hostap.c	6 Aug 2005 17:47:10 -0000	1.78
+++ hostap_working/driver/modules/hostap.c	31 Jan 2006 03:52:01 -0000
@@ -1170,6 +1170,49 @@
 	return ret;
 }
 
+/*
+ * Callback function for the receipt of net device events.
+ * Only deals with events related to interface names changing.
+ * When one of the hostap interfaces has it's name changed
+ * remove all of its /proc entries and put new ones in the 
+ * right place.
+ */
+
+static int hostap_rcv_dev_event(struct notifier_block *this, unsigned long event,
+		void *ptr)
+{
+	struct net_device *dev = ptr;
+	struct hostap_interface *iface = NULL;
+	local_info_t * local = NULL;
+	
+	if(event == NETDEV_CHANGENAME)
+	{
+		/*
+		 * Only hostap interfaces will be using this
+		 * particular function, so this identifies
+		 * the device as a hostap device.
+		 */
+		if( dev->do_ioctl != hostap_ioctl) return NOTIFY_DONE;
+		
+		iface = dev->priv;
+		local = iface->local;
+		
+		if(local->ddev == dev)
+		{
+			hostap_free_data(local->ap);
+			hostap_remove_proc(local);
+			hostap_init_proc(local);
+			hostap_init_data(local);
+			hostap_init_ap_proc(local);
+		}
+	}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block hostap_dev_notifier = {
+	.notifier_call = hostap_rcv_dev_event,
+};
 
 struct proc_dir_entry *hostap_proc;
 
@@ -1185,12 +1229,26 @@
 	} else
 		hostap_proc = NULL;
 
+	/*
+	 * Register for net device events so we can relocate
+	 * /proc entries on name changes.
+	 */
+	register_netdevice_notifier(&hostap_dev_notifier);
+	
 	return 0;
 }
 
 
 static void __exit hostap_exit(void)
 {
+	/*
+	 * Unregister our desire to receive net device
+	 * events as we are packing up, and no longer need
+	 * to know if interfaces have their names changed.
+	 */
+	unregister_netdevice_notifier(&hostap_dev_notifier);
+	
+	
 	if (hostap_proc != NULL) {
 		hostap_proc = NULL;
 		remove_proc_entry("hostap", proc_net);



More information about the Hostap mailing list