Hi,
I am practising writing my own queue handler instead of using ip_queue like this:
#include<linux/module.h>
#include<linux/netfilter_ipv4.h>
#include<linux/netdevice.h>
#include<linux/ip.h>
#include<linux/delay.h>
#include<linux/kthread.h>
static int usercontrol(struct sk_buff*, struct nf_info*, unsigned int , void* );
static struct nf_queue_handler myqhandler= {
.name = "USERCONTROL",
.outfn = &usercontrol,
};
static int __init first(void)
{
int ret;
ret = nf_register_queue_handler(PF_INET, &myqhandler);
if(ret < 0)
{
printk(KERN_INFO "\n~~~Could not register queue handler~~~\n");
return 0;
}
printk(KERN_INFO "\n~~~Registering the module~~~~\n");
return 0;
}
static void __exit sec(void)
{
nf_unregister_queue_handlers(&myqhandler);
}
static int usercontrol(struct sk_buff *skb, struct nf_info *info, unsigned int queuenum, void *data)
{
printk(KERN_INFO "Queue handler called");
nf_reinject(skb, 0, NF_QUEUE);
return 1;
}
module_init(first);
module_exit(sec);
MODULE_LICENSE("GPL");
Now, for testing i did this:
first i gave command iptables -A INPUT -j QUEUE and then pinged localhost .. No reply came because queue handler was not there... and then i flushed the rule using iptables -F
then after making this module, i insmoded this module. then i gave iptables -A INPUT -j QUEUE command. But Kernel suddenly hanged. this is happeningg everytime i try this.
What could be the problem? plz suggest if you know.