[PATCH 2.5.67] Update VLAN to new module semantics

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

 



The following patch to vlan code:

Module fixes:
* Uses try_module_get/put to be compatiable with 2.5 module handling
   and not generate compiler warnings.
* Set owner field so other access to device gets reference count as well.

There still is a race in the vlan_ioctl_hook path with module unloading,
looking into how to fix this without exposing more grossness.

Locking related:
* Use sychrnonize_net() on unregister rather than calling brlock
* Get rid of extranous include of brlock
* don't init next field in packet_type (comes up 0 anyway),
  so it can be changed to list macros() without changing this code.

Tested by using vconfig on SMP host.


diff -Nru a/net/8021q/vlan.c b/net/8021q/vlan.c
--- a/net/8021q/vlan.c	Tue Apr  8 11:03:30 2003
+++ b/net/8021q/vlan.c	Tue Apr  8 11:03:30 2003
@@ -29,7 +29,6 @@
 #include <net/p8022.h>
 #include <net/arp.h>
 #include <linux/rtnetlink.h>
-#include <linux/brlock.h>
 #include <linux/notifier.h>
 
 #include <linux/if_vlan.h>
@@ -68,7 +67,6 @@
 	.dev =NULL,
 	.func = vlan_skb_recv, /* VLAN receive method */
 	.data = (void *)(-1),  /* Set here '(void *)1' when this code can SHARE SKBs */
-	.next = NULL
 };
 
 /* End of global variables definitions. */
@@ -231,9 +229,8 @@
 				real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
 			}
 
-			br_write_lock(BR_NETPROTO_LOCK);
 			grp->vlan_devices[vlan_id] = NULL;
-			br_write_unlock(BR_NETPROTO_LOCK);
+			synchronize_net();
 
 
 			/* Caller unregisters (and if necessary, puts)
@@ -266,7 +263,7 @@
 				ret = 1;
 			}
 
-			MOD_DEC_USE_COUNT;
+			module_put(THIS_MODULE);
 		}
 	}
 
@@ -433,6 +430,7 @@
 	/* set up method calls */
 	new_dev->init = vlan_dev_init;
 	new_dev->destructor = vlan_dev_destruct;
+	new_dev->owner = THIS_MODULE;
 	    
 	/* new_dev->ifindex = 0;  it will be set when added to
 	 * the global list.
@@ -540,11 +538,12 @@
 	register_netdevice(new_dev);
 
 	rtnl_unlock();
-	    
+
 	/* NOTE:  We have a reference to the real device,
 	 * so hold on to the reference.
 	 */
-	MOD_INC_USE_COUNT; /* Add was a success!! */
+	try_module_get(THIS_MODULE);
+
 #ifdef VLAN_DEBUG
 	printk(VLAN_DBG "Allocated new device successfully, returning.\n");
 #endif
diff -Nru a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
--- a/net/8021q/vlan_dev.c	Tue Apr  8 11:03:30 2003
+++ b/net/8021q/vlan_dev.c	Tue Apr  8 11:03:30 2003
@@ -31,7 +31,6 @@
 #include <net/datalink.h>
 #include <net/p8022.h>
 #include <net/arp.h>
-#include <linux/brlock.h>
 
 #include "vlan.h"
 #include "vlanproc.h"
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux