mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
add my 2.6.15-rc5 port (yay) with devfs. The PCI subsystem is broken on Broadcom boards, we are working on it. Also upgrade iptables to 1.3.4
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@2683 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
219
target/linux/linux-2.6/patches/generic/000-reenable_devfs.patch
Normal file
219
target/linux/linux-2.6/patches/generic/000-reenable_devfs.patch
Normal file
@@ -0,0 +1,219 @@
|
||||
diff -ur linux-2.6.15-rc5/drivers/mtd/mtd_blkdevs.c linux-2.6.15-rc5-openwrt/drivers/mtd/mtd_blkdevs.c
|
||||
--- linux-2.6.15-rc5/drivers/mtd/mtd_blkdevs.c 2005-12-04 06:10:42.000000000 +0100
|
||||
+++ linux-2.6.15-rc5-openwrt/drivers/mtd/mtd_blkdevs.c 2005-12-15 07:53:20.000000000 +0100
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <linux/init.h>
|
||||
#include <asm/semaphore.h>
|
||||
#include <asm/uaccess.h>
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+#include <linux/devfs_fs_kernel.h>
|
||||
+#endif
|
||||
|
||||
static LIST_HEAD(blktrans_majors);
|
||||
|
||||
@@ -302,6 +305,11 @@
|
||||
snprintf(gd->disk_name, sizeof(gd->disk_name),
|
||||
"%s%d", tr->name, new->devnum);
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ snprintf(gd->devfs_name, sizeof(gd->devfs_name),
|
||||
+ "%s/%c", tr->name, (tr->part_bits?'a':'0') + new->devnum);
|
||||
+#endif
|
||||
+
|
||||
/* 2.5 has capacity in units of 512 bytes while still
|
||||
having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */
|
||||
set_capacity(gd, (new->size * new->blksize) >> 9);
|
||||
@@ -418,6 +426,10 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ devfs_mk_dir(tr->name);
|
||||
+#endif
|
||||
+
|
||||
INIT_LIST_HEAD(&tr->devs);
|
||||
list_add(&tr->list, &blktrans_majors);
|
||||
|
||||
@@ -450,6 +462,10 @@
|
||||
tr->remove_dev(dev);
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ devfs_remove(tr->name);
|
||||
+#endif
|
||||
+
|
||||
blk_cleanup_queue(tr->blkcore_priv->rq);
|
||||
unregister_blkdev(tr->major, tr->name);
|
||||
|
||||
diff -ur linux-2.6.15-rc5/drivers/mtd/mtdchar.c linux-2.6.15-rc5-openwrt/drivers/mtd/mtdchar.c
|
||||
--- linux-2.6.15-rc5/drivers/mtd/mtdchar.c 2005-12-04 06:10:42.000000000 +0100
|
||||
+++ linux-2.6.15-rc5-openwrt/drivers/mtd/mtdchar.c 2005-12-15 07:49:15.000000000 +0100
|
||||
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
-#include <linux/device.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -19,19 +18,33 @@
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+#include <linux/devfs_fs_kernel.h>
|
||||
+#else
|
||||
+#include <linux/device.h>
|
||||
+
|
||||
static struct class *mtd_class;
|
||||
+#endif
|
||||
|
||||
static void mtd_notify_add(struct mtd_info* mtd)
|
||||
{
|
||||
if (!mtd)
|
||||
return;
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ devfs_mk_cdev(MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
|
||||
+ S_IFCHR | S_IRUGO | S_IWUGO, "mtd/%d", mtd->index);
|
||||
+
|
||||
+ devfs_mk_cdev(MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
|
||||
+ S_IFCHR | S_IRUGO, "mtd/%dro", mtd->index);
|
||||
+#else
|
||||
class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
|
||||
NULL, "mtd%d", mtd->index);
|
||||
|
||||
class_device_create(mtd_class, NULL,
|
||||
MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
|
||||
NULL, "mtd%dro", mtd->index);
|
||||
+#endif
|
||||
}
|
||||
|
||||
static void mtd_notify_remove(struct mtd_info* mtd)
|
||||
@@ -39,8 +52,13 @@
|
||||
if (!mtd)
|
||||
return;
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ devfs_remove("mtd/%d", mtd->index);
|
||||
+ devfs_remove("mtd/%dro", mtd->index);
|
||||
+#else
|
||||
class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2));
|
||||
class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1));
|
||||
+#endif
|
||||
}
|
||||
|
||||
static struct mtd_notifier notifier = {
|
||||
@@ -48,6 +66,22 @@
|
||||
.remove = mtd_notify_remove,
|
||||
};
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ static inline void mtdchar_devfs_init(void)
|
||||
+ {
|
||||
+ devfs_mk_dir("mtd");
|
||||
+ register_mtd_user(¬ifier);
|
||||
+ }
|
||||
+ static inline void mtdchar_devfs_exit(void)
|
||||
+ {
|
||||
+ unregister_mtd_user(¬ifier);
|
||||
+ devfs_remove("mtd");
|
||||
+ }
|
||||
+ #else /* !DEVFS */
|
||||
+ #define mtdchar_devfs_init() do { } while(0)
|
||||
+ #define mtdchar_devfs_exit() do { } while(0)
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* We use file->private_data to store a pointer to the MTDdevice.
|
||||
* Since alighment is at least 32 bits, we have 2 bits free for OTP
|
||||
@@ -643,6 +677,9 @@
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ mtdchar_devfs_init();
|
||||
+#else
|
||||
mtd_class = class_create(THIS_MODULE, "mtd");
|
||||
|
||||
if (IS_ERR(mtd_class)) {
|
||||
@@ -652,13 +689,19 @@
|
||||
}
|
||||
|
||||
register_mtd_user(¬ifier);
|
||||
+#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit cleanup_mtdchar(void)
|
||||
{
|
||||
+
|
||||
+#ifdef CONFIG_DEVFS_FS
|
||||
+ mtdchar_devfs_exit();
|
||||
+#else
|
||||
unregister_mtd_user(¬ifier);
|
||||
class_destroy(mtd_class);
|
||||
+#endif
|
||||
unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
|
||||
}
|
||||
|
||||
diff -ur linux-2.6.15-rc5/fs/Kconfig linux-2.6.15-rc5-openwrt/fs/Kconfig
|
||||
--- linux-2.6.15-rc5/fs/Kconfig 2005-12-04 06:10:42.000000000 +0100
|
||||
+++ linux-2.6.15-rc5-openwrt/fs/Kconfig 2005-12-15 07:44:01.000000000 +0100
|
||||
@@ -772,6 +772,56 @@
|
||||
help
|
||||
Exports the dump image of crashed kernel in ELF format.
|
||||
|
||||
+config DEVFS_FS
|
||||
+ bool "/dev file system support (OBSOLETE)"
|
||||
+ depends on EXPERIMENTAL
|
||||
+ help
|
||||
+ This is support for devfs, a virtual file system (like /proc) which
|
||||
+ provides the file system interface to device drivers, normally found
|
||||
+ in /dev. Devfs does not depend on major and minor number
|
||||
+ allocations. Device drivers register entries in /dev which then
|
||||
+ appear automatically, which means that the system administrator does
|
||||
+ not have to create character and block special device files in the
|
||||
+ /dev directory using the mknod command (or MAKEDEV script) anymore.
|
||||
+
|
||||
+ This is work in progress. If you want to use this, you *must* read
|
||||
+ the material in <file:Documentation/filesystems/devfs/>, especially
|
||||
+ the file README there.
|
||||
+
|
||||
+ Note that devfs no longer manages /dev/pts! If you are using UNIX98
|
||||
+ ptys, you will also need to mount the /dev/pts filesystem (devpts).
|
||||
+
|
||||
+ Note that devfs has been obsoleted by udev,
|
||||
+ <http://www.kernel.org/pub/linux/utils/kernel/hotplug/>.
|
||||
+ It has been stripped down to a bare minimum and is only provided for
|
||||
+ legacy installations that use its naming scheme which is
|
||||
+ unfortunately different from the names normal Linux installations
|
||||
+ use.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
+
|
||||
+config DEVFS_MOUNT
|
||||
+ bool "Automatically mount at boot"
|
||||
+ depends on DEVFS_FS
|
||||
+ help
|
||||
+ This option appears if you have CONFIG_DEVFS_FS enabled. Setting
|
||||
+ this to 'Y' will make the kernel automatically mount devfs onto /dev
|
||||
+ when the system is booted, before the init thread is started.
|
||||
+ You can override this with the "devfs=nomount" boot option.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
+
|
||||
+config DEVFS_DEBUG
|
||||
+ bool "Debug devfs"
|
||||
+ depends on DEVFS_FS
|
||||
+ help
|
||||
+ If you say Y here, then the /dev file system code will generate
|
||||
+ debugging messages. See the file
|
||||
+ <file:Documentation/filesystems/devfs/boot-options> for more
|
||||
+ details.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
+
|
||||
config SYSFS
|
||||
bool "sysfs file system support" if EMBEDDED
|
||||
default y
|
||||
807
target/linux/linux-2.6/patches/generic/003-net-b44-1.patch
Normal file
807
target/linux/linux-2.6/patches/generic/003-net-b44-1.patch
Normal file
@@ -0,0 +1,807 @@
|
||||
diff -ur linux-2.6.15-rc5/drivers/net/b44.c linux-2.6.15-rc5-openwrt/drivers/net/b44.c
|
||||
--- linux-2.6.15-rc5/drivers/net/b44.c 2005-12-04 06:10:42.000000000 +0100
|
||||
+++ linux-2.6.15-rc5-openwrt/drivers/net/b44.c 2005-08-15 02:20:18.000000000 +0200
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <linux/pci.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/init.h>
|
||||
-#include <linux/dma-mapping.h>
|
||||
+#include <linux/version.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/io.h>
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
#define DRV_MODULE_NAME "b44"
|
||||
#define PFX DRV_MODULE_NAME ": "
|
||||
-#define DRV_MODULE_VERSION "0.97"
|
||||
-#define DRV_MODULE_RELDATE "Nov 30, 2005"
|
||||
+#define DRV_MODULE_VERSION "0.95"
|
||||
+#define DRV_MODULE_RELDATE "Aug 3, 2004"
|
||||
|
||||
#define B44_DEF_MSG_ENABLE \
|
||||
(NETIF_MSG_DRV | \
|
||||
@@ -101,35 +101,10 @@
|
||||
static void b44_halt(struct b44 *);
|
||||
static void b44_init_rings(struct b44 *);
|
||||
static void b44_init_hw(struct b44 *);
|
||||
-
|
||||
-static int dma_desc_align_mask;
|
||||
-static int dma_desc_sync_size;
|
||||
-
|
||||
-static const char b44_gstrings[][ETH_GSTRING_LEN] = {
|
||||
-#define _B44(x...) # x,
|
||||
-B44_STAT_REG_DECLARE
|
||||
-#undef _B44
|
||||
-};
|
||||
-
|
||||
-static inline void b44_sync_dma_desc_for_device(struct pci_dev *pdev,
|
||||
- dma_addr_t dma_base,
|
||||
- unsigned long offset,
|
||||
- enum dma_data_direction dir)
|
||||
-{
|
||||
- dma_sync_single_range_for_device(&pdev->dev, dma_base,
|
||||
- offset & dma_desc_align_mask,
|
||||
- dma_desc_sync_size, dir);
|
||||
-}
|
||||
-
|
||||
-static inline void b44_sync_dma_desc_for_cpu(struct pci_dev *pdev,
|
||||
- dma_addr_t dma_base,
|
||||
- unsigned long offset,
|
||||
- enum dma_data_direction dir)
|
||||
-{
|
||||
- dma_sync_single_range_for_cpu(&pdev->dev, dma_base,
|
||||
- offset & dma_desc_align_mask,
|
||||
- dma_desc_sync_size, dir);
|
||||
-}
|
||||
+static int b44_poll(struct net_device *dev, int *budget);
|
||||
+#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||
+static void b44_poll_controller(struct net_device *dev);
|
||||
+#endif
|
||||
|
||||
static inline unsigned long br32(const struct b44 *bp, unsigned long reg)
|
||||
{
|
||||
@@ -503,10 +478,7 @@
|
||||
for (reg = B44_TX_GOOD_O; reg <= B44_TX_PAUSE; reg += 4UL) {
|
||||
*val++ += br32(bp, reg);
|
||||
}
|
||||
-
|
||||
- /* Pad */
|
||||
- reg += 8*4UL;
|
||||
-
|
||||
+ val = &bp->hw_stats.rx_good_octets;
|
||||
for (reg = B44_RX_GOOD_O; reg <= B44_RX_NPAUSE; reg += 4UL) {
|
||||
*val++ += br32(bp, reg);
|
||||
}
|
||||
@@ -657,7 +629,7 @@
|
||||
|
||||
/* Hardware bug work-around, the chip is unable to do PCI DMA
|
||||
to/from anything above 1GB :-( */
|
||||
- if (mapping + RX_PKT_BUF_SZ > B44_DMA_MASK) {
|
||||
+ if(mapping+RX_PKT_BUF_SZ > B44_DMA_MASK) {
|
||||
/* Sigh... */
|
||||
pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE);
|
||||
dev_kfree_skb_any(skb);
|
||||
@@ -667,7 +639,7 @@
|
||||
mapping = pci_map_single(bp->pdev, skb->data,
|
||||
RX_PKT_BUF_SZ,
|
||||
PCI_DMA_FROMDEVICE);
|
||||
- if (mapping + RX_PKT_BUF_SZ > B44_DMA_MASK) {
|
||||
+ if(mapping+RX_PKT_BUF_SZ > B44_DMA_MASK) {
|
||||
pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE);
|
||||
dev_kfree_skb_any(skb);
|
||||
return -ENOMEM;
|
||||
@@ -696,11 +668,6 @@
|
||||
dp->ctrl = cpu_to_le32(ctrl);
|
||||
dp->addr = cpu_to_le32((u32) mapping + bp->rx_offset + bp->dma_offset);
|
||||
|
||||
- if (bp->flags & B44_FLAG_RX_RING_HACK)
|
||||
- b44_sync_dma_desc_for_device(bp->pdev, bp->rx_ring_dma,
|
||||
- dest_idx * sizeof(dp),
|
||||
- DMA_BIDIRECTIONAL);
|
||||
-
|
||||
return RX_PKT_BUF_SZ;
|
||||
}
|
||||
|
||||
@@ -725,11 +692,6 @@
|
||||
pci_unmap_addr_set(dest_map, mapping,
|
||||
pci_unmap_addr(src_map, mapping));
|
||||
|
||||
- if (bp->flags & B44_FLAG_RX_RING_HACK)
|
||||
- b44_sync_dma_desc_for_cpu(bp->pdev, bp->rx_ring_dma,
|
||||
- src_idx * sizeof(src_desc),
|
||||
- DMA_BIDIRECTIONAL);
|
||||
-
|
||||
ctrl = src_desc->ctrl;
|
||||
if (dest_idx == (B44_RX_RING_SIZE - 1))
|
||||
ctrl |= cpu_to_le32(DESC_CTRL_EOT);
|
||||
@@ -738,14 +700,8 @@
|
||||
|
||||
dest_desc->ctrl = ctrl;
|
||||
dest_desc->addr = src_desc->addr;
|
||||
-
|
||||
src_map->skb = NULL;
|
||||
|
||||
- if (bp->flags & B44_FLAG_RX_RING_HACK)
|
||||
- b44_sync_dma_desc_for_device(bp->pdev, bp->rx_ring_dma,
|
||||
- dest_idx * sizeof(dest_desc),
|
||||
- DMA_BIDIRECTIONAL);
|
||||
-
|
||||
pci_dma_sync_single_for_device(bp->pdev, src_desc->addr,
|
||||
RX_PKT_BUF_SZ,
|
||||
PCI_DMA_FROMDEVICE);
|
||||
@@ -894,10 +850,11 @@
|
||||
{
|
||||
struct net_device *dev = dev_id;
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
+ unsigned long flags;
|
||||
u32 istat, imask;
|
||||
int handled = 0;
|
||||
|
||||
- spin_lock(&bp->lock);
|
||||
+ spin_lock_irqsave(&bp->lock, flags);
|
||||
|
||||
istat = br32(bp, B44_ISTAT);
|
||||
imask = br32(bp, B44_IMASK);
|
||||
@@ -908,12 +865,6 @@
|
||||
istat &= imask;
|
||||
if (istat) {
|
||||
handled = 1;
|
||||
-
|
||||
- if (unlikely(!netif_running(dev))) {
|
||||
- printk(KERN_INFO "%s: late interrupt.\n", dev->name);
|
||||
- goto irq_ack;
|
||||
- }
|
||||
-
|
||||
if (netif_rx_schedule_prep(dev)) {
|
||||
/* NOTE: These writes are posted by the readback of
|
||||
* the ISTAT register below.
|
||||
@@ -926,11 +877,10 @@
|
||||
dev->name);
|
||||
}
|
||||
|
||||
-irq_ack:
|
||||
bw32(bp, B44_ISTAT, istat);
|
||||
br32(bp, B44_ISTAT);
|
||||
}
|
||||
- spin_unlock(&bp->lock);
|
||||
+ spin_unlock_irqrestore(&bp->lock, flags);
|
||||
return IRQ_RETVAL(handled);
|
||||
}
|
||||
|
||||
@@ -958,7 +908,6 @@
|
||||
{
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
struct sk_buff *bounce_skb;
|
||||
- int rc = NETDEV_TX_OK;
|
||||
dma_addr_t mapping;
|
||||
u32 len, entry, ctrl;
|
||||
|
||||
@@ -968,28 +917,29 @@
|
||||
/* This is a hard error, log it. */
|
||||
if (unlikely(TX_BUFFS_AVAIL(bp) < 1)) {
|
||||
netif_stop_queue(dev);
|
||||
+ spin_unlock_irq(&bp->lock);
|
||||
printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n",
|
||||
dev->name);
|
||||
- goto err_out;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE);
|
||||
- if (mapping + len > B44_DMA_MASK) {
|
||||
+ if(mapping+len > B44_DMA_MASK) {
|
||||
/* Chip can't handle DMA to/from >1GB, use bounce buffer */
|
||||
pci_unmap_single(bp->pdev, mapping, len, PCI_DMA_TODEVICE);
|
||||
|
||||
bounce_skb = __dev_alloc_skb(TX_PKT_BUF_SZ,
|
||||
GFP_ATOMIC|GFP_DMA);
|
||||
if (!bounce_skb)
|
||||
- goto err_out;
|
||||
+ return NETDEV_TX_BUSY;
|
||||
|
||||
mapping = pci_map_single(bp->pdev, bounce_skb->data,
|
||||
len, PCI_DMA_TODEVICE);
|
||||
- if (mapping + len > B44_DMA_MASK) {
|
||||
+ if(mapping+len > B44_DMA_MASK) {
|
||||
pci_unmap_single(bp->pdev, mapping,
|
||||
len, PCI_DMA_TODEVICE);
|
||||
dev_kfree_skb_any(bounce_skb);
|
||||
- goto err_out;
|
||||
+ return NETDEV_TX_BUSY;
|
||||
}
|
||||
|
||||
memcpy(skb_put(bounce_skb, len), skb->data, skb->len);
|
||||
@@ -1009,11 +959,6 @@
|
||||
bp->tx_ring[entry].ctrl = cpu_to_le32(ctrl);
|
||||
bp->tx_ring[entry].addr = cpu_to_le32((u32) mapping+bp->dma_offset);
|
||||
|
||||
- if (bp->flags & B44_FLAG_TX_RING_HACK)
|
||||
- b44_sync_dma_desc_for_device(bp->pdev, bp->tx_ring_dma,
|
||||
- entry * sizeof(bp->tx_ring[0]),
|
||||
- DMA_TO_DEVICE);
|
||||
-
|
||||
entry = NEXT_TX(entry);
|
||||
|
||||
bp->tx_prod = entry;
|
||||
@@ -1029,16 +974,11 @@
|
||||
if (TX_BUFFS_AVAIL(bp) < 1)
|
||||
netif_stop_queue(dev);
|
||||
|
||||
- dev->trans_start = jiffies;
|
||||
-
|
||||
-out_unlock:
|
||||
spin_unlock_irq(&bp->lock);
|
||||
|
||||
- return rc;
|
||||
+ dev->trans_start = jiffies;
|
||||
|
||||
-err_out:
|
||||
- rc = NETDEV_TX_BUSY;
|
||||
- goto out_unlock;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int b44_change_mtu(struct net_device *dev, int new_mtu)
|
||||
@@ -1112,7 +1052,8 @@
|
||||
*
|
||||
* The chip has been shut down and the driver detached from
|
||||
* the networking, so no interrupts or new tx packets will
|
||||
- * end up in the driver.
|
||||
+ * end up in the driver. bp->lock is not held and we are not
|
||||
+ * in an interrupt context and thus may sleep.
|
||||
*/
|
||||
static void b44_init_rings(struct b44 *bp)
|
||||
{
|
||||
@@ -1123,16 +1064,6 @@
|
||||
memset(bp->rx_ring, 0, B44_RX_RING_BYTES);
|
||||
memset(bp->tx_ring, 0, B44_TX_RING_BYTES);
|
||||
|
||||
- if (bp->flags & B44_FLAG_RX_RING_HACK)
|
||||
- dma_sync_single_for_device(&bp->pdev->dev, bp->rx_ring_dma,
|
||||
- DMA_TABLE_BYTES,
|
||||
- PCI_DMA_BIDIRECTIONAL);
|
||||
-
|
||||
- if (bp->flags & B44_FLAG_TX_RING_HACK)
|
||||
- dma_sync_single_for_device(&bp->pdev->dev, bp->tx_ring_dma,
|
||||
- DMA_TABLE_BYTES,
|
||||
- PCI_DMA_TODEVICE);
|
||||
-
|
||||
for (i = 0; i < bp->rx_pending; i++) {
|
||||
if (b44_alloc_rx_skb(bp, -1, i) < 0)
|
||||
break;
|
||||
@@ -1145,33 +1076,23 @@
|
||||
*/
|
||||
static void b44_free_consistent(struct b44 *bp)
|
||||
{
|
||||
- kfree(bp->rx_buffers);
|
||||
- bp->rx_buffers = NULL;
|
||||
- kfree(bp->tx_buffers);
|
||||
- bp->tx_buffers = NULL;
|
||||
+ if (bp->rx_buffers) {
|
||||
+ kfree(bp->rx_buffers);
|
||||
+ bp->rx_buffers = NULL;
|
||||
+ }
|
||||
+ if (bp->tx_buffers) {
|
||||
+ kfree(bp->tx_buffers);
|
||||
+ bp->tx_buffers = NULL;
|
||||
+ }
|
||||
if (bp->rx_ring) {
|
||||
- if (bp->flags & B44_FLAG_RX_RING_HACK) {
|
||||
- dma_unmap_single(&bp->pdev->dev, bp->rx_ring_dma,
|
||||
- DMA_TABLE_BYTES,
|
||||
- DMA_BIDIRECTIONAL);
|
||||
- kfree(bp->rx_ring);
|
||||
- } else
|
||||
- pci_free_consistent(bp->pdev, DMA_TABLE_BYTES,
|
||||
- bp->rx_ring, bp->rx_ring_dma);
|
||||
+ pci_free_consistent(bp->pdev, DMA_TABLE_BYTES,
|
||||
+ bp->rx_ring, bp->rx_ring_dma);
|
||||
bp->rx_ring = NULL;
|
||||
- bp->flags &= ~B44_FLAG_RX_RING_HACK;
|
||||
}
|
||||
if (bp->tx_ring) {
|
||||
- if (bp->flags & B44_FLAG_TX_RING_HACK) {
|
||||
- dma_unmap_single(&bp->pdev->dev, bp->tx_ring_dma,
|
||||
- DMA_TABLE_BYTES,
|
||||
- DMA_TO_DEVICE);
|
||||
- kfree(bp->tx_ring);
|
||||
- } else
|
||||
- pci_free_consistent(bp->pdev, DMA_TABLE_BYTES,
|
||||
- bp->tx_ring, bp->tx_ring_dma);
|
||||
+ pci_free_consistent(bp->pdev, DMA_TABLE_BYTES,
|
||||
+ bp->tx_ring, bp->tx_ring_dma);
|
||||
bp->tx_ring = NULL;
|
||||
- bp->flags &= ~B44_FLAG_TX_RING_HACK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1184,67 +1105,25 @@
|
||||
int size;
|
||||
|
||||
size = B44_RX_RING_SIZE * sizeof(struct ring_info);
|
||||
- bp->rx_buffers = kzalloc(size, GFP_KERNEL);
|
||||
+ bp->rx_buffers = kmalloc(size, GFP_KERNEL);
|
||||
if (!bp->rx_buffers)
|
||||
goto out_err;
|
||||
+ memset(bp->rx_buffers, 0, size);
|
||||
|
||||
size = B44_TX_RING_SIZE * sizeof(struct ring_info);
|
||||
- bp->tx_buffers = kzalloc(size, GFP_KERNEL);
|
||||
+ bp->tx_buffers = kmalloc(size, GFP_KERNEL);
|
||||
if (!bp->tx_buffers)
|
||||
goto out_err;
|
||||
+ memset(bp->tx_buffers, 0, size);
|
||||
|
||||
size = DMA_TABLE_BYTES;
|
||||
bp->rx_ring = pci_alloc_consistent(bp->pdev, size, &bp->rx_ring_dma);
|
||||
- if (!bp->rx_ring) {
|
||||
- /* Allocation may have failed due to pci_alloc_consistent
|
||||
- insisting on use of GFP_DMA, which is more restrictive
|
||||
- than necessary... */
|
||||
- struct dma_desc *rx_ring;
|
||||
- dma_addr_t rx_ring_dma;
|
||||
-
|
||||
- rx_ring = kzalloc(size, GFP_KERNEL);
|
||||
- if (!rx_ring)
|
||||
- goto out_err;
|
||||
-
|
||||
- rx_ring_dma = dma_map_single(&bp->pdev->dev, rx_ring,
|
||||
- DMA_TABLE_BYTES,
|
||||
- DMA_BIDIRECTIONAL);
|
||||
-
|
||||
- if (rx_ring_dma + size > B44_DMA_MASK) {
|
||||
- kfree(rx_ring);
|
||||
- goto out_err;
|
||||
- }
|
||||
-
|
||||
- bp->rx_ring = rx_ring;
|
||||
- bp->rx_ring_dma = rx_ring_dma;
|
||||
- bp->flags |= B44_FLAG_RX_RING_HACK;
|
||||
- }
|
||||
+ if (!bp->rx_ring)
|
||||
+ goto out_err;
|
||||
|
||||
bp->tx_ring = pci_alloc_consistent(bp->pdev, size, &bp->tx_ring_dma);
|
||||
- if (!bp->tx_ring) {
|
||||
- /* Allocation may have failed due to pci_alloc_consistent
|
||||
- insisting on use of GFP_DMA, which is more restrictive
|
||||
- than necessary... */
|
||||
- struct dma_desc *tx_ring;
|
||||
- dma_addr_t tx_ring_dma;
|
||||
-
|
||||
- tx_ring = kzalloc(size, GFP_KERNEL);
|
||||
- if (!tx_ring)
|
||||
- goto out_err;
|
||||
-
|
||||
- tx_ring_dma = dma_map_single(&bp->pdev->dev, tx_ring,
|
||||
- DMA_TABLE_BYTES,
|
||||
- DMA_TO_DEVICE);
|
||||
-
|
||||
- if (tx_ring_dma + size > B44_DMA_MASK) {
|
||||
- kfree(tx_ring);
|
||||
- goto out_err;
|
||||
- }
|
||||
-
|
||||
- bp->tx_ring = tx_ring;
|
||||
- bp->tx_ring_dma = tx_ring_dma;
|
||||
- bp->flags |= B44_FLAG_TX_RING_HACK;
|
||||
- }
|
||||
+ if (!bp->tx_ring)
|
||||
+ goto out_err;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1394,21 +1273,19 @@
|
||||
|
||||
err = b44_alloc_consistent(bp);
|
||||
if (err)
|
||||
- goto out;
|
||||
+ return err;
|
||||
+
|
||||
+ err = request_irq(dev->irq, b44_interrupt, SA_SHIRQ, dev->name, dev);
|
||||
+ if (err)
|
||||
+ goto err_out_free;
|
||||
+
|
||||
+ spin_lock_irq(&bp->lock);
|
||||
|
||||
b44_init_rings(bp);
|
||||
b44_init_hw(bp);
|
||||
+ bp->flags |= B44_FLAG_INIT_COMPLETE;
|
||||
|
||||
- netif_carrier_off(dev);
|
||||
- b44_check_phy(bp);
|
||||
-
|
||||
- err = request_irq(dev->irq, b44_interrupt, SA_SHIRQ, dev->name, dev);
|
||||
- if (unlikely(err < 0)) {
|
||||
- b44_chip_reset(bp);
|
||||
- b44_free_rings(bp);
|
||||
- b44_free_consistent(bp);
|
||||
- goto out;
|
||||
- }
|
||||
+ spin_unlock_irq(&bp->lock);
|
||||
|
||||
init_timer(&bp->timer);
|
||||
bp->timer.expires = jiffies + HZ;
|
||||
@@ -1417,8 +1294,11 @@
|
||||
add_timer(&bp->timer);
|
||||
|
||||
b44_enable_ints(bp);
|
||||
- netif_start_queue(dev);
|
||||
-out:
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_out_free:
|
||||
+ b44_free_consistent(bp);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1453,8 +1333,6 @@
|
||||
|
||||
netif_stop_queue(dev);
|
||||
|
||||
- netif_poll_disable(dev);
|
||||
-
|
||||
del_timer_sync(&bp->timer);
|
||||
|
||||
spin_lock_irq(&bp->lock);
|
||||
@@ -1464,14 +1342,13 @@
|
||||
#endif
|
||||
b44_halt(bp);
|
||||
b44_free_rings(bp);
|
||||
+ bp->flags &= ~B44_FLAG_INIT_COMPLETE;
|
||||
netif_carrier_off(bp->dev);
|
||||
|
||||
spin_unlock_irq(&bp->lock);
|
||||
|
||||
free_irq(dev->irq, dev);
|
||||
|
||||
- netif_poll_enable(dev);
|
||||
-
|
||||
b44_free_consistent(bp);
|
||||
|
||||
return 0;
|
||||
@@ -1536,6 +1413,8 @@
|
||||
{
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
u32 val;
|
||||
+ int i=0;
|
||||
+ unsigned char zero[6] = {0,0,0,0,0,0};
|
||||
|
||||
val = br32(bp, B44_RXCONFIG);
|
||||
val &= ~(RXCONFIG_PROMISC | RXCONFIG_ALLMULTI);
|
||||
@@ -1543,17 +1422,14 @@
|
||||
val |= RXCONFIG_PROMISC;
|
||||
bw32(bp, B44_RXCONFIG, val);
|
||||
} else {
|
||||
- unsigned char zero[6] = {0, 0, 0, 0, 0, 0};
|
||||
- int i = 0;
|
||||
-
|
||||
__b44_set_mac_addr(bp);
|
||||
|
||||
if (dev->flags & IFF_ALLMULTI)
|
||||
val |= RXCONFIG_ALLMULTI;
|
||||
else
|
||||
- i = __b44_load_mcast(bp, dev);
|
||||
+ i=__b44_load_mcast(bp, dev);
|
||||
|
||||
- for (; i < 64; i++) {
|
||||
+ for(;i<64;i++) {
|
||||
__b44_cam_write(bp, zero, i);
|
||||
}
|
||||
bw32(bp, B44_RXCONFIG, val);
|
||||
@@ -1617,7 +1493,7 @@
|
||||
{
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
|
||||
- if (!netif_running(dev))
|
||||
+ if (!(bp->flags & B44_FLAG_INIT_COMPLETE))
|
||||
return -EAGAIN;
|
||||
cmd->supported = (SUPPORTED_Autoneg);
|
||||
cmd->supported |= (SUPPORTED_100baseT_Half |
|
||||
@@ -1628,14 +1504,14 @@
|
||||
|
||||
cmd->advertising = 0;
|
||||
if (bp->flags & B44_FLAG_ADV_10HALF)
|
||||
- cmd->advertising |= ADVERTISED_10baseT_Half;
|
||||
+ cmd->advertising |= ADVERTISE_10HALF;
|
||||
if (bp->flags & B44_FLAG_ADV_10FULL)
|
||||
- cmd->advertising |= ADVERTISED_10baseT_Full;
|
||||
+ cmd->advertising |= ADVERTISE_10FULL;
|
||||
if (bp->flags & B44_FLAG_ADV_100HALF)
|
||||
- cmd->advertising |= ADVERTISED_100baseT_Half;
|
||||
+ cmd->advertising |= ADVERTISE_100HALF;
|
||||
if (bp->flags & B44_FLAG_ADV_100FULL)
|
||||
- cmd->advertising |= ADVERTISED_100baseT_Full;
|
||||
- cmd->advertising |= ADVERTISED_Pause | ADVERTISED_Asym_Pause;
|
||||
+ cmd->advertising |= ADVERTISE_100FULL;
|
||||
+ cmd->advertising |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
|
||||
cmd->speed = (bp->flags & B44_FLAG_100_BASE_T) ?
|
||||
SPEED_100 : SPEED_10;
|
||||
cmd->duplex = (bp->flags & B44_FLAG_FULL_DUPLEX) ?
|
||||
@@ -1655,7 +1531,7 @@
|
||||
{
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
|
||||
- if (!netif_running(dev))
|
||||
+ if (!(bp->flags & B44_FLAG_INIT_COMPLETE))
|
||||
return -EAGAIN;
|
||||
|
||||
/* We do not support gigabit. */
|
||||
@@ -1785,37 +1661,6 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void b44_get_strings(struct net_device *dev, u32 stringset, u8 *data)
|
||||
-{
|
||||
- switch(stringset) {
|
||||
- case ETH_SS_STATS:
|
||||
- memcpy(data, *b44_gstrings, sizeof(b44_gstrings));
|
||||
- break;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-static int b44_get_stats_count(struct net_device *dev)
|
||||
-{
|
||||
- return ARRAY_SIZE(b44_gstrings);
|
||||
-}
|
||||
-
|
||||
-static void b44_get_ethtool_stats(struct net_device *dev,
|
||||
- struct ethtool_stats *stats, u64 *data)
|
||||
-{
|
||||
- struct b44 *bp = netdev_priv(dev);
|
||||
- u32 *val = &bp->hw_stats.tx_good_octets;
|
||||
- u32 i;
|
||||
-
|
||||
- spin_lock_irq(&bp->lock);
|
||||
-
|
||||
- b44_stats_update(bp);
|
||||
-
|
||||
- for (i = 0; i < ARRAY_SIZE(b44_gstrings); i++)
|
||||
- *data++ = *val++;
|
||||
-
|
||||
- spin_unlock_irq(&bp->lock);
|
||||
-}
|
||||
-
|
||||
static struct ethtool_ops b44_ethtool_ops = {
|
||||
.get_drvinfo = b44_get_drvinfo,
|
||||
.get_settings = b44_get_settings,
|
||||
@@ -1828,25 +1673,18 @@
|
||||
.set_pauseparam = b44_set_pauseparam,
|
||||
.get_msglevel = b44_get_msglevel,
|
||||
.set_msglevel = b44_set_msglevel,
|
||||
- .get_strings = b44_get_strings,
|
||||
- .get_stats_count = b44_get_stats_count,
|
||||
- .get_ethtool_stats = b44_get_ethtool_stats,
|
||||
- .get_perm_addr = ethtool_op_get_perm_addr,
|
||||
};
|
||||
|
||||
static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||
{
|
||||
struct mii_ioctl_data *data = if_mii(ifr);
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
- int err = -EINVAL;
|
||||
-
|
||||
- if (!netif_running(dev))
|
||||
- goto out;
|
||||
+ int err;
|
||||
|
||||
spin_lock_irq(&bp->lock);
|
||||
err = generic_mii_ioctl(&bp->mii_if, data, cmd, NULL);
|
||||
spin_unlock_irq(&bp->lock);
|
||||
-out:
|
||||
+
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1877,7 +1715,6 @@
|
||||
bp->dev->dev_addr[3] = eeprom[80];
|
||||
bp->dev->dev_addr[4] = eeprom[83];
|
||||
bp->dev->dev_addr[5] = eeprom[82];
|
||||
- memcpy(bp->dev->perm_addr, bp->dev->dev_addr, bp->dev->addr_len);
|
||||
|
||||
bp->phy_addr = eeprom[90] & 0x1f;
|
||||
|
||||
@@ -1942,9 +1779,9 @@
|
||||
|
||||
err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK);
|
||||
if (err) {
|
||||
- printk(KERN_ERR PFX "No usable DMA configuration, "
|
||||
- "aborting.\n");
|
||||
- goto err_out_free_res;
|
||||
+ printk(KERN_ERR PFX "No usable DMA configuration, "
|
||||
+ "aborting.\n");
|
||||
+ goto err_out_free_res;
|
||||
}
|
||||
|
||||
b44reg_base = pci_resource_start(pdev, 0);
|
||||
@@ -1966,8 +1803,10 @@
|
||||
bp = netdev_priv(dev);
|
||||
bp->pdev = pdev;
|
||||
bp->dev = dev;
|
||||
-
|
||||
- bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE);
|
||||
+ if (b44_debug >= 0)
|
||||
+ bp->msg_enable = (1 << b44_debug) - 1;
|
||||
+ else
|
||||
+ bp->msg_enable = B44_DEF_MSG_ENABLE;
|
||||
|
||||
spin_lock_init(&bp->lock);
|
||||
|
||||
@@ -2057,14 +1896,17 @@
|
||||
static void __devexit b44_remove_one(struct pci_dev *pdev)
|
||||
{
|
||||
struct net_device *dev = pci_get_drvdata(pdev);
|
||||
- struct b44 *bp = netdev_priv(dev);
|
||||
|
||||
- unregister_netdev(dev);
|
||||
- iounmap(bp->regs);
|
||||
- free_netdev(dev);
|
||||
- pci_release_regions(pdev);
|
||||
- pci_disable_device(pdev);
|
||||
- pci_set_drvdata(pdev, NULL);
|
||||
+ if (dev) {
|
||||
+ struct b44 *bp = netdev_priv(dev);
|
||||
+
|
||||
+ unregister_netdev(dev);
|
||||
+ iounmap(bp->regs);
|
||||
+ free_netdev(dev);
|
||||
+ pci_release_regions(pdev);
|
||||
+ pci_disable_device(pdev);
|
||||
+ pci_set_drvdata(pdev, NULL);
|
||||
+ }
|
||||
}
|
||||
|
||||
static int b44_suspend(struct pci_dev *pdev, pm_message_t state)
|
||||
@@ -2085,9 +1927,6 @@
|
||||
b44_free_rings(bp);
|
||||
|
||||
spin_unlock_irq(&bp->lock);
|
||||
-
|
||||
- free_irq(dev->irq, dev);
|
||||
- pci_disable_device(pdev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2097,15 +1936,10 @@
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
|
||||
pci_restore_state(pdev);
|
||||
- pci_enable_device(pdev);
|
||||
- pci_set_master(pdev);
|
||||
|
||||
if (!netif_running(dev))
|
||||
return 0;
|
||||
|
||||
- if (request_irq(dev->irq, b44_interrupt, SA_SHIRQ, dev->name, dev))
|
||||
- printk(KERN_ERR PFX "%s: request_irq failed\n", dev->name);
|
||||
-
|
||||
spin_lock_irq(&bp->lock);
|
||||
|
||||
b44_init_rings(bp);
|
||||
@@ -2117,7 +1951,6 @@
|
||||
add_timer(&bp->timer);
|
||||
|
||||
b44_enable_ints(bp);
|
||||
- netif_wake_queue(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2132,12 +1965,6 @@
|
||||
|
||||
static int __init b44_init(void)
|
||||
{
|
||||
- unsigned int dma_desc_align_size = dma_get_cache_alignment();
|
||||
-
|
||||
- /* Setup paramaters for syncing RX/TX DMA descriptors */
|
||||
- dma_desc_align_mask = ~(dma_desc_align_size - 1);
|
||||
- dma_desc_sync_size = max(dma_desc_align_size, sizeof(struct dma_desc));
|
||||
-
|
||||
return pci_module_init(&b44_driver);
|
||||
}
|
||||
|
||||
diff -ur linux-2.6.15-rc5/drivers/net/b44.h linux-2.6.15-rc5-openwrt/drivers/net/b44.h
|
||||
--- linux-2.6.15-rc5/drivers/net/b44.h 2005-12-04 06:10:42.000000000 +0100
|
||||
+++ linux-2.6.15-rc5-openwrt/drivers/net/b44.h 2005-08-15 02:20:18.000000000 +0200
|
||||
@@ -346,63 +346,29 @@
|
||||
|
||||
#define B44_MCAST_TABLE_SIZE 32
|
||||
|
||||
-#define B44_STAT_REG_DECLARE \
|
||||
- _B44(tx_good_octets) \
|
||||
- _B44(tx_good_pkts) \
|
||||
- _B44(tx_octets) \
|
||||
- _B44(tx_pkts) \
|
||||
- _B44(tx_broadcast_pkts) \
|
||||
- _B44(tx_multicast_pkts) \
|
||||
- _B44(tx_len_64) \
|
||||
- _B44(tx_len_65_to_127) \
|
||||
- _B44(tx_len_128_to_255) \
|
||||
- _B44(tx_len_256_to_511) \
|
||||
- _B44(tx_len_512_to_1023) \
|
||||
- _B44(tx_len_1024_to_max) \
|
||||
- _B44(tx_jabber_pkts) \
|
||||
- _B44(tx_oversize_pkts) \
|
||||
- _B44(tx_fragment_pkts) \
|
||||
- _B44(tx_underruns) \
|
||||
- _B44(tx_total_cols) \
|
||||
- _B44(tx_single_cols) \
|
||||
- _B44(tx_multiple_cols) \
|
||||
- _B44(tx_excessive_cols) \
|
||||
- _B44(tx_late_cols) \
|
||||
- _B44(tx_defered) \
|
||||
- _B44(tx_carrier_lost) \
|
||||
- _B44(tx_pause_pkts) \
|
||||
- _B44(rx_good_octets) \
|
||||
- _B44(rx_good_pkts) \
|
||||
- _B44(rx_octets) \
|
||||
- _B44(rx_pkts) \
|
||||
- _B44(rx_broadcast_pkts) \
|
||||
- _B44(rx_multicast_pkts) \
|
||||
- _B44(rx_len_64) \
|
||||
- _B44(rx_len_65_to_127) \
|
||||
- _B44(rx_len_128_to_255) \
|
||||
- _B44(rx_len_256_to_511) \
|
||||
- _B44(rx_len_512_to_1023) \
|
||||
- _B44(rx_len_1024_to_max) \
|
||||
- _B44(rx_jabber_pkts) \
|
||||
- _B44(rx_oversize_pkts) \
|
||||
- _B44(rx_fragment_pkts) \
|
||||
- _B44(rx_missed_pkts) \
|
||||
- _B44(rx_crc_align_errs) \
|
||||
- _B44(rx_undersize) \
|
||||
- _B44(rx_crc_errs) \
|
||||
- _B44(rx_align_errs) \
|
||||
- _B44(rx_symbol_errs) \
|
||||
- _B44(rx_pause_pkts) \
|
||||
- _B44(rx_nonpause_pkts)
|
||||
-
|
||||
/* SW copy of device statistics, kept up to date by periodic timer
|
||||
- * which probes HW values. Check b44_stats_update if you mess with
|
||||
- * the layout
|
||||
+ * which probes HW values. Must have same relative layout as HW
|
||||
+ * register above, because b44_stats_update depends upon this.
|
||||
*/
|
||||
struct b44_hw_stats {
|
||||
-#define _B44(x) u32 x;
|
||||
-B44_STAT_REG_DECLARE
|
||||
-#undef _B44
|
||||
+ u32 tx_good_octets, tx_good_pkts, tx_octets;
|
||||
+ u32 tx_pkts, tx_broadcast_pkts, tx_multicast_pkts;
|
||||
+ u32 tx_len_64, tx_len_65_to_127, tx_len_128_to_255;
|
||||
+ u32 tx_len_256_to_511, tx_len_512_to_1023, tx_len_1024_to_max;
|
||||
+ u32 tx_jabber_pkts, tx_oversize_pkts, tx_fragment_pkts;
|
||||
+ u32 tx_underruns, tx_total_cols, tx_single_cols;
|
||||
+ u32 tx_multiple_cols, tx_excessive_cols, tx_late_cols;
|
||||
+ u32 tx_defered, tx_carrier_lost, tx_pause_pkts;
|
||||
+ u32 __pad1[8];
|
||||
+
|
||||
+ u32 rx_good_octets, rx_good_pkts, rx_octets;
|
||||
+ u32 rx_pkts, rx_broadcast_pkts, rx_multicast_pkts;
|
||||
+ u32 rx_len_64, rx_len_65_to_127, rx_len_128_to_255;
|
||||
+ u32 rx_len_256_to_511, rx_len_512_to_1023, rx_len_1024_to_max;
|
||||
+ u32 rx_jabber_pkts, rx_oversize_pkts, rx_fragment_pkts;
|
||||
+ u32 rx_missed_pkts, rx_crc_align_errs, rx_undersize;
|
||||
+ u32 rx_crc_errs, rx_align_errs, rx_symbol_errs;
|
||||
+ u32 rx_pause_pkts, rx_nonpause_pkts;
|
||||
};
|
||||
|
||||
struct b44 {
|
||||
@@ -420,6 +386,7 @@
|
||||
|
||||
u32 dma_offset;
|
||||
u32 flags;
|
||||
+#define B44_FLAG_INIT_COMPLETE 0x00000001
|
||||
#define B44_FLAG_BUGGY_TXPTR 0x00000002
|
||||
#define B44_FLAG_REORDER_BUG 0x00000004
|
||||
#define B44_FLAG_PAUSE_AUTO 0x00008000
|
||||
@@ -433,8 +400,6 @@
|
||||
#define B44_FLAG_ADV_100HALF 0x04000000
|
||||
#define B44_FLAG_ADV_100FULL 0x08000000
|
||||
#define B44_FLAG_INTERNAL_PHY 0x10000000
|
||||
-#define B44_FLAG_RX_RING_HACK 0x20000000
|
||||
-#define B44_FLAG_TX_RING_HACK 0x40000000
|
||||
|
||||
u32 rx_offset;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
--- linux-2.6.12.5/drivers/net/b44.c 2005-08-15 02:20:18.000000000 +0200
|
||||
+++ linux-2.6.12.5-b44/drivers/net/b44.c 2005-09-16 22:19:33.841633800 +0200
|
||||
diff -ur linux-2.6.14.3/drivers/net/b44.c linux-2.6.14.3-openwrt/drivers/net/b44.c
|
||||
--- linux-2.6.14.3/drivers/net/b44.c 2005-11-24 23:10:21.000000000 +0100
|
||||
+++ linux-2.6.14.3-openwrt/drivers/net/b44.c 2005-12-08 13:24:35.000000000 +0100
|
||||
@@ -1,7 +1,8 @@
|
||||
-/* b44.c: Broadcom 4400 device driver.
|
||||
+/* b44.c: Broadcom 4400/47xx device driver.
|
||||
@@ -615,7 +615,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
}
|
||||
|
||||
static int b44_open(struct net_device *dev)
|
||||
@@ -1416,11 +1460,11 @@
|
||||
@@ -1419,11 +1463,11 @@
|
||||
int i=0;
|
||||
unsigned char zero[6] = {0,0,0,0,0,0};
|
||||
|
||||
@@ -629,7 +629,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
} else {
|
||||
__b44_set_mac_addr(bp);
|
||||
|
||||
@@ -1432,9 +1476,9 @@
|
||||
@@ -1435,9 +1479,9 @@
|
||||
for(;i<64;i++) {
|
||||
__b44_cam_write(bp, zero, i);
|
||||
}
|
||||
@@ -642,7 +642,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1675,17 +1719,288 @@
|
||||
@@ -1678,17 +1722,288 @@
|
||||
.set_msglevel = b44_set_msglevel,
|
||||
};
|
||||
|
||||
@@ -935,7 +935,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
}
|
||||
|
||||
/* Read 128-bytes of EEPROM. */
|
||||
@@ -1695,7 +2010,7 @@
|
||||
@@ -1698,7 +2013,7 @@
|
||||
u16 *ptr = (u16 *) data;
|
||||
|
||||
for (i = 0; i < 128; i += 2)
|
||||
@@ -944,7 +944,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1704,19 +2019,41 @@
|
||||
@@ -1707,19 +2022,41 @@
|
||||
{
|
||||
u8 eeprom[128];
|
||||
int err;
|
||||
@@ -998,7 +998,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
|
||||
/* With this, plus the rx_header prepended to the data by the
|
||||
* hardware, we'll land the ethernet header on a 2-byte boundary.
|
||||
@@ -1726,13 +2063,12 @@
|
||||
@@ -1729,13 +2066,12 @@
|
||||
bp->imask = IMASK_DEF;
|
||||
|
||||
bp->core_unit = ssb_core_unit(bp);
|
||||
@@ -1014,7 +1014,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
}
|
||||
|
||||
static int __devinit b44_init_one(struct pci_dev *pdev,
|
||||
@@ -1810,7 +2146,7 @@
|
||||
@@ -1813,7 +2149,7 @@
|
||||
|
||||
spin_lock_init(&bp->lock);
|
||||
|
||||
@@ -1023,7 +1023,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
if (bp->regs == 0UL) {
|
||||
printk(KERN_ERR PFX "Cannot map device registers, "
|
||||
"aborting.\n");
|
||||
@@ -1871,15 +2207,21 @@
|
||||
@@ -1874,15 +2210,21 @@
|
||||
|
||||
pci_save_state(bp->pdev);
|
||||
|
||||
@@ -1047,7 +1047,7 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
|
||||
err_out_free_dev:
|
||||
free_netdev(dev);
|
||||
@@ -1901,7 +2243,7 @@
|
||||
@@ -1904,7 +2246,7 @@
|
||||
struct b44 *bp = netdev_priv(dev);
|
||||
|
||||
unregister_netdev(dev);
|
||||
@@ -1056,9 +1056,9 @@ diff -Nur linux-2.6.12.5/drivers/net/b44.c linux-2.6.12.5-b44/drivers/net/b44.c
|
||||
free_netdev(dev);
|
||||
pci_release_regions(pdev);
|
||||
pci_disable_device(pdev);
|
||||
diff -Nur linux-2.6.12.5/drivers/net/b44.h linux-2.6.12.5-b44/drivers/net/b44.h
|
||||
--- linux-2.6.12.5/drivers/net/b44.h 2005-08-15 02:20:18.000000000 +0200
|
||||
+++ linux-2.6.12.5-b44/drivers/net/b44.h 2005-09-16 22:18:06.217954624 +0200
|
||||
diff -ur linux-2.6.14.3/drivers/net/b44.h linux-2.6.14.3-openwrt/drivers/net/b44.h
|
||||
--- linux-2.6.14.3/drivers/net/b44.h 2005-11-24 23:10:21.000000000 +0100
|
||||
+++ linux-2.6.14.3-openwrt/drivers/net/b44.h 2005-12-08 13:24:35.000000000 +0100
|
||||
@@ -292,6 +292,9 @@
|
||||
#define SSB_PCI_MASK1 0xfc000000
|
||||
#define SSB_PCI_MASK2 0xc0000000
|
||||
@@ -1,6 +1,6 @@
|
||||
--- linux-2.6.11.3-stock/include/linux/netfilter_ipv4/ip_conntrack.h 2005-03-13 00:44:41.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/include/linux/netfilter_ipv4/ip_conntrack.h 2005-03-13 20:30:01.000000000 -0600
|
||||
@@ -177,6 +177,15 @@ struct ip_conntrack
|
||||
--- linux-2.6.14/include/linux/netfilter_ipv4/ip_conntrack.h 2005-10-27 19:02:08.000000000 -0500
|
||||
+++ linux-2.6.14-layer7/include/linux/netfilter_ipv4/ip_conntrack.h 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -253,6 +253,15 @@ struct ip_conntrack
|
||||
/* Traversed often, so hopefully in different cacheline to top */
|
||||
/* These are my tuples; original and reply */
|
||||
struct ip_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX];
|
||||
@@ -16,8 +16,8 @@
|
||||
};
|
||||
|
||||
struct ip_conntrack_expect
|
||||
--- linux-2.6.11.3-stock/include/linux/netfilter_ipv4/ipt_layer7.h 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/include/linux/netfilter_ipv4/ipt_layer7.h 2005-03-13 20:30:01.000000000 -0600
|
||||
--- linux-2.6.14/include/linux/netfilter_ipv4/ipt_layer7.h 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.14-layer7/include/linux/netfilter_ipv4/ipt_layer7.h 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -0,0 +1,26 @@
|
||||
+/*
|
||||
+ By Matthew Strait <quadong@users.sf.net>, Dec 2003.
|
||||
@@ -45,9 +45,9 @@
|
||||
+};
|
||||
+
|
||||
+#endif /* _IPT_LAYER7_H */
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/Kconfig 2005-03-13 00:44:38.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/Kconfig 2005-03-13 20:30:01.000000000 -0600
|
||||
@@ -146,6 +146,33 @@ config IP_NF_MATCH_MAC
|
||||
--- linux-2.6.14/net/ipv4/netfilter/Kconfig 2005-10-27 19:02:08.000000000 -0500
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/Kconfig 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -205,6 +205,24 @@ config IP_NF_MATCH_MAC
|
||||
|
||||
To compile it as a module, choose M here. If unsure, say N.
|
||||
|
||||
@@ -68,35 +68,26 @@
|
||||
+ depends on IP_NF_MATCH_LAYER7
|
||||
+ help
|
||||
+ Say Y to get lots of debugging output.
|
||||
+
|
||||
+config IP_NF_MATCH_LAYER7_MAXDATALEN
|
||||
+ int "Buffer size for application layer data" if IP_NF_MATCH_LAYER7
|
||||
+ range 256 65536
|
||||
+ default 2048
|
||||
+ help
|
||||
+ Size of the buffer that the application layer data is stored in.
|
||||
+ Unless you know what you're doing, leave it at the default of 2kB.
|
||||
+
|
||||
+
|
||||
config IP_NF_MATCH_PKTTYPE
|
||||
tristate "Packet type match support"
|
||||
depends on IP_NF_IPTABLES
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/Makefile 2005-03-13 00:44:14.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/Makefile 2005-03-13 20:30:01.000000000 -0600
|
||||
@@ -60,6 +60,8 @@ obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ip
|
||||
obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt_physdev.o
|
||||
--- linux-2.6.14/net/ipv4/netfilter/Makefile 2005-10-27 19:02:08.000000000 -0500
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/Makefile 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -74,6 +74,8 @@ obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt
|
||||
obj-$(CONFIG_IP_NF_MATCH_COMMENT) += ipt_comment.o
|
||||
obj-$(CONFIG_IP_NF_MATCH_STRING) += ipt_string.o
|
||||
|
||||
+obj-$(CONFIG_IP_NF_MATCH_LAYER7) += ipt_layer7.o
|
||||
+
|
||||
# targets
|
||||
obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
|
||||
obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/ip_conntrack_core.c 2005-03-13 00:43:57.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/ip_conntrack_core.c 2005-03-13 22:09:32.000000000 -0600
|
||||
@@ -247,6 +247,13 @@ destroy_conntrack(struct nf_conntrack *n
|
||||
--- linux-2.6.14/net/ipv4/netfilter/ip_conntrack_core.c 2005-10-27 19:02:08.000000000 -0500
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/ip_conntrack_core.c 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -335,6 +335,13 @@ destroy_conntrack(struct nf_conntrack *n
|
||||
* too. */
|
||||
remove_expectations(ct);
|
||||
ip_ct_remove_expectations(ct);
|
||||
|
||||
+ #if defined(CONFIG_IP_NF_MATCH_LAYER7) || defined(CONFIG_IP_NF_MATCH_LAYER7_MODULE)
|
||||
+ if(ct->layer7.app_proto)
|
||||
@@ -108,10 +99,10 @@
|
||||
/* We overload first tuple to link into unconfirmed list. */
|
||||
if (!is_confirmed(ct)) {
|
||||
BUG_ON(list_empty(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list));
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/ip_conntrack_standalone.c 2005-03-13 00:44:25.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/ip_conntrack_standalone.c 2005-03-13 20:30:01.000000000 -0600
|
||||
@@ -152,6 +152,12 @@ static int ct_seq_real_show(const struct
|
||||
return 1;
|
||||
--- linux-2.6.14/net/ipv4/netfilter/ip_conntrack_standalone.c 2005-10-27 19:02:08.000000000 -0500
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/ip_conntrack_standalone.c 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -188,6 +188,12 @@ static int ct_seq_show(struct seq_file *
|
||||
return -ENOSPC;
|
||||
#endif
|
||||
|
||||
+#if defined(CONFIG_IP_NF_MATCH_LAYER7) || defined(CONFIG_IP_NF_MATCH_LAYER7_MODULE)
|
||||
@@ -121,11 +112,11 @@
|
||||
+#endif
|
||||
+
|
||||
if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
|
||||
return 1;
|
||||
return -ENOSPC;
|
||||
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/ipt_layer7.c 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/ipt_layer7.c 2005-03-13 20:30:01.000000000 -0600
|
||||
@@ -0,0 +1,552 @@
|
||||
--- linux-2.6.14/net/ipv4/netfilter/ipt_layer7.c 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/ipt_layer7.c 2005-11-12 17:49:24.000000000 -0600
|
||||
@@ -0,0 +1,569 @@
|
||||
+/*
|
||||
+ Kernel module to match application layer (OSI layer 7)
|
||||
+ data in connections.
|
||||
@@ -151,7 +142,7 @@
|
||||
+#include <linux/ctype.h>
|
||||
+#include <net/ip.h>
|
||||
+#include <net/tcp.h>
|
||||
+#include <linux/netfilter_ipv4/lockhelp.h>
|
||||
+#include <linux/spinlock.h>
|
||||
+
|
||||
+#include "regexp/regexp.c"
|
||||
+
|
||||
@@ -161,8 +152,13 @@
|
||||
+MODULE_AUTHOR("Matthew Strait <quadong@users.sf.net>, Ethan Sommer <sommere@users.sf.net>");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("iptables application layer match module");
|
||||
+MODULE_VERSION("2.0");
|
||||
+
|
||||
+#if defined(CONFIG_IP_NF_MATCH_LAYER7_DEBUG)
|
||||
+static int maxdatalen = 2048; // this is the default
|
||||
+module_param(maxdatalen, int, 0444);
|
||||
+MODULE_PARM_DESC(maxdatalen, "maximum bytes of data looked at by l7-filter");
|
||||
+
|
||||
+#ifdef CONFIG_IP_NF_MATCH_LAYER7_DEBUG
|
||||
+ #define DPRINTK(format,args...) printk(format,##args)
|
||||
+#else
|
||||
+ #define DPRINTK(format,args...)
|
||||
@@ -173,7 +169,7 @@
|
||||
+
|
||||
+/* Number of packets whose data we look at.
|
||||
+This can be modified through /proc/net/layer7_numpackets */
|
||||
+static int num_packets = 8;
|
||||
+static int num_packets = 10;
|
||||
+
|
||||
+static struct pattern_cache {
|
||||
+ char * regex_string;
|
||||
@@ -196,10 +192,10 @@
|
||||
+ time. In this case, we have to protect the conntracks and the list of
|
||||
+ compiled patterns.
|
||||
+*/
|
||||
+DECLARE_RWLOCK(ct_lock);
|
||||
+DECLARE_LOCK(list_lock);
|
||||
+DEFINE_RWLOCK(ct_lock);
|
||||
+DEFINE_SPINLOCK(list_lock);
|
||||
+
|
||||
+#if CONFIG_IP_NF_MATCH_LAYER7_DEBUG
|
||||
+#ifdef CONFIG_IP_NF_MATCH_LAYER7_DEBUG
|
||||
+/* Converts an unfriendly string into a friendly one by
|
||||
+replacing unprintables with periods and all whitespace with " ". */
|
||||
+static char * friendly_print(unsigned char * s)
|
||||
@@ -366,7 +362,7 @@
|
||||
+ struct ipt_layer7_info * info)
|
||||
+{
|
||||
+ /* If we're in here, throw the app data away */
|
||||
+ WRITE_LOCK(&ct_lock);
|
||||
+ write_lock(&ct_lock);
|
||||
+ if(master_conntrack->layer7.app_data != NULL) {
|
||||
+
|
||||
+ #ifdef CONFIG_IP_NF_MATCH_LAYER7_DEBUG
|
||||
@@ -385,38 +381,38 @@
|
||||
+ kfree(master_conntrack->layer7.app_data);
|
||||
+ master_conntrack->layer7.app_data = NULL; /* don't free again */
|
||||
+ }
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+
|
||||
+ if(master_conntrack->layer7.app_proto){
|
||||
+ /* Here child connections set their .app_proto (for /proc/net/ip_conntrack) */
|
||||
+ WRITE_LOCK(&ct_lock);
|
||||
+ write_lock(&ct_lock);
|
||||
+ if(!conntrack->layer7.app_proto) {
|
||||
+ conntrack->layer7.app_proto = kmalloc(strlen(master_conntrack->layer7.app_proto)+1, GFP_ATOMIC);
|
||||
+ if(!conntrack->layer7.app_proto){
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_ERR "layer7: out of memory in match_no_append, bailing.\n");
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ strcpy(conntrack->layer7.app_proto, master_conntrack->layer7.app_proto);
|
||||
+ }
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+
|
||||
+ return (!strcmp(master_conntrack->layer7.app_proto, info->protocol));
|
||||
+ }
|
||||
+ else {
|
||||
+ /* If not classified, set to "unknown" to distinguish from
|
||||
+ connections that are still being tested. */
|
||||
+ WRITE_LOCK(&ct_lock);
|
||||
+ write_lock(&ct_lock);
|
||||
+ master_conntrack->layer7.app_proto = kmalloc(strlen("unknown")+1, GFP_ATOMIC);
|
||||
+ if(!master_conntrack->layer7.app_proto){
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_ERR "layer7: out of memory in match_no_append, bailing.\n");
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ strcpy(master_conntrack->layer7.app_proto, "unknown");
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
@@ -430,7 +426,7 @@
|
||||
+
|
||||
+ /* Strip nulls. Make everything lower case (our regex lib doesn't
|
||||
+ do case insensitivity). Add it to the end of the current data. */
|
||||
+ for(i = 0; i < CONFIG_IP_NF_MATCH_LAYER7_MAXDATALEN-oldlength-1 &&
|
||||
+ for(i = 0; i < maxdatalen-oldlength-1 &&
|
||||
+ i < appdatalen; i++) {
|
||||
+ if(app_data[i] != '\0') {
|
||||
+ master_conntrack->layer7.app_data[length+oldlength] =
|
||||
@@ -463,13 +459,12 @@
|
||||
+ return info->invert;
|
||||
+ }
|
||||
+
|
||||
+ /* Treat the parent and all its children together as one connection,
|
||||
+ except for the purpose of setting conntrack->layer7.app_proto in the
|
||||
+ actual connection. This makes /proc/net/ip_conntrack somewhat more
|
||||
+ satisfying. */
|
||||
+ if(!(conntrack = ip_conntrack_get((struct sk_buff *)skb, &ctinfo)) ||
|
||||
+ /* Treat parent & all its children together as one connection, except
|
||||
+ for the purpose of setting conntrack->layer7.app_proto in the actual
|
||||
+ connection. This makes /proc/net/ip_conntrack more satisfying. */
|
||||
+ if(!(conntrack = ip_conntrack_get((struct sk_buff *)skb, &ctinfo)) ||
|
||||
+ !(master_conntrack = ip_conntrack_get((struct sk_buff *)skb, &master_ctinfo))) {
|
||||
+ DPRINTK("layer7: packet is not from a known connection, giving up.\n");
|
||||
+ //DPRINTK("layer7: packet is not from a known connection, giving up.\n");
|
||||
+ return info->invert;
|
||||
+ }
|
||||
+
|
||||
@@ -505,25 +500,25 @@
|
||||
+ app_data = skb->data + app_data_offset(skb);
|
||||
+ appdatalen = skb->tail - app_data;
|
||||
+
|
||||
+ LOCK_BH(&list_lock);
|
||||
+ spin_lock_bh(&list_lock);
|
||||
+ /* the return value gets checked later, when we're ready to use it */
|
||||
+ comppattern = compile_and_cache(info->pattern, info->protocol);
|
||||
+ UNLOCK_BH(&list_lock);
|
||||
+ spin_unlock_bh(&list_lock);
|
||||
+
|
||||
+ /* On the first packet of a connection, allocate space for app data */
|
||||
+ WRITE_LOCK(&ct_lock);
|
||||
+ write_lock(&ct_lock);
|
||||
+ if(TOTAL_PACKETS == 1 && !skb->cb[0] && !master_conntrack->layer7.app_data) {
|
||||
+ master_conntrack->layer7.app_data = kmalloc(CONFIG_IP_NF_MATCH_LAYER7_MAXDATALEN, GFP_ATOMIC);
|
||||
+ master_conntrack->layer7.app_data = kmalloc(maxdatalen, GFP_ATOMIC);
|
||||
+ if(!master_conntrack->layer7.app_data){
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_ERR "layer7: out of memory in match, bailing.\n");
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+ return info->invert;
|
||||
+ }
|
||||
+
|
||||
+ master_conntrack->layer7.app_data[0] = '\0';
|
||||
+ }
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+
|
||||
+ /* Can be here, but unallocated, if numpackets is increased near
|
||||
+ the beginning of a connection */
|
||||
@@ -532,9 +527,9 @@
|
||||
+
|
||||
+ if(!skb->cb[0]){
|
||||
+ int newbytes;
|
||||
+ WRITE_LOCK(&ct_lock);
|
||||
+ write_lock(&ct_lock);
|
||||
+ newbytes = add_data(master_conntrack, app_data, appdatalen);
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+
|
||||
+ if(newbytes == 0) { /* didn't add any data */
|
||||
+ skb->cb[0] = 1;
|
||||
@@ -549,21 +544,21 @@
|
||||
+ pattern_result = 0;
|
||||
+ /* If the regexp failed to compile, don't bother running it */
|
||||
+ } else if(comppattern && regexec(comppattern, master_conntrack->layer7.app_data)) {
|
||||
+ DPRINTK("layer7: regexec positive: %s!\n", info->protocol);
|
||||
+ DPRINTK("layer7: matched %s\n", info->protocol);
|
||||
+ pattern_result = 1;
|
||||
+ } else pattern_result = 0;
|
||||
+
|
||||
+ if(pattern_result) {
|
||||
+ WRITE_LOCK(&ct_lock);
|
||||
+ write_lock(&ct_lock);
|
||||
+ master_conntrack->layer7.app_proto = kmalloc(strlen(info->protocol)+1, GFP_ATOMIC);
|
||||
+ if(!master_conntrack->layer7.app_proto){
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_ERR "layer7: out of memory in match, bailing.\n");
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+ return (pattern_result ^ info->invert);
|
||||
+ }
|
||||
+ strcpy(master_conntrack->layer7.app_proto, info->protocol);
|
||||
+ WRITE_UNLOCK(&ct_lock);
|
||||
+ write_unlock(&ct_lock);
|
||||
+ }
|
||||
+
|
||||
+ /* mark the packet seen */
|
||||
@@ -632,7 +627,10 @@
|
||||
+ return count;
|
||||
+ }
|
||||
+
|
||||
+ copy_from_user(foo, buffer, count);
|
||||
+ if(copy_from_user(foo, buffer, count)) {
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ num_packets = my_atoi(foo);
|
||||
+ kfree (foo);
|
||||
@@ -667,6 +665,16 @@
|
||||
+static int __init init(void)
|
||||
+{
|
||||
+ layer7_init_proc();
|
||||
+ if(maxdatalen < 1) {
|
||||
+ printk(KERN_WARNING "layer7: maxdatalen can't be < 1, using 1\n");
|
||||
+ maxdatalen = 1;
|
||||
+ }
|
||||
+ /* This is not a hard limit. It's just here to prevent people from
|
||||
+ bringing their slow machines to a grinding halt. */
|
||||
+ else if(maxdatalen > 65536) {
|
||||
+ printk(KERN_WARNING "layer7: maxdatalen can't be > 65536, using 65536\n");
|
||||
+ maxdatalen = 65536;
|
||||
+ }
|
||||
+ return ipt_register_match(&layer7_match);
|
||||
+}
|
||||
+
|
||||
@@ -678,8 +686,8 @@
|
||||
+
|
||||
+module_init(init);
|
||||
+module_exit(fini);
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/regexp/regexp.c 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/regexp/regexp.c 2005-03-13 20:30:01.000000000 -0600
|
||||
--- linux-2.6.14/net/ipv4/netfilter/regexp/regexp.c 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/regexp/regexp.c 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -0,0 +1,1195 @@
|
||||
+/*
|
||||
+ * regcomp and regexec -- regsub and regerror are elsewhere
|
||||
@@ -1876,8 +1884,8 @@
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/regexp/regexp.h 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/regexp/regexp.h 2005-03-13 20:30:01.000000000 -0600
|
||||
--- linux-2.6.14/net/ipv4/netfilter/regexp/regexp.h 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/regexp/regexp.h 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -0,0 +1,41 @@
|
||||
+/*
|
||||
+ * Definitions etc. for regexp(3) routines.
|
||||
@@ -1920,16 +1928,16 @@
|
||||
+void regerror(char *s);
|
||||
+
|
||||
+#endif
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/regexp/regmagic.h 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/regexp/regmagic.h 2005-03-13 20:30:01.000000000 -0600
|
||||
--- linux-2.6.14/net/ipv4/netfilter/regexp/regmagic.h 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/regexp/regmagic.h 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -0,0 +1,5 @@
|
||||
+/*
|
||||
+ * The first byte of the regexp internal "program" is actually this magic
|
||||
+ * number; the start node begins in the second byte.
|
||||
+ */
|
||||
+#define MAGIC 0234
|
||||
--- linux-2.6.11.3-stock/net/ipv4/netfilter/regexp/regsub.c 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.11.3-layer7/net/ipv4/netfilter/regexp/regsub.c 2005-03-13 20:30:01.000000000 -0600
|
||||
--- linux-2.6.14/net/ipv4/netfilter/regexp/regsub.c 1969-12-31 18:00:00.000000000 -0600
|
||||
+++ linux-2.6.14-layer7/net/ipv4/netfilter/regexp/regsub.c 2005-11-12 17:31:34.000000000 -0600
|
||||
@@ -0,0 +1,95 @@
|
||||
+/*
|
||||
+ * regsub
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user