Commit 328b9c35 authored by David Johnson's avatar David Johnson

Bugs.

parent 248a7e4a
--- drivers/net/imq.c.orig 2009-02-03 11:55:57.000000000 -0700
+++ drivers/net/imq.c 2009-04-23 17:23:22.000000000 -0600
@@ -64,68 +64,274 @@
+++ drivers/net/imq.c 2009-04-24 17:24:49.000000000 -0600
@@ -64,68 +64,281 @@
#endif
#include <linux/imq.h>
#include <net/pkt_sched.h>
......@@ -209,7 +209,7 @@
+ cur = get_exec_env();
+
+ /* find this device */
+ for (i = 0; i < numdevs; ++i) {
+ for (i = 0; i <= numdevs; ++i) {
+ if ((imq_devs + i)->ifindex == dev->ifindex) {
+ offset = i;
+ break;
......@@ -236,7 +236,7 @@
+ return 0;
+ }
+
+ for (i = 0; i < numdevs; ++i) {
+ for (i = 0; i <= numdevs; ++i) {
+ ind = (hook_map + i)->dev;
+ if (ind->owner_env->veid == cur->veid
+ && ind->ifindex != dev->ifindex) {
......@@ -250,6 +250,7 @@
+ printk(KERN_ERR "IMQ: no kmem when registering nf hooks for %s!\n",
+ dev->name);
+ imq_init_hooks(hs,0);
+ (hook_map + offset)->hook_set = hs;
+ printk(KERN_INFO "IMQ: init_hooks for %s in %d\n",
+ dev->name,cur->veid);
+ }
......@@ -273,7 +274,7 @@
+ return 0;
+ }
+
+ for (i = 0; i < numdevs; ++i) {
+ for (i = 0; i <= numdevs; ++i) {
+ ind = (hook_map + i)->dev;
+ if (ind->owner_env->veid == cur->veid
+ && ind->ifindex != dev->ifindex) {
......@@ -283,13 +284,10 @@
+ }
+ if (!found) {
+ /* unregister: */
+ imq_unhook(hs,0);
+ free_hook_set(&hs);
+ (hook_map + offset)->hook_set = NULL;
+ }
+ else {
+ (hook_map + offset)->hook_set = NULL;
+ imq_unhook((hook_map + offset)->hook_set,0);
+ free_hook_set(&((hook_map + offset)->hook_set));
+ }
+ (hook_map + offset)->hook_set = NULL;
+ }
+
+ return 0;
......@@ -299,9 +297,18 @@
+ * Check if the imq device with this number is really in this VE.
+ */
+int imq_dev_in_ve(unsigned todev) {
+ if (todev >= IMQ_MAX_DEVS)
+ if (todev > numdevs)
+ return 0;
+
+ if (imq_devs + todev == NULL)
+ printk(KERN_ERR "IMQ: imq_devs+todev NULL!\n");
+
+ if ((imq_devs + todev)->owner_env == NULL)
+ printk(KERN_ERR "IMQ: (imq_devs+todev)->owner_env NULL!\n");
+
+ if (get_exec_env() == NULL)
+ printk(KERN_ERR "IMQ: get_exec_env() NULL!\n");
+
+ if ((imq_devs + todev)->owner_env->veid == get_exec_env()->veid)
+ return 1;
+
......@@ -312,7 +319,7 @@
static struct net_device_stats *imq_get_stats(struct net_device *dev)
{
@@ -143,6 +349,12 @@
@@ -143,6 +356,12 @@
if (info->outdev)
dev_put(info->outdev);
kfree(info);
......@@ -325,7 +332,7 @@
}
}
@@ -150,6 +362,11 @@
@@ -150,6 +369,11 @@
{
struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
......@@ -337,7 +344,7 @@
stats->tx_bytes += skb->len;
stats->tx_packets++;
@@ -170,11 +387,19 @@
@@ -170,11 +394,19 @@
unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
int ret = -1;
......@@ -358,7 +365,7 @@
skb->imq_flags = 0;
nf_reinject(skb, info, NF_ACCEPT);
return 0;
@@ -184,9 +409,13 @@
@@ -184,9 +416,13 @@
if (skb->destructor) {
skb2 = skb;
skb = skb_clone(skb, GFP_ATOMIC);
......@@ -373,7 +380,7 @@
skb->nf_info = info;
stats = (struct net_device_stats *)dev->priv;
@@ -216,6 +445,10 @@
@@ -216,6 +452,10 @@
if (skb2)
kfree_skb(ret ? skb : skb2);
......@@ -384,7 +391,7 @@
return ret;
}
@@ -229,30 +462,53 @@
@@ -229,30 +469,53 @@
const struct net_device *outdev,
int (*okfn)(struct sk_buff *))
{
......@@ -445,7 +452,7 @@
goto err6;
#endif
@@ -260,29 +516,37 @@
@@ -260,29 +523,37 @@
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
err6:
......@@ -491,7 +498,7 @@
nf_unregister_queue_handler(PF_INET);
}
@@ -310,6 +574,9 @@
@@ -310,6 +581,9 @@
static int __init imq_init_devs(void)
{
struct net_device *dev;
......@@ -501,7 +508,7 @@
int i,j;
j = numdevs;
@@ -324,24 +591,60 @@
@@ -324,24 +598,60 @@
return -ENOMEM;
memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
......@@ -563,7 +570,7 @@
kfree(imq_devs);
return -EIO;
}
@@ -354,6 +657,11 @@
@@ -354,6 +664,11 @@
for (i = 0; i <= numdevs; i++)
unregister_netdev(dev++);
......@@ -575,23 +582,27 @@
kfree(imq_devs);
}
@@ -365,8 +673,14 @@
@@ -361,12 +676,18 @@
{
int err;
+ if (build_hook_set(&root_hook_set)) {
+ printk(KERN_ERR "IMQ: Error trying to build root hook set\n");
+ return -ENOMEM;
+ }
if ((err = imq_init_devs())) {
printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n");
+ free_hook_set(&root_hook_set);
return err;
}
- if ((err = imq_init_hooks())) {
+ if (build_hook_set(&root_hook_set)) {
+ printk(KERN_ERR "IMQ: Error trying to build root hook set\n");
+ imq_cleanup_devs();
+ return err;
+ }
+ if ((err = imq_init_hooks(root_hook_set,1))) {
printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
+ free_hook_set(&root_hook_set);
imq_cleanup_devs();
return err;
}
@@ -389,7 +703,8 @@
@@ -389,7 +710,8 @@
static void __exit imq_cleanup_module(void)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment