Update of /cvsroot/leaf/src/bering-uclibc/apps/linux/patches
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3885
Added Files:
linux-2.4.28-imq2.diff linux-2.4.32-ipv4zones-0.1.2.patch
sk98lin_v10.61.3.3_2.4.34.patch
Log Message:
patches for ipv4zones, Linux IMQ and
Gigabit Ethernet driver for Marvell and SysKonnect network adapter cards
(sk98lin)
provided by NiTro
--- NEW FILE: linux-2.4.28-imq2.diff ---
diff -aurN linux-2.4.28-orig/Documentation/Configure.help
linux-2.4.28/Documentation/Configure.help
--- linux-2.4.28-orig/Documentation/Configure.help 2004-11-17
11:54:20.000000000 +0000
+++ linux-2.4.28/Documentation/Configure.help 2004-12-14 11:43:42.000000000
+0000
@@ -3147,6 +3147,22 @@
If you want to compile it as a module, say M here and read
<file:Documentation/modules.txt>. If unsure, say `N'.
+IMQ target support
+CONFIG_IP_NF_TARGET_IMQ
+ This option adds a `IMQ' target which is used to specify if and
+ to which imq device packets should get enqueued/dequeued.
+
+ If you want to compile it as a module, say M here and read
+ <file:Documentation/modules.txt>. If unsure, say `N'.
+
+IMQ target support
+CONFIG_IP6_NF_TARGET_IMQ
+ This option adds a `IMQ' target which is used to specify if and
+ to which imq device packets should get enqueued/dequeued.
+
+ If you want to compile it as a module, say M here and read
+ <file:Documentation/modules.txt>. If unsure, say `N'.
+
MARK target support
CONFIG_IP_NF_TARGET_MARK
This option adds a `MARK' target, which allows you to create rules
@@ -9799,6 +9815,20 @@
say M here and read <file:Documentation/modules.txt>. The module
will be called bonding.o.
+Intermediate queueing device support
+CONFIG_IMQ
+ The imq device(s) is used as placeholder for QoS queueing disciplines.
+ Every packet entering/leaving the ip stack can be directed through
+ the imq device where it's enqueued/dequeued to the attached qdisc.
+ This allows you to treat network devices as classes and distribute
+ bandwidth among them. Iptables is used to specify through which imq
+ device, if any, packets travel.
+
+ If you want to compile this as a module ( = code which ca be
+ inserted in and removed from the running kernel whenever you want),
+ say M here and read <file:Documentation/modules.txt>. The module
+ will be called imq.o
+
SLIP (serial line) support
CONFIG_SLIP
Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to
diff -aurN linux-2.4.28-orig/drivers/net/Config.in
linux-2.4.28/drivers/net/Config.in
--- linux-2.4.28-orig/drivers/net/Config.in 2004-08-07 23:26:04.000000000
+0000
+++ linux-2.4.28/drivers/net/Config.in 2004-12-14 11:43:42.000000000 +0000
@@ -7,6 +7,11 @@
tristate 'Dummy net driver support' CONFIG_DUMMY
tristate 'Bonding driver support' CONFIG_BONDING
tristate 'EQL (serial line load balancing) support' CONFIG_EQUALIZER
+if [ "$CONFIG_NETFILTER" = "y" ]; then
+ tristate 'IMQ (intermediate queueing device) support' CONFIG_IMQ
+else
+ comment 'IMQ needs CONFIG_NETFILTER enabled'
+fi
tristate 'Universal TUN/TAP device driver support' CONFIG_TUN
if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
tristate 'Ethertap network tap (OBSOLETE)' CONFIG_ETHERTAP
diff -aurN linux-2.4.28-orig/drivers/net/Makefile
linux-2.4.28/drivers/net/Makefile
--- linux-2.4.28-orig/drivers/net/Makefile 2004-08-07 23:26:04.000000000
+0000
+++ linux-2.4.28/drivers/net/Makefile 2004-12-14 11:43:42.000000000 +0000
@@ -170,6 +170,7 @@
obj-$(CONFIG_STRIP) += strip.o
obj-$(CONFIG_DUMMY) += dummy.o
+obj-$(CONFIG_IMQ) += imq.o
obj-$(CONFIG_DE600) += de600.o
obj-$(CONFIG_DE620) += de620.o
obj-$(CONFIG_AT1500) += lance.o
diff -aurN linux-2.4.28-orig/drivers/net/imq.c linux-2.4.28/drivers/net/imq.c
--- linux-2.4.28-orig/drivers/net/imq.c 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.4.28/drivers/net/imq.c 2004-12-14 11:43:42.000000000 +0000
@@ -0,0 +1,321 @@
+/*
+ * Pseudo-driver for the intermediate queue device.
+ *
+ * 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.
+ *
+ * Authors: Patrick McHardy, <[email protected]>
+ *
+ * The first version was written by Martin Devera, <[email protected]>
+ *
+ * Credits: Jan Rafaj <[email protected]>
+ * - Update patch to 2.4.21
+ * Sebastian Strollo <[email protected]>
+ * - Fix "Dead-loop on netdevice imq"-issue
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
+#include <linux/if_arp.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter_ipv4.h>
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+#include <linux/netfilter_ipv6.h>
+#endif
+#include <linux/imq.h>
+#include <net/pkt_sched.h>
+
+static nf_hookfn imq_nf_hook;
+
+static struct nf_hook_ops imq_ingress_ipv4 = {
+ { NULL, NULL},
+ imq_nf_hook,
+ PF_INET,
+ NF_IP_PRE_ROUTING,
+ NF_IP_PRI_MANGLE + 1
+};
+
+static struct nf_hook_ops imq_egress_ipv4 = {
+ { NULL, NULL},
+ imq_nf_hook,
+ PF_INET,
+ NF_IP_POST_ROUTING,
+ NF_IP_PRI_LAST
+};
+
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+static struct nf_hook_ops imq_ingress_ipv6 = {
+ { NULL, NULL},
+ imq_nf_hook,
+ PF_INET6,
+ NF_IP6_PRE_ROUTING,
+ NF_IP6_PRI_MANGLE + 1
+};
+
+static struct nf_hook_ops imq_egress_ipv6 = {
+ { NULL, NULL},
+ imq_nf_hook,
+ PF_INET6,
+ NF_IP6_POST_ROUTING,
+ NF_IP6_PRI_LAST
+};
+#endif
+
+static unsigned int numdevs = 2;
+
+MODULE_PARM(numdevs, "i");
+MODULE_PARM_DESC(numdevs, "number of imq devices");
+
+static struct net_device *imq_devs;
+
+
+static struct net_device_stats *imq_get_stats(struct net_device *dev)
+{
+ return (struct net_device_stats *)dev->priv;
+}
+
+/* called for packets kfree'd in qdiscs at places other than enqueue */
+static void imq_skb_destructor(struct sk_buff *skb)
+{
+ struct nf_info *info = skb->nf_info;
+
+ if (info) {
+ if (info->indev)
+ dev_put(info->indev);
+ if (info->outdev)
+ dev_put(info->outdev);
+ kfree(info);
+ }
+}
+
+static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
+
+ stats->tx_bytes += skb->len;
+ stats->tx_packets++;
+
+ skb->imq_flags = 0;
+ skb->destructor = NULL;
+
+ dev->trans_start = jiffies;
+ nf_reinject(skb, skb->nf_info, NF_ACCEPT);
+ return 0;
+}
+
+static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info,
+ void *data)
+{
+ struct net_device *dev;
+ struct net_device_stats *stats;
+ struct sk_buff *skb2 = NULL;
+ struct Qdisc *q;
+ unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
+ int ret = -1;
+
+ if (index > numdevs)
+ return -1;
+
+ dev = imq_devs + index;
+ if (!(dev->flags & IFF_UP)) {
+ skb->imq_flags = 0;
+ nf_reinject(skb, info, NF_ACCEPT);
+ return 0;
+ }
+ dev->last_rx = jiffies;
+
+ if (skb->destructor) {
+ skb2 = skb;
+ skb = skb_clone(skb, GFP_ATOMIC);
+ if (!skb)
+ return -1;
+ }
+ skb->nf_info = info;
+
+ stats = (struct net_device_stats *)dev->priv;
+ stats->rx_bytes+= skb->len;
+ stats->rx_packets++;
+
+ spin_lock_bh(&dev->queue_lock);
+ q = dev->qdisc;
+ if (q->enqueue) {
+ q->enqueue(skb_get(skb), q);
+ if (skb_shared(skb)) {
+ skb->destructor = imq_skb_destructor;
+ kfree_skb(skb);
+ ret = 0;
+ }
+ }
+ if (spin_is_locked(&dev->xmit_lock))
+ netif_schedule(dev);
+ else
+ qdisc_run(dev);
+ spin_unlock_bh(&dev->queue_lock);
+
+ if (skb2)
+ kfree_skb(ret ? skb : skb2);
+
+ return ret;
+}
+
+static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb,
+ const struct net_device *indev,
+ const struct net_device *outdev,
+ int (*okfn)(struct sk_buff *))
+{
+ if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
+ return NF_QUEUE;
+
+ return NF_ACCEPT;
+}
+
+
+static int __init imq_init_hooks(void)
+{
+ int err;
+
+ if ((err = nf_register_queue_handler(PF_INET, imq_nf_queue, NULL)))
+ goto err1;
+ if ((err = nf_register_hook(&imq_ingress_ipv4)))
+ goto err2;
+ if ((err = nf_register_hook(&imq_egress_ipv4)))
+ goto err3;
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+ if ((err = nf_register_queue_handler(PF_INET6, imq_nf_queue, NULL)))
+ goto err4;
+ if ((err = nf_register_hook(&imq_ingress_ipv6)))
+ goto err5;
+ if ((err = nf_register_hook(&imq_egress_ipv6)))
+ goto err6;
+#endif
+
+ return 0;
+
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+err6:
+ nf_unregister_hook(&imq_ingress_ipv6);
+err5:
+ nf_unregister_queue_handler(PF_INET6);
+err4:
+ nf_unregister_hook(&imq_egress_ipv4);
+#endif
+err3:
+ nf_unregister_hook(&imq_ingress_ipv4);
+err2:
+ nf_unregister_queue_handler(PF_INET);
+err1:
+ return err;
+}
+
+static void __exit imq_unhook(void)
+{
+ nf_unregister_hook(&imq_ingress_ipv4);
+ nf_unregister_hook(&imq_egress_ipv4);
+ nf_unregister_queue_handler(PF_INET);
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+ nf_unregister_hook(&imq_ingress_ipv6);
+ nf_unregister_hook(&imq_egress_ipv6);
+ nf_unregister_queue_handler(PF_INET6);
+#endif
+}
+
+static int __init imq_dev_init(struct net_device *dev)
+{
+ dev->hard_start_xmit = imq_dev_xmit;
+ dev->type = ARPHRD_VOID;
+ dev->mtu = 1500;
+ dev->tx_queue_len = 30;
+ dev->flags = IFF_NOARP;
+ dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
+ if (dev->priv == NULL)
+ return -ENOMEM;
+ memset(dev->priv, 0, sizeof(struct net_device_stats));
+ dev->get_stats = imq_get_stats;
+
+ return 0;
+}
+
+static void imq_dev_uninit(struct net_device *dev)
+{
+ kfree(dev->priv);
+}
+
+static int __init imq_init_devs(void)
+{
+ struct net_device *dev;
+ int i;
+
+ if (!numdevs || numdevs > IMQ_MAX_DEVS) {
+ printk(KERN_ERR "numdevs has to be betweed 1 and %u\n",
+ IMQ_MAX_DEVS);
+ return -EINVAL;
+ }
+
+ imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
+ if (!imq_devs)
+ return -ENOMEM;
+ memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
+
+ /* we start counting at zero */
+ numdevs--;
+
+ for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
+ SET_MODULE_OWNER(dev);
+ strcpy(dev->name, "imq%d");
+ dev->init = imq_dev_init;
+ dev->uninit = imq_dev_uninit;
+
+ if (register_netdev(dev) < 0)
+ goto err_register;
+ }
+ return 0;
+
+err_register:
+ for (; i; i--)
+ unregister_netdev(--dev);
+ kfree(imq_devs);
+ return -EIO;
+}
+
+static void imq_cleanup_devs(void)
+{
+ int i;
+ struct net_device *dev = imq_devs;
+
+ for (i = 0; i <= numdevs; i++)
+ unregister_netdev(dev++);
+
+ kfree(imq_devs);
+}
+
+static int __init imq_init_module(void)
+{
+ int err;
+
+ if ((err = imq_init_devs()))
+ return err;
+ if ((err = imq_init_hooks())) {
+ imq_cleanup_devs();
+ return err;
+ }
+
+ printk(KERN_INFO "imq driver loaded.\n");
+
+ return 0;
+}
+
+static void __exit imq_cleanup_module(void)
+{
+ imq_unhook();
+ imq_cleanup_devs();
+}
+
+module_init(imq_init_module);
+module_exit(imq_cleanup_module);
+MODULE_LICENSE("GPL");
diff -aurN linux-2.4.28-orig/include/linux/imq.h
linux-2.4.28/include/linux/imq.h
--- linux-2.4.28-orig/include/linux/imq.h 1970-01-01 00:00:00.000000000
+0000
+++ linux-2.4.28/include/linux/imq.h 2004-12-14 11:43:42.000000000 +0000
@@ -0,0 +1,9 @@
+#ifndef _IMQ_H
+#define _IMQ_H
+
+#define IMQ_MAX_DEVS 16
+
+#define IMQ_F_IFMASK 0x7f
+#define IMQ_F_ENQUEUE 0x80
+
+#endif /* _IMQ_H */
diff -aurN linux-2.4.28-orig/include/linux/netfilter_ipv4/ipt_IMQ.h
linux-2.4.28/include/linux/netfilter_ipv4/ipt_IMQ.h
--- linux-2.4.28-orig/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01
00:00:00.000000000 +0000
+++ linux-2.4.28/include/linux/netfilter_ipv4/ipt_IMQ.h 2004-12-14
11:43:42.000000000 +0000
@@ -0,0 +1,8 @@
+#ifndef _IPT_IMQ_H
+#define _IPT_IMQ_H
+
+struct ipt_imq_info {
+ unsigned int todev; /* target imq device */
+};
+
+#endif /* _IPT_IMQ_H */
diff -aurN linux-2.4.28-orig/include/linux/netfilter_ipv6/ip6t_IMQ.h
linux-2.4.28/include/linux/netfilter_ipv6/ip6t_IMQ.h
--- linux-2.4.28-orig/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01
00:00:00.000000000 +0000
+++ linux-2.4.28/include/linux/netfilter_ipv6/ip6t_IMQ.h 2004-12-14
11:43:42.000000000 +0000
@@ -0,0 +1,8 @@
+#ifndef _IP6T_IMQ_H
+#define _IP6T_IMQ_H
+
+struct ip6t_imq_info {
+ unsigned int todev; /* target imq device */
+};
+
+#endif /* _IP6T_IMQ_H */
diff -aurN linux-2.4.28-orig/include/linux/skbuff.h
linux-2.4.28/include/linux/skbuff.h
--- linux-2.4.28-orig/include/linux/skbuff.h 2004-08-07 23:26:06.000000000
+0000
+++ linux-2.4.28/include/linux/skbuff.h 2004-12-14 11:43:42.000000000 +0000
@@ -93,6 +93,9 @@
struct nf_conntrack *master;
};
#endif
+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
+struct nf_info;
+#endif
struct sk_buff_head {
/* These two members must be first. */
@@ -182,7 +185,7 @@
unsigned int len; /* Length of actual data
*/
unsigned int data_len;
unsigned int csum; /* Checksum
*/
- unsigned char __unused, /* Dead field, may be reused
*/
+ unsigned char imq_flags, /* intermediate queueing device
*/
cloned, /* head may be cloned (check
refcnt to be sure). */
pkt_type, /* Packet class
*/
ip_summed; /* Driver fed us an IP checksum
*/
@@ -219,6 +222,9 @@
#ifdef CONFIG_NET_SCHED
__u32 tc_index; /* traffic control index */
#endif
+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
+ struct nf_info *nf_info;
+#endif
};
#ifdef __KERNEL__
diff -aurN linux-2.4.28-orig/net/core/skbuff.c linux-2.4.28/net/core/skbuff.c
--- linux-2.4.28-orig/net/core/skbuff.c 2003-08-25 11:44:44.000000000 +0000
+++ linux-2.4.28/net/core/skbuff.c 2004-12-14 11:43:42.000000000 +0000
@@ -202,6 +202,10 @@
/* Set up other state */
skb->len = 0;
skb->cloned = 0;
+#if defined(CONFIG_IMQ) || defined (CONFIG_IMQ_MODULE)
+ skb->imq_flags = 0;
+ skb->nf_info = NULL;
+#endif
skb->data_len = 0;
atomic_set(&skb->users, 1);
@@ -250,6 +254,10 @@
#ifdef CONFIG_NET_SCHED
skb->tc_index = 0;
#endif
+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
+ skb->imq_flags = 0;
+ skb->nf_info = NULL;
+#endif
}
static void skb_drop_fraglist(struct sk_buff *skb)
@@ -400,6 +408,10 @@
#ifdef CONFIG_NET_SCHED
C(tc_index);
#endif
+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
+ C(imq_flags);
+ C(nf_info);
+#endif
atomic_inc(&(skb_shinfo(skb)->dataref));
skb->cloned = 1;
@@ -444,6 +456,10 @@
#ifdef CONFIG_NET_SCHED
new->tc_index = old->tc_index;
#endif
+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
+ new->imq_flags=old->imq_flags;
+ new->nf_info=old->nf_info;
+#endif
}
/**
diff -aurN linux-2.4.28-orig/net/ipv4/netfilter/Config.in
linux-2.4.28/net/ipv4/netfilter/Config.in
--- linux-2.4.28-orig/net/ipv4/netfilter/Config.in 2003-08-25
11:44:44.000000000 +0000
+++ linux-2.4.28/net/ipv4/netfilter/Config.in 2004-12-14 11:43:43.000000000
+0000
@@ -104,6 +104,7 @@
dep_tristate ' DSCP target support' CONFIG_IP_NF_TARGET_DSCP
$CONFIG_IP_NF_MANGLE
dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK
$CONFIG_IP_NF_MANGLE
+ dep_tristate ' IMQ target support' CONFIG_IP_NF_TARGET_IMQ
$CONFIG_IP_NF_MANGLE
dep_tristate ' CLASSIFY target support (EXPERIMENTAL)'
CONFIG_IP_NF_TARGET_CLASSIFY $CONFIG_IP_NF_MANGLE
fi
dep_tristate ' LOG target support' CONFIG_IP_NF_TARGET_LOG
$CONFIG_IP_NF_IPTABLES
diff -aurN linux-2.4.28-orig/net/ipv4/netfilter/Makefile
linux-2.4.28/net/ipv4/netfilter/Makefile
--- linux-2.4.28-orig/net/ipv4/netfilter/Makefile 2003-08-25
11:44:44.000000000 +0000
+++ linux-2.4.28/net/ipv4/netfilter/Makefile 2004-12-14 11:43:43.000000000
+0000
@@ -94,6 +94,7 @@
obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o
+obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
diff -aurN linux-2.4.28-orig/net/ipv4/netfilter/ipt_IMQ.c
linux-2.4.28/net/ipv4/netfilter/ipt_IMQ.c
--- linux-2.4.28-orig/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01
00:00:00.000000000 +0000
+++ linux-2.4.28/net/ipv4/netfilter/ipt_IMQ.c 2004-12-14 11:43:43.000000000
+0000
@@ -0,0 +1,78 @@
+/* This target marks packets to be enqueued to an imq device */
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_IMQ.h>
+#include <linux/imq.h>
+
+static unsigned int imq_target(struct sk_buff **pskb,
+ unsigned int hooknum,
+ const struct net_device *in,
+ const struct net_device *out,
+ const void *targinfo,
+ void *userinfo)
+{
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
+
+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
+ (*pskb)->nfcache |= NFC_ALTERED;
+
+ return IPT_CONTINUE;
+}
+
+static int imq_checkentry(const char *tablename,
+ const struct ipt_entry *e,
+ void *targinfo,
+ unsigned int targinfosize,
+ unsigned int hook_mask)
+{
+ struct ipt_imq_info *mr;
+
+ if (targinfosize != IPT_ALIGN(sizeof(struct ipt_imq_info))) {
+ printk(KERN_WARNING "IMQ: invalid targinfosize\n");
+ return 0;
+ }
+ mr = (struct ipt_imq_info*)targinfo;
+
+ if (strcmp(tablename, "mangle") != 0) {
+ printk(KERN_WARNING
+ "IMQ: IMQ can only be called from \"mangle\" table, not
\"%s\"\n",
+ tablename);
+ return 0;
+ }
+
+ if (mr->todev > IMQ_MAX_DEVS) {
+ printk(KERN_WARNING
+ "IMQ: invalid device specified, highest is %u\n",
+ IMQ_MAX_DEVS);
+ return 0;
+ }
+
+ return 1;
+}
+
+static struct ipt_target ipt_imq_reg = {
+ { NULL, NULL},
+ "IMQ",
+ imq_target,
+ imq_checkentry,
+ NULL,
+ THIS_MODULE
+};
+
+static int __init init(void)
+{
+ if (ipt_register_target(&ipt_imq_reg))
+ return -EINVAL;
+
+ return 0;
+}
+
+static void __exit fini(void)
+{
+ ipt_unregister_target(&ipt_imq_reg);
+}
+
+module_init(init);
+module_exit(fini);
+MODULE_LICENSE("GPL");
diff -aurN linux-2.4.28-orig/net/ipv6/netfilter/Config.in
linux-2.4.28/net/ipv6/netfilter/Config.in
--- linux-2.4.28-orig/net/ipv6/netfilter/Config.in 2003-06-13
14:51:39.000000000 +0000
+++ linux-2.4.28/net/ipv6/netfilter/Config.in 2004-12-14 11:43:43.000000000
+0000
@@ -71,6 +71,7 @@
if [ "$CONFIG_IP6_NF_MANGLE" != "n" ]; then
# dep_tristate ' TOS target support' CONFIG_IP6_NF_TARGET_TOS
$CONFIG_IP_NF_MANGLE
dep_tristate ' MARK target support' CONFIG_IP6_NF_TARGET_MARK
$CONFIG_IP6_NF_MANGLE
+ dep_tristate ' IMQ target support' CONFIG_IP6_NF_TARGET_IMQ
$CONFIG_IP6_NF_MANGLE
fi
#dep_tristate ' LOG target support' CONFIG_IP6_NF_TARGET_LOG
$CONFIG_IP6_NF_IPTABLES
fi
diff -aurN linux-2.4.28-orig/net/ipv6/netfilter/Makefile
linux-2.4.28/net/ipv6/netfilter/Makefile
--- linux-2.4.28-orig/net/ipv6/netfilter/Makefile 2003-06-13
14:51:39.000000000 +0000
+++ linux-2.4.28/net/ipv6/netfilter/Makefile 2004-12-14 11:43:43.000000000
+0000
@@ -28,6 +28,7 @@
obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t_MARK.o
+obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o
diff -aurN linux-2.4.28-orig/net/ipv6/netfilter/ip6t_IMQ.c
linux-2.4.28/net/ipv6/netfilter/ip6t_IMQ.c
--- linux-2.4.28-orig/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01
00:00:00.000000000 +0000
+++ linux-2.4.28/net/ipv6/netfilter/ip6t_IMQ.c 2004-12-14 11:43:43.000000000
+0000
@@ -0,0 +1,78 @@
+/* This target marks packets to be enqueued to an imq device */
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/netfilter_ipv6/ip6t_IMQ.h>
+#include <linux/imq.h>
+
+static unsigned int imq_target(struct sk_buff **pskb,
+ unsigned int hooknum,
+ const struct net_device *in,
+ const struct net_device *out,
+ const void *targinfo,
+ void *userinfo)
+{
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
+
+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
+ (*pskb)->nfcache |= NFC_ALTERED;
+
+ return IP6T_CONTINUE;
+}
+
+static int imq_checkentry(const char *tablename,
+ const struct ip6t_entry *e,
+ void *targinfo,
+ unsigned int targinfosize,
+ unsigned int hook_mask)
+{
+ struct ip6t_imq_info *mr;
+
+ if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_imq_info))) {
+ printk(KERN_WARNING "IMQ: invalid targinfosize\n");
+ return 0;
+ }
+ mr = (struct ip6t_imq_info*)targinfo;
+
+ if (strcmp(tablename, "mangle") != 0) {
+ printk(KERN_WARNING
+ "IMQ: IMQ can only be called from \"mangle\" table, not
\"%s\"\n",
+ tablename);
+ return 0;
+ }
+
+ if (mr->todev > IMQ_MAX_DEVS) {
+ printk(KERN_WARNING
+ "IMQ: invalid device specified, highest is %u\n",
+ IMQ_MAX_DEVS);
+ return 0;
+ }
+
+ return 1;
+}
+
+static struct ip6t_target ip6t_imq_reg = {
+ { NULL, NULL},
+ "IMQ",
+ imq_target,
+ imq_checkentry,
+ NULL,
+ THIS_MODULE
+};
+
+static int __init init(void)
+{
+ if (ip6t_register_target(&ip6t_imq_reg))
+ return -EINVAL;
+
+ return 0;
+}
+
+static void __exit fini(void)
+{
+ ip6t_unregister_target(&ip6t_imq_reg);
+}
+
+module_init(init);
+module_exit(fini);
+MODULE_LICENSE("GPL");
diff -aurN linux-2.4.28-orig/net/sched/sch_generic.c
linux-2.4.28/net/sched/sch_generic.c
--- linux-2.4.28-orig/net/sched/sch_generic.c 2004-11-17 11:54:22.000000000
+0000
+++ linux-2.4.28/net/sched/sch_generic.c 2004-12-14 11:44:27.000000000
+0000
@@ -29,6 +29,9 @@
#include <linux/skbuff.h>
#include <linux/rtnetlink.h>
#include <linux/init.h>
+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
+#include <linux/imq.h>
+#endif
#include <linux/list.h>
#include <net/sock.h>
#include <net/pkt_sched.h>
@@ -90,7 +93,11 @@
spin_unlock(&dev->queue_lock);
if (!netif_queue_stopped(dev)) {
- if (netdev_nit)
+ if (netdev_nit
+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
+ && !(skb->imq_flags & IMQ_F_ENQUEUE)
+#endif
+ )
dev_queue_xmit_nit(skb, dev);
if (dev->hard_start_xmit(skb, dev) == 0) {
--- NEW FILE: linux-2.4.32-ipv4zones-0.1.2.patch ---
diff -Nru linux-2.4.32.orig/drivers/net/Config.in
linux-2.4.32/drivers/net/Config.in
--- linux-2.4.32.orig/drivers/net/Config.in 2006-06-07 13:47:00.000000000
+0300
+++ linux-2.4.32/drivers/net/Config.in 2006-06-27 21:29:26.000000000 +0300
@@ -328,6 +328,10 @@
if [ ! "$CONFIG_PPP" = "n" ]; then
dep_bool ' PPP multilink support (EXPERIMENTAL)' CONFIG_PPP_MULTILINK
$CONFIG_EXPERIMENTAL
dep_bool ' PPP filtering' CONFIG_PPP_FILTER $CONFIG_FILTER
+ bool ' PPP IPv4 zone counters' CONFIG_PPP_IPV4ZONES $CONFIG_PPP
+ if [ "$CONFIG_PPP_IPV4ZONES" = "y" -o "$CONFIG_PPP_IPV4ZONES" = "m" ]; then
+ int ' PPP IPv4 zones number' CONFIG_PPP_IPV4ZONES_COUNT 4
+ fi
dep_tristate ' PPP support for async serial ports' CONFIG_PPP_ASYNC
$CONFIG_PPP
dep_tristate ' PPP support for sync tty ports' CONFIG_PPP_SYNC_TTY
$CONFIG_PPP
dep_tristate ' PPP Deflate compression' CONFIG_PPP_DEFLATE $CONFIG_PPP
diff -Nru linux-2.4.32.orig/drivers/net/ppp_generic.c
linux-2.4.32/drivers/net/ppp_generic.c
--- linux-2.4.32.orig/drivers/net/ppp_generic.c 2006-06-07 13:47:00.000000000
+0300
+++ linux-2.4.32/drivers/net/ppp_generic.c 2006-06-27 23:25:09.000000000
+0300
@@ -126,6 +126,12 @@
struct sk_buff_head mrq; /* MP: receive reconstruction queue */
#endif /* CONFIG_PPP_MULTILINK */
struct net_device_stats stats; /* statistics */
+#ifdef CONFIG_PPP_IPV4ZONES
+ unsigned long tx_packets_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+ unsigned long rx_packets_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+ unsigned long tx_bytes_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+ unsigned long rx_bytes_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+#endif /* CONFIG_PPP_IPV4ZONES */
#ifdef CONFIG_PPP_FILTER
struct sock_fprog pass_filter; /* filter for packets to pass */
struct sock_fprog active_filter;/* filter for pkts to reset idle */
@@ -319,6 +325,491 @@
ETH_P_PPPTALK,
};
+#ifdef CONFIG_PPP_IPV4ZONES
+/*
+ * PPP IPv4 Zones for traffic counting
+ * Zones storing and IP lookup based on Red-Black Tree
+ */
+#ifndef LINUX_VERSION_CODE
+#include <linux/version.h>
+#endif
+#include <linux/rbtree.h>
+#include <linux/proc_fs.h>
+
+#define lib_assert_if_true(cond) if (cond) return;
+#define lib_return_if_true(cond, retval) if (cond) return (retval);
+
+#ifdef __KERNEL__
+# if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
+static inline void *kzalloc(size_t size, int flags)
+{
+ void *data;
+
+ data = kmalloc(size, flags);
+
+ if (NULL != data) {
+ memset(data, 0, size);
+ }
+
+ return data;
+}
+# endif
+# define ALLOCATE(klass) (klass*)kmalloc(sizeof(klass), GFP_KERNEL)
+# define ALLOCATE_Z(klass) (klass*)kzalloc(sizeof(klass), GFP_KERNEL)
+# define DEALLOCATE(thisObj) kfree(thisObj)
+
+# define lib_log_trace(args...) // printk(KERN_DEBUG args)
+# define lib_log_debug(args...) // printk(KERN_DEBUG args)
+# define lib_log_info(args...) printk(KERN_INFO args)
+# define lib_log_notice(args...) printk(KERN_NOTICE args)
+# define lib_log_warning(args...) printk(KERN_WARNING args)
+# define lib_log_err(args...) printk(KERN_ERR args)
+# define lib_log_crit(args...) printk(KERN_CRIT args)
+#else
+
+# define ALLOCATE(klass) (klass*)malloc(sizeof(klass))
+# define ALLOCATE_Z(klass) (klass*)calloc(1, sizeof(klass))
+# define DEALLOCATE(thisObj) free(thisObj)
+
+# define lib_log_trace(args...) printf(args)
+# define lib_log_debug(args...) printf(args)
+# define lib_log_info(args...) printf(args)
+# define lib_log_notice(args...) printf(args)
+# define lib_log_warning(args...) printf(args)
+# define lib_log_err(args...) printf(args)
+# define lib_log_crit(args...) printf(args)
+#endif
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
+# define RB_NODE_TYPE rb_node_t
+# define RB_ROOT_TYPE rb_root_t
+#else
+# define RB_NODE_TYPE struct rb_node
+# define RB_ROOT_TYPE struct rb_root
+#endif
+
+#define RB_NODE(x) ((RB_NODE_TYPE *)(x))
+
+struct ppp_ipv4zone_node {
+ /* RB-Tree node used to link this structure to the zones rb-tree */
+ RB_NODE_TYPE rbn;
+
+ struct ppp_ipv4zone zone;
+};
+
+static inline struct ppp_ipv4zone_node*
+ipv4zone_node_init(struct ppp_ipv4zone_node* node) {
+ if (NULL != node) {
+ // TODO Test if ok
+ node->rbn.rb_parent = RB_NODE(node);
+ }
+
+ return node;
+}
+
+static struct ppp_ipv4zone_node*
+ipv4zone_node_init_data(struct ppp_ipv4zone_node* thisObj, unsigned int start,
unsigned int last, int zone)
+{
+ struct ppp_ipv4zone_node* node = ipv4zone_node_init(thisObj);
+ if (NULL != node) {
+ node->zone.start = start;
+ node->zone.last = last;
+ node->zone.zone = zone;
+ }
+
+ return node;
+}
+
+static struct ppp_ipv4zone_node*
+ipv4zone_node_new_data(unsigned int start, unsigned int last, int zone)
+{
+ struct ppp_ipv4zone_node* tmp;
+ struct ppp_ipv4zone_node* thisObj = ALLOCATE_Z(struct
ppp_ipv4zone_node);
+ tmp = ipv4zone_node_init_data(thisObj, start, last, zone);
+
+ if (NULL == tmp) {
+ DEALLOCATE(thisObj);
+ thisObj = NULL;
+ }
+
+ return thisObj;
+}
+
+static inline void ipv4zone_node_finalize(struct ppp_ipv4zone_node* thisObj)
+{
+}
+
+static inline void ipv4zone_node_delete(struct ppp_ipv4zone_node* thisObj)
+{
+ ipv4zone_node_finalize(thisObj);
+ DEALLOCATE(thisObj);
+}
+
+struct ppp_ipv4zones {
+ /* Protect this structure access */
+ rwlock_t lock;
+
+ /* RB-Tree root used to store IPv4 zones */
+ RB_ROOT_TYPE rbr;
+};
+
+//static spinlock_t ppp_ipv4zones_lock;
+static struct ppp_ipv4zones* ppp_ipv4zone_tree;
+
+//#define IPV4ZONES_PROC_FILE "sys/net/ppp/ipv4zones"
+#define IPV4ZONES_PROC_FILE "ipv4zones"
+static struct proc_dir_entry *ipv4zones_proc_entry;
+
+static inline void
+ipv4zones_remove(struct ppp_ipv4zones *zones, struct ppp_ipv4zone_node *node)
+{
+ rb_erase(&node->rbn, &zones->rbr);
+ node->rbn.rb_parent = &node->rbn;
+}
+
+static inline struct ppp_ipv4zones* ipv4zones_init(struct ppp_ipv4zones*
thisObj)
+{
+ if (NULL != thisObj) {
+ rwlock_init(&thisObj->lock);
+ thisObj->rbr = RB_ROOT;
+ }
+
+ return thisObj;
+}
+
+static int ipv4zones_alloc(struct ppp_ipv4zones **pzones)
+{
+ struct ppp_ipv4zones* zones = ALLOCATE_Z(struct ppp_ipv4zones);
+
+ if (!zones)
+ return -ENOMEM;
+
+ *pzones = ipv4zones_init(zones);
+
+ if (NULL == *pzones) {
+ DEALLOCATE(zones);
+ return -EAGAIN;
+ }
+
+ lib_log_info("[%p] ipv4zones: ipv4zones_alloc() pzones=%p\n", current,
pzones);
+ return 0;
+}
+
+static struct ppp_ipv4zones* ipv4zones_new(void)
+{
+ struct ppp_ipv4zones* zones;
+
+ int result = ipv4zones_alloc(&zones);
+
+ if (0 != result) {
+ zones = NULL;
+ // TODO indicate error type
+ }
+
+ return zones;
+}
+
+static void
+ipv4zones_free(struct ppp_ipv4zones *zones)
+{
+ RB_NODE_TYPE *rbp;
+ struct ppp_ipv4zone_node *zone;
+
+ lib_assert_if_true(NULL == zones);
+
+ /*
+ * We need to lock this because we could be hit by
+ * ??? Could we? we are freeing, so we are not in use...
+ */
+ write_lock_irq(&zones->lock);
+
+ /*
+ * Walks through the whole tree by freeing each "struct
ppp_ipv4zone_node".
+ */
+ while ((rbp = rb_first(&zones->rbr)) != 0) {
+ zone = rb_entry(rbp, struct ppp_ipv4zone_node, rbn);
+ ipv4zones_remove(zones, zone);
+ ipv4zone_node_delete(zone);
+ }
+
+ write_unlock_irq(&zones->lock);
+
+ DEALLOCATE(zones);
+}
+
+/**
+ * Compare 2 ppp_ipv4zone_node objects.
+ * No checking for NULL values!!!
+ */
+static inline int
+ppp_ipv4zone_node_comparator(RB_NODE_TYPE *node1, RB_NODE_TYPE *node2)
+{
+ struct ppp_ipv4zone* zone1;
+ struct ppp_ipv4zone* zone2;
+
+ zone1 = &rb_entry(node1, struct ppp_ipv4zone_node, rbn)->zone;
+ zone2 = &rb_entry(node2, struct ppp_ipv4zone_node, rbn)->zone;
+
+ // Not checking overlapping
+ // Next line would not be working - highest bit can be set :(
+ // result = ((unsigned int)zone1->start) - ((unsigned int)zone2->start);
+ if (((unsigned int)zone1->start) < ((unsigned int)zone2->start)) {
+ return -1;
+ } else if (zone1->start != zone2->start) {
+ return 1;
+ }
+ lib_log_trace("ipv4_zone_node_comparator: zone1=0x%08x, zone2=0x%08x,
result=%d\n",
+ zone1->start, zone2->start, result);
+
+ return 0;
+}
+
+/**
+ * Check if IPv4 address is in current ppp_ipv4zone_node object.
+ * No checking for NULL values!!!
+ */
+static inline int
+ppp_ipv4zone_node_testip(struct ppp_ipv4zone_node* node, unsigned int ip)
+{
+ if (ip < node->zone.start) {
+ return -1;
+ } else if (ip > node->zone.last) {
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Search zone inside the zones tree.
+ */
+static unsigned int ppp_ipv4zone_findzone(struct ppp_ipv4zones *zones,
unsigned int ip)
+{
+ int kcmp;
+ unsigned long flags;
+ RB_NODE_TYPE *rbp;
+ struct ppp_ipv4zone_node *zone = NULL;
+ int zonen = 0;
+
+ read_lock_irqsave(&zones->lock, flags);
+ for (rbp = zones->rbr.rb_node; rbp; ) {
+ zone = rb_entry(rbp, struct ppp_ipv4zone_node, rbn);
+ kcmp = ppp_ipv4zone_node_testip(zone, ip);
+ if (kcmp > 0)
+ rbp = rbp->rb_right;
+ else if (kcmp < 0)
+ rbp = rbp->rb_left;
+ else {
+ zonen = zone->zone.zone;
+ break;
+ }
+ }
+ read_unlock_irqrestore(&zones->lock, flags);
+
+ lib_log_debug("[%p] : ppp_ipv4zone_findzone(0x%x) -> %d\n", current,
ip, zonen);
+
+ return zonen;
+}
+
+static inline unsigned int
+ppp_ipv4zone_getzone(struct ppp* sppp, struct sk_buff *skb, int tx)
+{
+ struct iphdr *iph;
+ unsigned int test_zone;
+ unsigned int ip;
+
+ // ppp_ipv4zone_tree can now be NULL
+ if (NULL == ppp_ipv4zone_tree)
+ return 0;
+
+ lib_return_if_true(NULL == sppp, 0);
+ lib_return_if_true(NULL == skb, 0);
+ // Must be IPv4. Can't check, RX change this
+ // lib_return_if_true(PPP_IP != PPP_PROTO(skb), 0);
+ // Maybe so?
+ // lib_return_if_true(PPP_IP != skb->protocol), 0);
+
+ // get addr
+ lib_log_debug("ppp_ipv4zone_getzone: tx=%d, nh.iph=%p, data=%p,
protocol=%d, ihl=%d, iph.len=%d, skb.len=%d\n",
+ tx, skb->nh.iph, skb->data, skb->protocol, (NULL == skb->nh.iph
? -1 : skb->nh.iph->ihl),
+ (NULL == skb->nh.iph ? -1 : skb->nh.iph->tot_len), skb->len);
+ iph = skb->nh.iph;
+ if (NULL == iph || 5 > iph->ihl) {
+ // if we are using kernel pppoe, some packets have not
well-formed headers
+ iph = (struct iphdr *)skb->data;
+ }
+ lib_return_if_true(NULL == iph, 0);
+
+ // TX relative to iface, so swap addr source
+ if (tx)
+ ip = ntohl(iph->saddr);
+ else
+ ip = ntohl(iph->daddr);
+
+ test_zone = ppp_ipv4zone_findzone(ppp_ipv4zone_tree, ip);
+ lib_log_trace("ppp_ipv4zone_getzone: iph=%p, tx=%d, ip="NIPQUAD_FMT",
zone=%d\n",
+ skb->nh.iph, tx, HIPQUAD(ip), test_zone);
+
+ return test_zone;
+}
+
+static void ipv4zones_insert(struct ppp_ipv4zones *zones, struct
ppp_ipv4zone_node *zone)
+{
+ int kcmp;
+ RB_NODE_TYPE **p = &zones->rbr.rb_node, *parent = NULL;
+
+ // TODO check overlapping, find out right locking method
+ write_lock_irq(&zones->lock);
+ while (*p) {
+ parent = *p;
+ kcmp = ppp_ipv4zone_node_comparator(&zone->rbn, parent);
+ if (kcmp > 0)
+ p = &parent->rb_right;
+ else
+ p = &parent->rb_left;
+ }
+ rb_link_node(&zone->rbn, parent, p);
+ rb_insert_color(&zone->rbn, &zones->rbr);
+ write_unlock_irq(&zones->lock);
+}
+
+static inline void ppp_ipv4zone_rx(struct ppp* sppp, struct sk_buff *skb) {
+ int zone;
+ zone = ppp_ipv4zone_getzone(sppp, skb, 0);
+
+ ++sppp->rx_packets_zones[zone];
+ sppp->rx_bytes_zones[zone] += skb->len - 2;
+}
+
+static inline void ppp_ipv4zone_postpull_rx(struct ppp* sppp, struct sk_buff
*skb, unsigned int len) {
+ int zone;
+ zone = ppp_ipv4zone_getzone(sppp, skb, 0);
+
+ ++sppp->rx_packets_zones[zone];
+ sppp->rx_bytes_zones[zone] += skb->len - 2 + len;
+}
+
+static inline void ppp_ipv4zone_tx(struct ppp* sppp, struct sk_buff *skb) {
+ int zone;
+ zone = ppp_ipv4zone_getzone(sppp, skb, 1);
+
+ ++sppp->tx_packets_zones[zone];
+ sppp->tx_bytes_zones[zone] += skb->len - 2;
+}
+
+/**
+ * Output textual representation of IPv4 zones tree to userspace
+ */
+int ipv4zones_proc_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len = 0;
+
+ *eof = 1;
+
+ return len;
+}
+
+ssize_t ipv4zones_proc_write(struct file *filp, const char __user *buff,
+ unsigned long len, void *data )
+{
+ struct ppp_ipv4zones_config_packet *packet;
+
+ if (IPV4ZONES_MIN_PACKET_SIZE >= len) {
+ lib_log_warning("ipv4zones: too small packet!\n");
+ return -EINVAL;
+ }
+
+ if (IPV4ZONES_MAX_PACKET_SIZE <= len) {
+ lib_log_warning("ipv4zones: too big packet!\n");
+ return -EFBIG;
+ }
+
+ packet = kmalloc(len, GFP_KERNEL);
+ if (NULL == packet) {
+ lib_log_err("ipv4zones: can't allocate space for packet!\n");
+ len = -ENOMEM;
+ goto out;
+ }
+
+ if (copy_from_user(packet, buff, len)) {
+ lib_log_err("ipv4zones: can't copy packet from userspace!\n");
+ len = -EFAULT;
+ goto out_packet;
+ }
+
+ if (IPV4ZONES_VERSION != packet->version) {
+ lib_log_err("ipv4zones: packet verion mismatch!\n");
+ len = -EINVAL;
+ goto out_packet;
+ }
+
+ switch (packet->type_magic) {
+ case IPV4ZONES_TYPE_TREE:
+ {
+ unsigned int i;
+ struct ppp_ipv4zones *zones, *orig;
+ struct ppp_ipv4zones_config_packet_tree *cp = (struct
ppp_ipv4zones_config_packet_tree *)packet;
+ if (0 == cp->count ||
+ sizeof(struct ppp_ipv4zone) !=
+ (len - sizeof(struct
ppp_ipv4zones_config_packet) - sizeof(size_t)) / (cp->count)) {
+ lib_log_err("ipv4zones: invalid packet size or
zone count!\n");
+ len = -EINVAL;
+ goto out_packet;
+ }
+
+ // Allocate new tree root
+ zones = ipv4zones_new();
+ if (NULL == zones) {
+ lib_log_err("ipv4zones: can't allocate space
for zones!\n");
+ len = -ENOMEM;
+ goto out_packet;
+ } else {
+ for (i = 0; i < cp->count; i++) {
+ struct ppp_ipv4zone_node *node =
ipv4zone_node_new_data(cp->zones[i].start, cp->zones[i].last,
cp->zones[i].zone);
+ if (NULL == node) {
+ lib_log_err("ipv4zones: can't
allocate space for zone node!\n");
+ goto tree_err;
+ }
+
+ ipv4zones_insert(zones, node);
+ }
+
+ // Swap current IPv4 zones tree root with new
+ // spin_lock(&ppp_ipv4zones_lock);
+ orig = ppp_ipv4zone_tree;
+ ppp_ipv4zone_tree = zones;
+ // spin_unlock(&ppp_ipv4zones_lock);
+
+ // Free old IPv4 zones tree root
+ if (NULL != orig) {
+ ipv4zones_free(orig);
+ }
+ }
+
+ break;
+tree_err:
+ ipv4zones_free(zones);
+ len = -ENOMEM;
+ goto out_packet;
+ }
+ default:
+ lib_log_err("ipv4zones: unknown packet type!\n");
+ len = -EINVAL;
+ goto out_packet;
+ }
+
+out_packet:
+ if (NULL != packet) {
+ kfree(packet);
+ }
+
+out:
+ return len;
+}
+#endif /* CONFIG_PPP_IPV4ZONES */
+
+
/*
* Locking shorthand.
*/
@@ -796,6 +1247,24 @@
S_IFCHR | S_IRUSR | S_IWUSR,
&ppp_device_fops, NULL);
+#ifdef CONFIG_PPP_IPV4ZONES
+ ppp_ipv4zone_tree = NULL;
+
+ ipv4zones_proc_entry = create_proc_entry(IPV4ZONES_PROC_FILE, S_IFREG,
&proc_root);
+ if (NULL == ipv4zones_proc_entry) {
+ lib_log_err("ipv4zones: can't create proc entry!\n");
+ if (devfs_unregister_chrdev(PPP_MAJOR, "ppp") != 0)
+ lib_log_err("ipv4zones: PPP: failed to unregister PPP
device\n");
+ devfs_unregister(devfs_handle);
+ return -ENOMEM;
+ } else {
+ ipv4zones_proc_entry->read_proc = ipv4zones_proc_read;
+ ipv4zones_proc_entry->write_proc = ipv4zones_proc_write;
+ ipv4zones_proc_entry->owner = THIS_MODULE;
+ }
+ lib_log_notice("ipv4zones: version 0.%d loaded\n", IPV4ZONES_VERSION);
+#endif /* CONFIG_PPP_IPV4ZONES */
+
return 0;
}
@@ -992,6 +1459,10 @@
switch (proto) {
case PPP_IP:
+#ifdef CONFIG_PPP_IPV4ZONES
+ ppp_ipv4zone_tx(ppp, skb);
+#endif /* CONFIG_PPP_IPV4ZONES */
+
if (ppp->vj == 0 || (ppp->flags & SC_COMP_TCP) == 0)
break;
/* try to do VJ TCP header compression */
@@ -1559,6 +2030,10 @@
skb->dev = ppp->dev;
skb->protocol = htons(npindex_to_ethertype[npi]);
skb->mac.raw = skb->data;
+#ifdef CONFIG_PPP_IPV4ZONES
+ if (NP_IP == npi) // NP_IP == ETH_P_IP
+ ppp_ipv4zone_postpull_rx(ppp, skb, 2);
+#endif /* CONFIG_PPP_IPV4ZONES */
netif_rx(skb);
ppp->dev->last_rx = jiffies;
}
@@ -2250,6 +2725,13 @@
st->p.ppp_opackets = ppp->stats.tx_packets;
st->p.ppp_oerrors = ppp->stats.tx_errors;
st->p.ppp_obytes = ppp->stats.tx_bytes;
+#ifdef CONFIG_PPP_IPV4ZONES
+// printk("copying CONFIG_PPP_IPV4ZONES data\n");
+ memcpy(st->p.ppp_opackets_zones, &ppp->tx_packets_zones,
sizeof(ppp->tx_packets_zones));
+ memcpy(st->p.ppp_ipackets_zones, &ppp->rx_packets_zones,
sizeof(ppp->rx_packets_zones));
+ memcpy(st->p.ppp_obytes_zones, &ppp->tx_bytes_zones,
sizeof(ppp->tx_bytes_zones));
+ memcpy(st->p.ppp_ibytes_zones, &ppp->rx_bytes_zones,
sizeof(ppp->tx_bytes_zones));
+#endif /* CONFIG_PPP_IPV4ZONES */
if (vj == 0)
return;
st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed;
@@ -2552,6 +3034,13 @@
static void __exit ppp_cleanup(void)
{
+#ifdef CONFIG_PPP_IPV4ZONES
+ remove_proc_entry(IPV4ZONES_PROC_FILE, &proc_root);
+ // spin_lock(&ppp_ipv4zones_lock);
+ ipv4zones_free(ppp_ipv4zone_tree);
+ // spin_unlock(&ppp_ipv4zones_lock);
+#endif /* CONFIG_PPP_IPV4ZONES */
+
/* should never happen */
if (atomic_read(&ppp_unit_count) || atomic_read(&channel_count))
printk(KERN_ERR "PPP: removing module but units remain!\n");
diff -Nru linux-2.4.32.orig/include/linux/ppp_defs.h
linux-2.4.32/include/linux/ppp_defs.h
--- linux-2.4.32.orig/include/linux/ppp_defs.h 2006-06-07 13:30:41.000000000
+0300
+++ linux-2.4.32/include/linux/ppp_defs.h 2006-06-27 22:33:39.000000000
+0300
@@ -127,6 +127,12 @@
__u32 ppp_opackets; /* packets sent */
__u32 ppp_oerrors; /* transmit errors */
__u32 ppp_olqrs; /* # LQR frames sent */
+#ifdef CONFIG_PPP_IPV4ZONES
+ __u32 ppp_opackets_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+ __u32 ppp_ipackets_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+ __u32 ppp_obytes_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+ __u32 ppp_ibytes_zones[CONFIG_PPP_IPV4ZONES_COUNT];
+#endif /* CONFIG_PPP_IPV4ZONES */
};
struct vjstat {
@@ -174,6 +180,35 @@
time_t recv_idle; /* time since last NP packet received */
};
+#ifdef CONFIG_PPP_IPV4ZONES
+struct ppp_ipv4zones_config_packet {
+ u32 version;
+ u32 type_magic;
+};
+
+#define IPV4ZONES_VERSION 0x01
+
+#define IPV4ZONES_TYPE_TREE 0x54F948AC
+
+#define IPV4ZONES_MIN_PACKET_SIZE (sizeof(struct ppp_ipv4zones_config_packet))
+#define IPV4ZONES_MAX_PACKET_SIZE 2048
+
+struct ppp_ipv4zone {
+ unsigned int start; // range start
+ unsigned int last; // range last
+ unsigned int zone; // zone number
+};
+
+/**
+ * Full tree
+ */
+struct ppp_ipv4zones_config_packet_tree {
+ struct ppp_ipv4zones_config_packet header;
+ size_t count;
+ struct ppp_ipv4zone zones[0];
+};
+#endif /* CONFIG_PPP_IPV4ZONES */
+
#ifndef __P
#ifdef __STDC__
#define __P(x) x
--- NEW FILE: sk98lin_v10.61.3.3_2.4.34.patch ---
diff -ruN linux/drivers/net/sk98lin/build_no.c
linux-new/drivers/net/sk98lin/build_no.c
--- linux/drivers/net/sk98lin/build_no.c 2007-07-22 16:50:47.000000000
+0300
+++ linux-new/drivers/net/sk98lin/build_no.c 1970-01-01 03:00:00.000000000
+0300
@@ -1,10 +0,0 @@
-/******************************************************************************
- *
- * Name: Build_No.c
- * Version: 1.01
- *
- */
-
-static const char SysKonnectBuildNumber[] =
- "@(#)SK-BUILD: 6.02 (20021219) PL: ALL.01";
-^Z
\ РконÑе Ñайла Ð½ÐµÑ Ð½Ð¾Ð²Ð¾Ð¹ ÑÑÑоки
diff -ruN linux/drivers/net/sk98lin/h/lm80.h
linux-new/drivers/net/sk98lin/h/lm80.h
--- linux/drivers/net/sk98lin/h/lm80.h 2007-07-22 16:50:47.000000000 +0300
+++ linux-new/drivers/net/sk98lin/h/lm80.h 2008-07-07 13:07:25.000000000
+0300
@@ -1,177 +1,180 @@
[...82203 lines suppressed...]
- - SK-9861 V2.0 Gigabit Ethernet 1000Base-SX Adapter
- - SK-9862 Gigabit Ethernet Server Adapter (SK-NET GE-SX Volition
dual link)
- - SK-9871 Gigabit Ethernet Server Adapter (SK-NET GE-ZX)
- - SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter
- - SK-9872 Gigabit Ethernet Server Adapter (SK-NET GE-ZX dual link)
- - SMC EZ Card 1000 (SMC9452TXV.2)
+ compliant Gigabit Ethernet Adapter.
The adapters support Jumbo Frames.
The dual link adapters support link-failover and dual port features.
@@ -12347,6 +12292,9 @@
say M here and read Documentation/modules.txt. This is recommended.
The module will be called sk98lin.o.
+CONFIG_SK98LIN_NAPI
+ NAPI is a new driver API designed to reduce CPU and interrupt load
+ when the driver is receiving lots of packets from the card.
Sun GEM support
CONFIG_SUNGEM
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
leaf-cvs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits