免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5961 | 回复: 5
打印 上一主题 下一主题

[求助]make[1]:没有规则可以创建目标"netfilter" [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-23 17:27 |只看该作者 |倒序浏览
大家好 还是同样的问题 我随便找个和netfilter相关的例程编译都会出现这个错误,像这里面的例程http://bbs.chinaunix.net/thread-2177913-1-1.html
就算是例程中有错误 还是报的这个错误。也注意到了hook接口的问题。
我的内核版本是 2.6.35-29-generic netfilter相关的模块也已经按模块编译了
在lib/modules/2.6.35-29-generic/kernel/net/ipv4/netfilter 也能找到很多.ko文件
同时 我原先有个aodv的程序 也要用到netfilter 也能够顺利编译并运行 。
但是现在是只要单独写的关于netfilter的小内核程序 就会有问题。不知道为什么。请大家帮忙 不胜感激!
我用的一个例程
  1. /* Sample code to install a Netfilter hook function that will
  2. * drop all incoming packets. */
  3. #define __KERNEL__
  4. #define MODULE
  5. #include <linux/module.h>
  6. #include <linux/kernel.h>
  7. #include <linux/netfilter.h>
  8. #include <linux/netfilter_ipv4.h>

  9. /* This is the structure we shall use to register our function */

  10. static struct nf_hook_ops nfho;

  11. /* This is the hook function itself */

  12. unsigned int hook_func(unsigned int hooknum,
  13. struct sk_buff **skb,
  14. const struct net_device *in,
  15. const struct net_device *out,
  16. int (*okfn)(struct sk_buff *))
  17. {

  18. return NF_DROP;           /* Drop ALL packets */
  19. }

  20. /* Initialisation routine */
  21. int init_module()
  22. {

  23. /* Fill in our hook structure */
  24. nfho.hook = hook_func;         /* Handler function */
  25. nfho.hooknum  = NF_IP_PRE_ROUTING; /* First hook for IPv4 */
  26. nfho.pf       = PF_INET;
  27. nfho.priority = NF_IP_PRI_FIRST;   /* Make our function first */
  28. nf_register_hook(&nfho);
  29. return 0;
  30. }

  31. /* Cleanup routine */
  32. void cleanup_module()
  33. {
  34. nf_unregister_hook(&nfho);
  35. }
复制代码
Makefite
  1. obj-m:=test.o
  2. KERNELDIR:=/lib/modules/`uname -r`/build
  3. PWD:=$(shell pwd)

  4. modules:
  5.         $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
  6. module_install:
  7.         $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

  8. clean:
  9.         make -C $(KERNELDIR) M=$(PWD) clean

  10. remove:
  11.         /sbin/rmmod dropAll
复制代码
求解答 忙乎很多了。。。。

论坛徽章:
1
午马
日期:2013-09-10 11:03:08
2 [报告]
发表于 2011-11-25 10:03 |只看该作者
Makefile 写错了

论坛徽章:
0
3 [报告]
发表于 2011-11-25 15:22 |只看该作者
回复 2# xbjpkpk


    那应该怎么写呢? 请告诉我 我已经纠结好几天了

论坛徽章:
1
午马
日期:2013-09-10 11:03:08
4 [报告]
发表于 2011-11-28 15:20 |只看该作者
回复 3# star5689


    也不能说你的makefile错了, 你直接输入命令 make modules 试下嘞, 就是觉得你的makefile写的怪怪的

论坛徽章:
1
技术图书徽章
日期:2013-11-12 10:33:00
5 [报告]
发表于 2011-11-28 16:20 |只看该作者
什么错误?
还是你的代码不全,一个模块没有声明入口和出口,缺少module_init和module_exit

论坛徽章:
0
6 [报告]
发表于 2011-12-02 11:41 |只看该作者
没看到报什么错误啊,把错误截屏贴出来
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP