Author: brooks
Date: Mon Jun 29 19:46:29 2009
New Revision: 195175
URL: http://svn.freebsd.org/changeset/base/195175

Log:
  Remove support for the /dev/net/* per-interface devices.  They serve
  little purpose and are unused in the base system.
  
  The IOCTL functionality is entirely duplicated and routing sockets
  provide a richer interface than the kqueue functionality.
  
  Further, it is not practical for these devices to be made sensible in
  the face of VIMAGE.
  
  Bump __FreeBSD_version on the off chance that there is any code out
  there that actually uses this stuff.
  
  Reviewed by:  rwatson
  Discussed with:       bz, zec
  Approved by:  re@ (kensmith)

Modified:
  head/UPDATING
  head/sys/net/if.c
  head/sys/net/if_var.h
  head/sys/net/vnet.h
  head/sys/sys/param.h

Modified: head/UPDATING
==============================================================================
--- head/UPDATING       Mon Jun 29 19:20:21 2009        (r195174)
+++ head/UPDATING       Mon Jun 29 19:46:29 2009        (r195175)
@@ -22,6 +22,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
        to maximize performance.  (To disable malloc debugging, run
        ln -s aj /etc/malloc.conf.)
 
+20090629:
+       The network interface device nodes at /dev/net/<interface> have
+       been removed.  All ioctl operations can be performed the normal
+       way using routing sockets.  The kqueue functionality can
+       generally be replaced with routing sockets.
+
 20090628:
        The documentation from the FreeBSD Documentation Project
        (Handbook, FAQ, etc.) is now installed via packages by

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c   Mon Jun 29 19:20:21 2009        (r195174)
+++ head/sys/net/if.c   Mon Jun 29 19:46:29 2009        (r195175)
@@ -100,6 +100,10 @@ struct vnet_net vnet_net_0;
 #endif
 #endif
 
+struct ifindex_entry {
+       struct  ifnet *ife_ifnet;
+};
+
 static int slowtimo_started;
 
 SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers");
@@ -163,9 +167,8 @@ struct      ifnethead ifnet;        /* depend on sta
 struct ifgrouphead ifg_head;
 int    if_index;
 static int if_indexlim;
-/* Table of ifnet/cdev by index.  Locked with ifnet_lock. */
+/* Table of ifnet by index.  Locked with ifnet_lock. */
 static struct ifindex_entry *ifindex_table;
-static struct  knlist ifklist;
 #endif
 
 int    ifqmaxlen = IFQ_MAXLEN;
@@ -173,12 +176,6 @@ struct rwlock ifnet_lock;
 static if_com_alloc_t *if_com_alloc[256];
 static if_com_free_t *if_com_free[256];
 
-static void    filt_netdetach(struct knote *kn);
-static int     filt_netdev(struct knote *kn, long hint);
-
-static struct filterops netdev_filtops =
-    { 1, NULL, filt_netdetach, filt_netdev };
-
 #ifndef VIMAGE_GLOBALS
 static struct vnet_symmap vnet_net_symmap[] = {
        VNET_SYMMAP(net, ifnet),
@@ -267,150 +264,6 @@ ifaddr_byindex(u_short idx)
        return (ifa);
 }
 
-struct cdev *
-ifdev_byindex(u_short idx)
-{
-       INIT_VNET_NET(curvnet);
-       struct cdev *cdev;
-
-       IFNET_RLOCK();
-       cdev = V_ifindex_table[idx].ife_dev;
-       IFNET_RUNLOCK();
-       return (cdev);
-}
-
-static void
-ifdev_setbyindex(u_short idx, struct cdev *cdev)
-{
-       INIT_VNET_NET(curvnet);
-
-       IFNET_WLOCK();
-       V_ifindex_table[idx].ife_dev = cdev;
-       IFNET_WUNLOCK();
-}
-
-static d_open_t                netopen;
-static d_close_t       netclose;
-static d_ioctl_t       netioctl;
-static d_kqfilter_t    netkqfilter;
-
-static struct cdevsw net_cdevsw = {
-       .d_version =    D_VERSION,
-       .d_flags =      D_NEEDGIANT,
-       .d_open =       netopen,
-       .d_close =      netclose,
-       .d_ioctl =      netioctl,
-       .d_name =       "net",
-       .d_kqfilter =   netkqfilter,
-};
-
-static int
-netopen(struct cdev *dev, int flag, int mode, struct thread *td)
-{
-       return (0);
-}
-
-static int
-netclose(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
-       return (0);
-}
-
-static int
-netioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread 
*td)
-{
-       struct ifnet *ifp;
-       int error, idx;
-
-       /* only support interface specific ioctls */
-       if (IOCGROUP(cmd) != 'i')
-               return (EOPNOTSUPP);
-       idx = dev2unit(dev);
-       if (idx == 0) {
-               /*
-                * special network device, not interface.
-                */
-               if (cmd == SIOCGIFCONF)
-                       return (ifconf(cmd, data));     /* XXX remove cmd */
-#ifdef __amd64__
-               if (cmd == SIOCGIFCONF32)
-                       return (ifconf(cmd, data));     /* XXX remove cmd */
-#endif
-               return (EOPNOTSUPP);
-       }
-
-       ifp = ifnet_byindex(idx);
-       if (ifp == NULL)
-               return (ENXIO);
-
-       error = ifhwioctl(cmd, ifp, data, td);
-       if (error == ENOIOCTL)
-               error = EOPNOTSUPP;
-       return (error);
-}
-
-static int
-netkqfilter(struct cdev *dev, struct knote *kn)
-{
-       INIT_VNET_NET(curvnet);
-       struct knlist *klist;
-       struct ifnet *ifp;
-       int idx;
-
-       switch (kn->kn_filter) {
-       case EVFILT_NETDEV:
-               kn->kn_fop = &netdev_filtops;
-               break;
-       default:
-               return (EINVAL);
-       }
-
-       idx = dev2unit(dev);
-       if (idx == 0) {
-               klist = &V_ifklist;
-       } else {
-               ifp = ifnet_byindex(idx);
-               if (ifp == NULL)
-                       return (1);
-               klist = &ifp->if_klist;
-       }
-
-       kn->kn_hook = (caddr_t)klist;
-
-       knlist_add(klist, kn, 0);
-
-       return (0);
-}
-
-static void
-filt_netdetach(struct knote *kn)
-{
-       struct knlist *klist = (struct knlist *)kn->kn_hook;
-
-       knlist_remove(klist, kn, 0);
-}
-
-static int
-filt_netdev(struct knote *kn, long hint)
-{
-       struct knlist *klist = (struct knlist *)kn->kn_hook;
-
-       /*
-        * Currently NOTE_EXIT is abused to indicate device detach.
-        */
-       if (hint == NOTE_EXIT) {
-               kn->kn_data = NOTE_LINKINV;
-               kn->kn_flags |= (EV_EOF | EV_ONESHOT);
-               knlist_remove_inevent(klist, kn);
-               return (1);
-       }
-       if (hint != 0)
-               kn->kn_data = hint;                     /* current status */
-       if (kn->kn_sfflags & hint)
-               kn->kn_fflags |= hint;
-       return (kn->kn_fflags != 0);
-}
-
 /*
  * Network interface utility routines.
  *
@@ -430,8 +283,6 @@ if_init(void *dummy __unused)
 #endif
 
        IFNET_LOCK_INIT();
-       ifdev_setbyindex(0, make_dev(&net_cdevsw, 0, UID_ROOT, GID_WHEEL,
-           0600, "network"));
        if_clone_init();
 }
 
@@ -446,7 +297,6 @@ vnet_net_iattach(const void *unused __un
 
        TAILQ_INIT(&V_ifnet);
        TAILQ_INIT(&V_ifg_head);
-       knlist_init_mtx(&V_ifklist, NULL);
        if_grow();                              /* create initial table */
 
        return (0);
@@ -460,7 +310,6 @@ vnet_net_idetach(const void *unused __un
 
        VNET_ASSERT(TAILQ_EMPTY(&V_ifnet));
        VNET_ASSERT(TAILQ_EMPTY(&V_ifg_head));
-       VNET_ASSERT(SLIST_EMPTY(&V_ifklist.kl_list));
 
        free((caddr_t)V_ifindex_table, M_IFNET);
 
@@ -549,7 +398,6 @@ if_alloc(u_char type)
        TAILQ_INIT(&ifp->if_prefixhead);
        TAILQ_INIT(&ifp->if_multiaddrs);
        TAILQ_INIT(&ifp->if_groups);
-       knlist_init_mtx(&ifp->if_klist, NULL);
 #ifdef MAC
        mac_ifnet_init(ifp);
 #endif
@@ -591,9 +439,6 @@ if_free_internal(struct ifnet *ifp)
 #ifdef MAC
        mac_ifnet_destroy(ifp);
 #endif /* MAC */
-       KNOTE_UNLOCKED(&ifp->if_klist, NOTE_EXIT);
-       knlist_clear(&ifp->if_klist, 0);
-       knlist_destroy(&ifp->if_klist);
        IF_AFDATA_DESTROY(ifp);
        IF_ADDR_LOCK_DESTROY(ifp);
        ifq_delete(&ifp->if_snd);
@@ -734,14 +579,6 @@ if_attach_internal(struct ifnet *ifp, in
                mac_ifnet_create(ifp);
 #endif
 
-               if (IS_DEFAULT_VNET(curvnet)) {
-                       ifdev_setbyindex(ifp->if_index, make_dev(&net_cdevsw,
-                           ifp->if_index, UID_ROOT, GID_WHEEL, 0600, "%s/%s",
-                           net_cdevsw.d_name, ifp->if_xname));
-                       make_dev_alias(ifdev_byindex(ifp->if_index), "%s%d",
-                           net_cdevsw.d_name, ifp->if_index);
-               }
-
                /*
                 * Create a Link Level name for this device.
                 */
@@ -1003,9 +840,6 @@ if_detach_internal(struct ifnet *ifp, in
                 * Clean up all addresses.
                 */
                ifp->if_addr = NULL;
-               if (IS_DEFAULT_VNET(curvnet))
-                       destroy_dev(ifdev_byindex(ifp->if_index));
-               ifdev_setbyindex(ifp->if_index, NULL);  
 
                /* We can now free link ifaddr. */
                if (!TAILQ_EMPTY(&ifp->if_addrhead)) {
@@ -1905,7 +1739,6 @@ do_link_state_change(void *arg, int pend
                link = NOTE_LINKDOWN;
        else
                link = NOTE_LINKINV;
-       KNOTE_UNLOCKED(&ifp->if_klist, link);
        if (ifp->if_vlantrunk != NULL)
                (*vlan_link_state_p)(ifp, link);
 

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h       Mon Jun 29 19:20:21 2009        (r195174)
+++ head/sys/net/if_var.h       Mon Jun 29 19:46:29 2009        (r195175)
@@ -135,7 +135,6 @@ struct ifnet {
                 * However, access to the AF_LINK address through this
                 * field is deprecated. Use if_addr or ifaddr_byindex() instead.
                 */
-       struct  knlist if_klist;        /* events attached to this if */
        int     if_pcount;              /* number of promiscuous listeners */
        struct  carp_if *if_carp;       /* carp interface structure */
        struct  bpf_if *if_bpf;         /* packet filter structure */
@@ -764,11 +763,6 @@ extern     struct rwlock ifnet_lock;
 #define        IFNET_RLOCK()           rw_rlock(&ifnet_lock)
 #define        IFNET_RUNLOCK()         rw_runlock(&ifnet_lock) 
 
-struct ifindex_entry {
-       struct  ifnet *ife_ifnet;
-       struct cdev *ife_dev;
-};
-
 /*
  * Look up an ifnet given its index; the _ref variant also acquires a
  * reference that must be freed using if_rele().  It is almost always a bug
@@ -784,7 +778,6 @@ struct ifnet        *ifnet_byindex_ref(u_short 
  * it to traverse the list of addresses associated to the interface.
  */
 struct ifaddr  *ifaddr_byindex(u_short idx);
-struct cdev    *ifdev_byindex(u_short idx);
 
 #ifdef VIMAGE_GLOBALS
 extern struct ifnethead ifnet;

Modified: head/sys/net/vnet.h
==============================================================================
--- head/sys/net/vnet.h Mon Jun 29 19:20:21 2009        (r195174)
+++ head/sys/net/vnet.h Mon Jun 29 19:46:29 2009        (r195175)
@@ -35,6 +35,8 @@
 
 #include <net/if_var.h>
 
+struct ifindex_entry;
+
 struct vnet_net {
        int                     _if_index;
        struct ifindex_entry *  _ifindex_table;
@@ -42,7 +44,6 @@ struct vnet_net {
        struct ifgrouphead      _ifg_head;
 
        int                     _if_indexlim;
-       struct knlist           _ifklist;
 
        struct ifnet *          _loif;
        struct if_clone *       _lo_cloner;

Modified: head/sys/sys/param.h
==============================================================================
--- head/sys/sys/param.h        Mon Jun 29 19:20:21 2009        (r195174)
+++ head/sys/sys/param.h        Mon Jun 29 19:46:29 2009        (r195175)
@@ -58,7 +58,7 @@
  *             in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 800100       /* Master, propagated to newvers */
+#define __FreeBSD_version 800101       /* Master, propagated to newvers */
 
 #ifndef LOCORE
 #include <sys/types.h>
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to