Re: Removing MOD_xxx_USE_COUNT from net drivers

From: Keith Owens (kaos@ocs.com.au)
Date: Wed Oct 18 2000 - 00:39:05 EST


On Wed, 18 Oct 2000 00:42:54 -0400,
Paul Gortmaker <p_gortmaker@yahoo.com> wrote:
>As an alternative to sprinkling MOD_DEC_USE_COUNT throughout the failure
>paths of each net driver init sequence, maybe we should get the module use
>counters out of the drivers entirely. The driver source(s) look cleaner

IOW, exactly what AL Viro did for VFS.

> /*
>+ * Make sure module is marked in
>+ * use in case dev->open sleeps.
>+ */
>+
>+ if (dev->module)
>+ __MOD_INC_USE_COUNT(dev->module);

That needs to be try_inc_mod_count with a test on the result to close
this race

  if (dev->module) rmmod
                                            usercount == 0, OK to unload
     __MOD_INC_USE_COUNT(dev->module);
                                            unload
  dev->open(), oops

There is a problem with devices, you can ioctl a device without having
a corresponding open().

# strace ifconfig eth0 promisc
execve("/sbin/ifconfig", ["ifconfig", "eth0", "promisc"], [/* 33 vars */]) = 0
.....
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
.....
ioctl(4, SIOCGIFFLAGS, 0xbffffa64) = 0

No open on the device so no use count, what keeps the mod count up to
prevent unloading?

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:24 EST