- 论坛徽章:
- 0
|
看了http://bbs.chinaunix.net/thread-1940183-1-1.html帖子后,试验NF_ARP_FORWARD,我的理解这是挂载到bridge的FORWARD上,所以我建立了一个br0,包含eth0和eth1,然后写了自己的模块但是没有抓到任何数据包(bridge肯定已经forward了arp数据包),请问这是为什么呢?- #include <linux/version.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/netfilter.h>
- #include <linux/netfilter_bridge.h>
- #include <linux/netfilter_arp.h>
- static unsigned int myarp_callback(
- unsigned int hooknum,
- struct sk_buff *skb,
- const struct net_device *in,
- const struct net_device *out,
- int (*okfn)(struct sk_buff *))
- {
- printk("Recv ARP forward packet\n");
- return NF_ACCEPT;
- }
- static struct nf_hook_ops my_arphook[] = {
- {
- .hook = myarp_callback,
- .owner = THIS_MODULE,
- .pf = NF_ARP,
- .hooknum = NF_ARP_FORWARD,
- .priority = NF_BR_PRI_FIRST,
- }
- };
- static int __init arptest_init(void)
- {
- int ret = 0;
- ret = nf_register_hooks(my_arphook, ARRAY_SIZE(my_arphook));
- if (ret < 0)
- {
- printk("can't register hooks.\n");
- return -1;
- }
- printk("insmod myarp success\n");
- return 0;
- }
- static void __exit arptest_exit(void)
- {
- nf_unregister_hooks(my_arphook, ARRAY_SIZE(my_arphook));
- printk("rmmod myarp success\n");
- return;
- }
- module_init(arptest_init);
- module_exit(arptest_exit);
复制代码 |
|