ChangeSet 1.2199.8.34, 2005/03/22 19:20:39-08:00, [EMAIL PROTECTED] [NET]: Kill NETLINK_DEV and its only user, ethertap. This stuff has been scheduled to die for 2 years. Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
b/drivers/net/Kconfig | 23 -- b/drivers/net/Makefile | 1 b/net/Kconfig | 9 - b/net/netlink/Makefile | 1 drivers/net/ethertap.c | 390 ---------------------------------------------- net/netlink/netlink_dev.c | 278 -------------------------------- 6 files changed, 702 deletions(-) diff -Nru a/drivers/net/Kconfig b/drivers/net/Kconfig --- a/drivers/net/Kconfig 2005-03-26 17:17:25 -08:00 +++ b/drivers/net/Kconfig 2005-03-26 17:17:25 -08:00 @@ -102,29 +102,6 @@ If you don't know what to use this for, you don't need it. -config ETHERTAP - tristate "Ethertap network tap" - depends on NETDEVICES && EXPERIMENTAL && NETLINK_DEV - ---help--- - If you say Y here (and have said Y to "Kernel/User network link - driver", above) and create a character special file /dev/tap0 with - major number 36 and minor number 16 using mknod ("man mknod"), you - will be able to have a user space program read and write raw - Ethernet frames from/to that special file. tap0 can be configured - with ifconfig and route like any other Ethernet device but it is not - connected to any physical LAN; everything written by the user to - /dev/tap0 is treated by the kernel as if it had come in from a LAN - to the device tap0; everything the kernel wants to send out over the - device tap0 can instead be read by the user from /dev/tap0: the user - mode program replaces the LAN that would be attached to an ordinary - Ethernet device. Please read the file - <file:Documentation/networking/ethertap.txt> for more information. - - To compile this driver as a module, choose M here: the module - will be called ethertap. - - If you don't know what to use this for, you don't need it. - config NET_SB1000 tristate "General Instruments Surfboard 1000" depends on NETDEVICES && PNP diff -Nru a/drivers/net/Makefile b/drivers/net/Makefile --- a/drivers/net/Makefile 2005-03-26 17:17:25 -08:00 +++ b/drivers/net/Makefile 2005-03-26 17:17:25 -08:00 @@ -68,7 +68,6 @@ obj-$(CONFIG_HAMACHI) += hamachi.o obj-$(CONFIG_NET) += Space.o loopback.o obj-$(CONFIG_SEEQ8005) += seeq8005.o -obj-$(CONFIG_ETHERTAP) += ethertap.o obj-$(CONFIG_NET_SB1000) += sb1000.o obj-$(CONFIG_MAC8390) += mac8390.o 8390.o obj-$(CONFIG_APNE) += apne.o 8390.o diff -Nru a/drivers/net/ethertap.c b/drivers/net/ethertap.c --- a/drivers/net/ethertap.c 2005-03-26 17:17:25 -08:00 +++ /dev/null Wed Dec 31 16:00:00 196900 @@ -1,390 +0,0 @@ -/* - * Ethertap: A network device for bouncing packets via user space - * - * This is a very simple ethernet driver. It bounces ethernet frames - * to user space on /dev/tap0->/dev/tap15 and expects ethernet frames - * to be written back to it. By default it does not ARP. If you turn ARP - * on it will attempt to ARP the user space and reply to ARPS from the - * user space. - * - * As this is an ethernet device you can use it for appletalk, IPX etc - * even for building bridging tunnels. - */ - -#include <linux/config.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/kernel.h> -#include <linux/jiffies.h> -#include <linux/slab.h> -#include <linux/string.h> -#include <linux/errno.h> - -#include <linux/netdevice.h> -#include <linux/inetdevice.h> -#include <linux/etherdevice.h> -#include <linux/skbuff.h> -#include <linux/init.h> - -#include <net/sock.h> -#include <linux/netlink.h> - -/* - * Index to functions. - */ - -static int ethertap_open(struct net_device *dev); -static int ethertap_start_xmit(struct sk_buff *skb, struct net_device *dev); -static int ethertap_close(struct net_device *dev); -static struct net_device_stats *ethertap_get_stats(struct net_device *dev); -static void ethertap_rx(struct sock *sk, int len); -#ifdef CONFIG_ETHERTAP_MC -static void set_multicast_list(struct net_device *dev); -#endif - -static int ethertap_debug; - -static int max_taps = 1; -module_param(max_taps, int, 0); -MODULE_PARM_DESC(max_taps,"Max number of ethernet tap devices"); - -static struct net_device **tap_map; /* Returns the tap device for a given netlink */ - -/* - * Board-specific info in dev->priv. - */ - -struct net_local -{ - struct sock *nl; -#ifdef CONFIG_ETHERTAP_MC - __u32 groups; -#endif - struct net_device_stats stats; -}; - -/* - * To call this a probe is a bit misleading, however for real - * hardware it would have to check what was present. - */ -static int __init ethertap_probe(int unit) -{ - struct net_device *dev; - int err = -ENOMEM; - - dev = alloc_etherdev(sizeof(struct net_local)); - - if (!dev) - goto out; - - SET_MODULE_OWNER(dev); - - sprintf(dev->name, "tap%d", unit); - dev->base_addr = unit + NETLINK_TAPBASE; - - netdev_boot_setup_check(dev); - - memcpy(dev->dev_addr, "\xFE\xFD\x00\x00\x00\x00", 6); - if (dev->mem_start & 0xf) - ethertap_debug = dev->mem_start & 0x7; - - /* - * The tap specific entries in the device structure. - */ - - dev->open = ethertap_open; - dev->hard_start_xmit = ethertap_start_xmit; - dev->stop = ethertap_close; - dev->get_stats = ethertap_get_stats; -#ifdef CONFIG_ETHERTAP_MC - dev->set_multicast_list = set_multicast_list; -#endif - - dev->tx_queue_len = 0; - dev->flags|=IFF_NOARP; - - err = register_netdev(dev); - if (err) - goto out_free; - - tap_map[unit]=dev; - return 0; -out_free: - free_netdev(dev); -out: - return err; -} - -/* - * Open/initialize the board. - */ - -static int ethertap_open(struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); - - if (ethertap_debug > 2) - printk(KERN_DEBUG "%s: Doing ethertap_open()...\n", dev->name); - - lp->nl = netlink_kernel_create(dev->base_addr, ethertap_rx); - if (lp->nl == NULL) - return -ENOBUFS; - - netif_start_queue(dev); - return 0; -} - -#ifdef CONFIG_ETHERTAP_MC -static unsigned ethertap_mc_hash(__u8 *dest) -{ - unsigned idx = 0; - idx ^= dest[0]; - idx ^= dest[1]; - idx ^= dest[2]; - idx ^= dest[3]; - idx ^= dest[4]; - idx ^= dest[5]; - return 1U << (idx&0x1F); -} - -static void set_multicast_list(struct net_device *dev) -{ - unsigned groups = ~0; - struct net_local *lp = netdev_priv(dev); - - if (!(dev->flags&(IFF_NOARP|IFF_PROMISC|IFF_ALLMULTI))) { - struct dev_mc_list *dmi; - - groups = ethertap_mc_hash(dev->broadcast); - - for (dmi=dev->mc_list; dmi; dmi=dmi->next) { - if (dmi->dmi_addrlen != 6) - continue; - groups |= ethertap_mc_hash(dmi->dmi_addr); - } - } - lp->groups = groups; - if (lp->nl) - lp->nl->protinfo.af_netlink.groups = groups; -} -#endif - -/* - * We transmit by throwing the packet at netlink. We have to clone - * it for 2.0 so that we dev_kfree_skb() the locked original. - */ - -static int ethertap_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); -#ifdef CONFIG_ETHERTAP_MC - struct ethhdr *eth = (struct ethhdr*)skb->data; -#endif - - if (skb_headroom(skb) < 2) { - static int once; - struct sk_buff *skb2; - - if (!once) { - once = 1; - printk(KERN_DEBUG "%s: not aligned xmit by protocol %04x\n", dev->name, skb->protocol); - } - - skb2 = skb_realloc_headroom(skb, 2); - dev_kfree_skb(skb); - if (skb2 == NULL) - return 0; - skb = skb2; - } - __skb_push(skb, 2); - - /* Make the same thing, which loopback does. */ - if (skb_shared(skb)) { - struct sk_buff *skb2 = skb; - skb = skb_clone(skb, GFP_ATOMIC); /* Clone the buffer */ - if (skb==NULL) { - dev_kfree_skb(skb2); - return 0; - } - dev_kfree_skb(skb2); - } - /* ... but do not orphan it here, netlink does it in any case. */ - - lp->stats.tx_bytes+=skb->len; - lp->stats.tx_packets++; - -#ifndef CONFIG_ETHERTAP_MC - netlink_broadcast(lp->nl, skb, 0, ~0, GFP_ATOMIC); -#else - if (dev->flags&IFF_NOARP) { - netlink_broadcast(lp->nl, skb, 0, ~0, GFP_ATOMIC); - return 0; - } - - if (!(eth->h_dest[0]&1)) { - /* Unicast packet */ - __u32 pid; - memcpy(&pid, eth->h_dest+2, 4); - netlink_unicast(lp->nl, skb, ntohl(pid), MSG_DONTWAIT); - } else - netlink_broadcast(lp->nl, skb, 0, ethertap_mc_hash(eth->h_dest), GFP_ATOMIC); -#endif - return 0; -} - -static __inline__ int ethertap_rx_skb(struct sk_buff *skb, struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); -#ifdef CONFIG_ETHERTAP_MC - struct ethhdr *eth = (struct ethhdr*)(skb->data + 2); -#endif - int len = skb->len; - - if (len < 16) { - printk(KERN_DEBUG "%s : rx len = %d\n", dev->name, len); - kfree_skb(skb); - return -EINVAL; - } - if (NETLINK_CREDS(skb)->uid) { - printk(KERN_INFO "%s : user %d\n", dev->name, NETLINK_CREDS(skb)->uid); - kfree_skb(skb); - return -EPERM; - } - -#ifdef CONFIG_ETHERTAP_MC - if (!(dev->flags&(IFF_NOARP|IFF_PROMISC))) { - int drop = 0; - - if (eth->h_dest[0]&1) { - if (!(ethertap_mc_hash(eth->h_dest)&lp->groups)) - drop = 1; - } else if (memcmp(eth->h_dest, dev->dev_addr, 6) != 0) - drop = 1; - - if (drop) { - if (ethertap_debug > 3) - printk(KERN_DEBUG "%s : not for us\n", dev->name); - kfree_skb(skb); - return -EINVAL; - } - } -#endif - - if (skb_shared(skb)) { - struct sk_buff *skb2 = skb; - skb = skb_clone(skb, GFP_KERNEL); /* Clone the buffer */ - if (skb==NULL) { - kfree_skb(skb2); - return -ENOBUFS; - } - kfree_skb(skb2); - } else - skb_orphan(skb); - - skb_pull(skb, 2); - skb->dev = dev; - skb->protocol=eth_type_trans(skb,dev); - memset(skb->cb, 0, sizeof(skb->cb)); - lp->stats.rx_packets++; - lp->stats.rx_bytes+=len; - netif_rx(skb); - dev->last_rx = jiffies; - return len; -} - -/* - * The typical workload of the driver: - * Handle the ether interface interrupts. - * - * (In this case handle the packets posted from user space..) - */ - -static void ethertap_rx(struct sock *sk, int len) -{ - unsigned unit = sk->sk_protocol - NETLINK_TAPBASE; - struct net_device *dev; - struct sk_buff *skb; - - if (unit >= max_taps || (dev = tap_map[unit]) == NULL) { - printk(KERN_CRIT "ethertap: bad unit %u!\n", unit); - skb_queue_purge(&sk->sk_receive_queue); - return; - } - - if (ethertap_debug > 3) - printk(KERN_DEBUG "%s: ethertap_rx()\n", dev->name); - - while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) - ethertap_rx_skb(skb, dev); -} - -static int ethertap_close(struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); - struct sock *sk = lp->nl; - - if (ethertap_debug > 2) - printk(KERN_DEBUG "%s: Shutting down.\n", dev->name); - - netif_stop_queue(dev); - - if (sk) { - lp->nl = NULL; - sock_release(sk->sk_socket); - } - - return 0; -} - -static struct net_device_stats *ethertap_get_stats(struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); - return &lp->stats; -} - - -static int __init ethertap_init(void) -{ - int i, err = 0; - - /* netlink can only hande 16 entries unless modified */ - if (max_taps > MAX_LINKS - NETLINK_TAPBASE) - return -E2BIG; - - tap_map = kmalloc(sizeof(struct net_device *)*max_taps, GFP_KERNEL); - if (!tap_map) - return -ENOMEM; - - for (i = 0; i < max_taps; i++) { - err = ethertap_probe(i); - if (err) { - while (--i > 0) { - unregister_netdev(tap_map[i]); - free_netdev(tap_map[i]); - } - break; - } - } - if (err) - kfree(tap_map); - return err; -} -module_init(ethertap_init); - -static void __exit ethertap_cleanup(void) -{ - int i; - - for (i = 0; i < max_taps; i++) { - struct net_device *dev = tap_map[i]; - if (dev) { - tap_map[i] = NULL; - unregister_netdev(dev); - free_netdev(dev); - } - } - kfree(tap_map); -} -module_exit(ethertap_cleanup); - -MODULE_LICENSE("GPL"); diff -Nru a/net/Kconfig b/net/Kconfig --- a/net/Kconfig 2005-03-26 17:17:25 -08:00 +++ b/net/Kconfig 2005-03-26 17:17:25 -08:00 @@ -45,15 +45,6 @@ If unsure, say N. -config NETLINK_DEV - tristate "Netlink device emulation" - help - This option will be removed soon. Any programs that want to use - character special nodes like /dev/tap0 or /dev/route (all with major - number 36) need this option, and need to be rewritten soon to use - the real netlink socket. - This is a backward compatibility option, choose Y for now. - config UNIX tristate "Unix domain sockets" ---help--- diff -Nru a/net/netlink/Makefile b/net/netlink/Makefile --- a/net/netlink/Makefile 2005-03-26 17:17:25 -08:00 +++ b/net/netlink/Makefile 2005-03-26 17:17:25 -08:00 @@ -3,4 +3,3 @@ # obj-y := af_netlink.o -obj-$(CONFIG_NETLINK_DEV) += netlink_dev.o diff -Nru a/net/netlink/netlink_dev.c b/net/netlink/netlink_dev.c --- a/net/netlink/netlink_dev.c 2005-03-26 17:17:25 -08:00 +++ /dev/null Wed Dec 31 16:00:00 196900 @@ -1,278 +0,0 @@ -/* - * NETLINK An implementation of a loadable kernel mode driver providing - * multiple kernel/user space bidirectional communications links. - * - * Author: Alan Cox <[EMAIL PROTECTED]> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Now netlink devices are emulated on the top of netlink sockets - * by compatibility reasons. Remove this file after a period. --ANK - * - */ - -#include <linux/module.h> - -#include <linux/errno.h> -#include <linux/kernel.h> -#include <linux/major.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/skbuff.h> -#include <linux/netlink.h> -#include <linux/poll.h> -#include <linux/init.h> -#include <linux/devfs_fs_kernel.h> -#include <linux/smp_lock.h> -#include <linux/device.h> -#include <linux/bitops.h> - -#include <asm/system.h> -#include <asm/uaccess.h> - -static long open_map; -static struct socket *netlink_user[MAX_LINKS]; -static struct class_simple *netlink_class; - -/* - * Device operations - */ - -static unsigned int netlink_poll(struct file *file, poll_table * wait) -{ - struct socket *sock = netlink_user[iminor(file->f_dentry->d_inode)]; - - if (sock->ops->poll==NULL) - return 0; - return sock->ops->poll(file, sock, wait); -} - -/* - * Write a message to the kernel side of a communication link - */ - -static ssize_t netlink_write(struct file * file, const char __user * buf, - size_t count, loff_t *pos) -{ - struct inode *inode = file->f_dentry->d_inode; - struct socket *sock = netlink_user[iminor(inode)]; - struct msghdr msg; - struct iovec iov; - - iov.iov_base = (void __user*)buf; - iov.iov_len = count; - msg.msg_name=NULL; - msg.msg_namelen=0; - msg.msg_controllen=0; - msg.msg_flags=0; - msg.msg_iov=&iov; - msg.msg_iovlen=1; - - return sock_sendmsg(sock, &msg, count); -} - -/* - * Read a message from the kernel side of the communication link - */ - -static ssize_t netlink_read(struct file * file, char __user * buf, - size_t count, loff_t *pos) -{ - struct inode *inode = file->f_dentry->d_inode; - struct socket *sock = netlink_user[iminor(inode)]; - struct msghdr msg; - struct iovec iov; - - iov.iov_base = buf; - iov.iov_len = count; - msg.msg_name=NULL; - msg.msg_namelen=0; - msg.msg_controllen=0; - msg.msg_flags=0; - msg.msg_iov=&iov; - msg.msg_iovlen=1; - if (file->f_flags&O_NONBLOCK) - msg.msg_flags=MSG_DONTWAIT; - - return sock_recvmsg(sock, &msg, count, msg.msg_flags); -} - -static int netlink_open(struct inode * inode, struct file * file) -{ - unsigned int minor = iminor(inode); - struct socket *sock; - struct sockaddr_nl nladdr; - int err; - - if (minor>=MAX_LINKS) - return -ENODEV; - if (test_and_set_bit(minor, &open_map)) - return -EBUSY; - - err = sock_create_kern(PF_NETLINK, SOCK_RAW, minor, &sock); - if (err < 0) - goto out; - - memset(&nladdr, 0, sizeof(nladdr)); - nladdr.nl_family = AF_NETLINK; - nladdr.nl_groups = ~0; - if ((err = sock->ops->bind(sock, (struct sockaddr*)&nladdr, sizeof(nladdr))) < 0) { - sock_release(sock); - goto out; - } - - netlink_user[minor] = sock; - return 0; - -out: - clear_bit(minor, &open_map); - return err; -} - -static int netlink_release(struct inode * inode, struct file * file) -{ - unsigned int minor = iminor(inode); - struct socket *sock; - - sock = netlink_user[minor]; - netlink_user[minor] = NULL; - clear_bit(minor, &open_map); - sock_release(sock); - return 0; -} - - -static int netlink_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - unsigned int minor = iminor(inode); - int retval = 0; - - if (minor >= MAX_LINKS) - return -ENODEV; - switch ( cmd ) { - default: - retval = -EINVAL; - } - return retval; -} - - -static struct file_operations netlink_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .read = netlink_read, - .write = netlink_write, - .poll = netlink_poll, - .ioctl = netlink_ioctl, - .open = netlink_open, - .release = netlink_release, -}; - -static struct { - char *name; - int minor; -} entries[] = { - { - .name = "route", - .minor = NETLINK_ROUTE, - }, - { - .name = "skip", - .minor = NETLINK_SKIP, - }, - { - .name = "usersock", - .minor = NETLINK_USERSOCK, - }, - { - .name = "fwmonitor", - .minor = NETLINK_FIREWALL, - }, - { - .name = "tcpdiag", - .minor = NETLINK_TCPDIAG, - }, - { - .name = "nflog", - .minor = NETLINK_NFLOG, - }, - { - .name = "xfrm", - .minor = NETLINK_XFRM, - }, - { - .name = "arpd", - .minor = NETLINK_ARPD, - }, - { - .name = "route6", - .minor = NETLINK_ROUTE6, - }, - { - .name = "ip6_fw", - .minor = NETLINK_IP6_FW, - }, - { - .name = "dnrtmsg", - .minor = NETLINK_DNRTMSG, - }, -}; - -static int __init init_netlink(void) -{ - int i; - - if (register_chrdev(NETLINK_MAJOR,"netlink", &netlink_fops)) { - printk(KERN_ERR "netlink: unable to get major %d\n", NETLINK_MAJOR); - return -EIO; - } - - netlink_class = class_simple_create(THIS_MODULE, "netlink"); - if (IS_ERR(netlink_class)) { - printk (KERN_ERR "Error creating netlink class.\n"); - unregister_chrdev(NETLINK_MAJOR, "netlink"); - return PTR_ERR(netlink_class); - } - - devfs_mk_dir("netlink"); - - /* Someone tell me the official names for the uppercase ones */ - for (i = 0; i < ARRAY_SIZE(entries); i++) { - devfs_mk_cdev(MKDEV(NETLINK_MAJOR, entries[i].minor), - S_IFCHR|S_IRUSR|S_IWUSR, "netlink/%s", entries[i].name); - class_simple_device_add(netlink_class, MKDEV(NETLINK_MAJOR, entries[i].minor), NULL, "%s", entries[i].name); - } - - for (i = 0; i < 16; i++) { - devfs_mk_cdev(MKDEV(NETLINK_MAJOR, i + 16), - S_IFCHR|S_IRUSR|S_IWUSR, "netlink/tap%d", i); - class_simple_device_add(netlink_class, MKDEV(NETLINK_MAJOR, i + 16), NULL, "tap%d", i); - } - - return 0; -} - -static void __exit cleanup_netlink(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(entries); i++) { - devfs_remove("netlink/%s", entries[i].name); - class_simple_device_remove(MKDEV(NETLINK_MAJOR, entries[i].minor)); - } - for (i = 0; i < 16; i++) { - devfs_remove("netlink/tap%d", i); - class_simple_device_remove(MKDEV(NETLINK_MAJOR, i + 16)); - } - devfs_remove("netlink"); - class_simple_destroy(netlink_class); - unregister_chrdev(NETLINK_MAJOR, "netlink"); -} - -MODULE_LICENSE("GPL"); -module_init(init_netlink); -module_exit(cleanup_netlink); - To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html