|
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter.h>
#include <linux/kernel.h>
#include <linux/netfilter_ipv4.h>
MODULE_LICENSE("Dual BSD/GPL");
static struct nf_hook_ops nfho;
unsigned int hook_func(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
printk("*********************** hook_func()\n");
return NF_DROP;
}
int my_init_module(void)
{
nfho.hook = hook_func;
nfho.hooknum = NF_IP_PRE_ROUTING;
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
printk("********************** my_init_module()\n");
nf_register_hook(&nfho);
return 0;
}
void my_cleanup_module(void)
{
printk("********************* my_cleanup_module()\n");
nf_unregister_hook(&nfho);
}
module_init(my_init_module);
module_exit(my_cleanup_module);
我把代码编译成ko,然后insmod,接着在message里面输出了两条信息后,系统就一点反应也没有了,只能重启,有谁能告诉我是为什么吗? |
|