就着上次的帖子,想尝试使用arptables抵挡arp广播风暴引起的linux软中断,奈何个人水平太差,修改Makefile后,进行交叉编译一直报错,实在找不到原因。所以想请教各位大佬将arptables移植到嵌入式linux上的方法。
下面是本人修改的Makefile和交叉编译报错信息: 1. Makefile - ARPTABLES_VERSION:=0.0.3-3
- KERNEL_DIR:=/home/yaofeng/linux/kernel_src # 原来为KERNEL_DIR:=./
- CC=arm-linux-gnueabihf-gcc # 原来没有这项,使用系统默认gcc
- PREFIX:=/home/yaofeng/linux/nfs/share_smba/tool/arptables/install # 根据对该Makefile的理解,这个应该是输出文件的存放路径,故自定义了,便于移植的时候查找
- LIBDIR:=$(PREFIX)/lib
- BINDIR:=$(PREFIX)/sbin
- MANDIR:=$(PREFIX)/man
- INITDIR:=/etc/rc.d/init.d
- SYSCONFIGDIR:=/etc/sysconfig
- DESTDIR:=
- COPT_FLAGS:=-O2
- CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include/ -Iinclude/ -DARPTABLES_VERSION="$(ARPTABLES_VERSION)" #-g -DDEBUG #-pg # -DARPTC_DEBUG
- ifndef ARPT_LIBDIR
- ARPT_LIBDIR:=$(LIBDIR)/arptables
- endif
- include extensions/Makefile
- all: arptables
- arptables.o: arptables.c
- $(CC) $(CFLAGS) -c -o $[url=home.php?mod=space&uid=95564]@[/url] [ DISCUZ_CODE_0 ]lt;
- arptables-standalone.o: arptables-standalone.c
- [url=home.php?mod=space&uid=3970]@ECHO[/url] "EXT_OBJS = $(EXT_OBJS)"
- $(CC) $(CFLAGS) -c -o $@ [ DISCUZ_CODE_0 ]lt;
- libarptc/libarptc.o: libarptc/libarptc.c libarptc/libarptc_incl.c
- $(CC) $(CFLAGS) -c -o $@ [ DISCUZ_CODE_0 ]lt;
- arptables: arptables-standalone.o arptables.o libarptc/libarptc.o $(EXT_OBJS)
- $(CC) $(CFLAGS) -o $@ $^
- $(DESTDIR)$(MANDIR)/man8/arptables.8: arptables.8
- mkdir -p $(@D)
- install -m 0644 -o root -g root [ DISCUZ_CODE_0 ]lt; $@
- $(DESTDIR)$(BINDIR)/arptables: arptables
- mkdir -p $(DESTDIR)$(BINDIR)
- install -m 0755 -o root -g root [ DISCUZ_CODE_0 ]lt; $@
- tmp1:=$(shell printf $(BINDIR) | sed 's/\//\\\//g')
- tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g')
- .PHONY: scripts
- scripts: arptables-save arptables-restore arptables.sysv
- cat arptables-save | sed 's/__EXEC_PATH__/$(tmp1)/g' > arptables-save_
- install -m 0755 -o root -g root arptables-save_ $(DESTDIR)$(BINDIR)/arptables-save
- cat arptables-restore | sed 's/__EXEC_PATH__/$(tmp1)/g' > arptables-restore_
- install -m 0755 -o root -g root arptables-restore_ $(DESTDIR)$(BINDIR)/arptables-restore
- cat arptables.sysv | sed 's/__EXEC_PATH__/$(tmp1)/g' | sed 's/__SYSCONFIG__/$(tmp2)/g' > arptables.sysv_
- install -m 0755 -o root -g root arptables.sysv_ $(DESTDIR)$(INITDIR)/arptables
- rm -f arptables-save_ arptables-restore_ arptables.sysv_
- .PHONY: install
- install: $(DESTDIR)$(MANDIR)/man8/arptables.8 $(DESTDIR)$(BINDIR)/arptables scripts
- .PHONY: clean
- clean:
- rm -f arptables
- rm -f *.o *~
- rm -f extensions/*.o extensions/*~
- rm -f libarptc/*.o libarptc/*~
- rm -f include/*~ include/libarptc/*~
- DIR:=arptables-v$(ARPTABLES_VERSION)
- CVSDIRS:=CVS extensions/CVS libarptc/CVS include/CVS include/libarptc/CVS
- # This is used to make a new userspace release
- .PHONY: release
- release:
- rm -rf $(CVSDIRS)
- mkdir -p include/linux/netfilter_arp
- install -m 0644 -o root -g root \
- $(KERNEL_DIR)/include/linux/netfilter_arp.h include/linux/
- install -m 0644 -o root -g root \
- $(KERNEL_DIR)/include/linux/netfilter_arp/*.h \
- include/linux/netfilter_arp/
- install -m 0644 -o root -g root \
- include/arp_tables.h include/linux/netfilter_arp/arp_tables.h
- make clean
- cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz
复制代码
2. 报错信息 然后进行交叉编译,在Makefile存在的路径下执行make,会报如下错误: arm-linux-gnueabihf-gcc -O2 -Wall -Wunused -I/home/yaofeng/linux/kernel_src/include/ -Iinclude/ -DARPTABLES_VERSION=\"0.0.3-3\" -c -o arptables-standalone.o arptables-standalone.c
In file included from /home/yaofeng/linux/kernel_src/include/linux/kernel.h:6:0,
from /home/yaofeng/linux/kernel_src/include/linux/skbuff.h:17,
from /home/yaofeng/linux/kernel_src/include/linux/if_ether.h:23,
from /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/netinet/if_ether.h:25,
from /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/netinet/ether.h:25,
from include/libarptc/arpt_kernel_headers.h:14,
from include/libarptc/libarptc.h:5,
from include/arptables.h:5,
from arptables-standalone.c:38:
/home/yaofeng/linux/kernel_src/include/linux/linkage.h:7:25: 致命错误: asm/linkage.h:没有那个文件或目录
#include <asm/linkage.h>
^
编译中断。
Makefile:29: recipe for target 'arptables-standalone.o' failed
make: *** [arptables-standalone.o] Error 1
|