Makefile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. #
  2. # Copyright (C) 2006-2016 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/kernel.mk
  9. PKG_NAME:=iptables
  10. PKG_VERSION:=1.6.1
  11. PKG_RELEASE:=1
  12. PKG_SOURCE_PROTO:=git
  13. PKG_SOURCE_URL:=https://git.netfilter.org/iptables
  14. PKG_SOURCE_VERSION:=7df66f1c13563cfbab75246b009ce36f69ee4487
  15. PKG_MIRROR_HASH:=22f15ef41fd8e3724bedcee666b7b6a3491d2d038d580ef1fb032718dcb73f14
  16. PKG_FIXUP:=autoreconf
  17. PKG_INSTALL:=1
  18. PKG_BUILD_PARALLEL:=1
  19. PKG_LICENSE:=GPL-2.0
  20. include $(INCLUDE_DIR)/package.mk
  21. ifeq ($(DUMP),)
  22. -include $(LINUX_DIR)/.config
  23. include $(INCLUDE_DIR)/netfilter.mk
  24. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | mkhash md5)
  25. endif
  26. define Package/iptables/Default
  27. SECTION:=net
  28. CATEGORY:=Network
  29. SUBMENU:=Firewall
  30. URL:=http://netfilter.org/
  31. endef
  32. define Package/iptables/Module
  33. $(call Package/iptables/Default)
  34. DEPENDS:=iptables $(1)
  35. endef
  36. define Package/iptables
  37. $(call Package/iptables/Default)
  38. TITLE:=IP firewall administration tool
  39. MENU:=1
  40. DEPENDS+= +kmod-ipt-core +libip4tc +IPV6:libip6tc +libxtables
  41. endef
  42. define Package/iptables/config
  43. config IPTABLES_CONNLABEL
  44. bool "Enable Connlabel support"
  45. default n
  46. help
  47. This enable connlabel support in iptables.
  48. config IPTABLES_NFTABLES
  49. bool "Enable Nftables support"
  50. default n
  51. help
  52. This enable nftables support in iptables.
  53. endef
  54. define Package/iptables/description
  55. IP firewall administration tool.
  56. Matches:
  57. - icmp
  58. - tcp
  59. - udp
  60. - comment
  61. - conntrack
  62. - limit
  63. - mac
  64. - mark
  65. - multiport
  66. - set
  67. - state
  68. - time
  69. Targets:
  70. - ACCEPT
  71. - CT
  72. - DNAT
  73. - DROP
  74. - REJECT
  75. - LOG
  76. - MARK
  77. - MASQUERADE
  78. - REDIRECT
  79. - SET
  80. - SNAT
  81. - TCPMSS
  82. Tables:
  83. - filter
  84. - mangle
  85. - nat
  86. - raw
  87. endef
  88. define Package/iptables-mod-conntrack-extra
  89. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  90. TITLE:=Extra connection tracking extensions
  91. endef
  92. define Package/iptables-mod-conntrack-extra/description
  93. Extra iptables extensions for connection tracking.
  94. Matches:
  95. - connbytes
  96. - connlimit
  97. - connmark
  98. - recent
  99. - helper
  100. Targets:
  101. - CONNMARK
  102. endef
  103. define Package/iptables-mod-filter
  104. $(call Package/iptables/Module, +kmod-ipt-filter)
  105. TITLE:=Content inspection extensions
  106. endef
  107. define Package/iptables-mod-filter/description
  108. iptables extensions for packet content inspection.
  109. Includes support for:
  110. Matches:
  111. - string
  112. endef
  113. define Package/iptables-mod-ipopt
  114. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  115. TITLE:=IP/Packet option extensions
  116. endef
  117. define Package/iptables-mod-ipopt/description
  118. iptables extensions for matching/changing IP packet options.
  119. Matches:
  120. - dscp
  121. - ecn
  122. - length
  123. - statistic
  124. - tcpmss
  125. - unclean
  126. - hl
  127. Targets:
  128. - DSCP
  129. - CLASSIFY
  130. - ECN
  131. - HL
  132. endef
  133. define Package/iptables-mod-ipsec
  134. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  135. TITLE:=IPsec extensions
  136. endef
  137. define Package/iptables-mod-ipsec/description
  138. iptables extensions for matching ipsec traffic.
  139. Matches:
  140. - ah
  141. - esp
  142. - policy
  143. endef
  144. define Package/iptables-mod-nat-extra
  145. $(call Package/iptables/Module, +kmod-ipt-nat-extra)
  146. TITLE:=Extra NAT extensions
  147. endef
  148. define Package/iptables-mod-nat-extra/description
  149. iptables extensions for extra NAT targets.
  150. Targets:
  151. - MIRROR
  152. - NETMAP
  153. endef
  154. define Package/iptables-mod-ulog
  155. $(call Package/iptables/Module, +kmod-ipt-ulog)
  156. TITLE:=user-space packet logging
  157. endef
  158. define Package/iptables-mod-ulog/description
  159. iptables extensions for user-space packet logging.
  160. Targets:
  161. - ULOG
  162. endef
  163. define Package/iptables-mod-nflog
  164. $(call Package/iptables/Module, +kmod-nfnetlink-log +kmod-ipt-nflog)
  165. TITLE:=Netfilter NFLOG target
  166. endef
  167. define Package/iptables-mod-nflog/description
  168. iptables extension for user-space logging via NFNETLINK.
  169. Includes:
  170. - libxt_NFLOG
  171. endef
  172. define Package/iptables-mod-nfqueue
  173. $(call Package/iptables/Module, +kmod-nfnetlink-queue +kmod-ipt-nfqueue)
  174. TITLE:=Netfilter NFQUEUE target
  175. endef
  176. define Package/iptables-mod-nfqueue/description
  177. iptables extension for user-space queuing via NFNETLINK.
  178. Includes:
  179. - libxt_NFQUEUE
  180. endef
  181. define Package/iptables-mod-hashlimit
  182. $(call Package/iptables/Module, +kmod-ipt-hashlimit)
  183. TITLE:=hashlimit matching
  184. endef
  185. define Package/iptables-mod-hashlimit/description
  186. iptables extensions for hashlimit matching
  187. Matches:
  188. - hashlimit
  189. endef
  190. define Package/iptables-mod-rpfilter
  191. $(call Package/iptables/Module, +kmod-ipt-rpfilter)
  192. TITLE:=rpfilter iptables extension
  193. endef
  194. define Package/iptables-mod-rpfilter/description
  195. iptables extensions for reverse path filter test on a packet
  196. Matches:
  197. - rpfilter
  198. endef
  199. define Package/iptables-mod-iprange
  200. $(call Package/iptables/Module, +kmod-ipt-iprange)
  201. TITLE:=IP range extension
  202. endef
  203. define Package/iptables-mod-iprange/description
  204. iptables extensions for matching ip ranges.
  205. Matches:
  206. - iprange
  207. endef
  208. define Package/iptables-mod-cluster
  209. $(call Package/iptables/Module, +kmod-ipt-cluster)
  210. TITLE:=Match cluster extension
  211. endef
  212. define Package/iptables-mod-cluster/description
  213. iptables extensions for matching cluster.
  214. Netfilter (IPv4/IPv6) module for matching cluster
  215. This option allows you to build work-load-sharing clusters of
  216. network servers/stateful firewalls without having a dedicated
  217. load-balancing router/server/switch. Basically, this match returns
  218. true when the packet must be handled by this cluster node. Thus,
  219. all nodes see all packets and this match decides which node handles
  220. what packets. The work-load sharing algorithm is based on source
  221. address hashing.
  222. This module is usable for ipv4 and ipv6.
  223. If you select it, it enables kmod-ipt-cluster.
  224. see `iptables -m cluster --help` for more information.
  225. endef
  226. define Package/iptables-mod-clusterip
  227. $(call Package/iptables/Module, +kmod-ipt-clusterip)
  228. TITLE:=Clusterip extension
  229. endef
  230. define Package/iptables-mod-clusterip/description
  231. iptables extensions for CLUSTERIP.
  232. The CLUSTERIP target allows you to build load-balancing clusters of
  233. network servers without having a dedicated load-balancing
  234. router/server/switch.
  235. If you select it, it enables kmod-ipt-clusterip.
  236. see `iptables -j CLUSTERIP --help` for more information.
  237. endef
  238. define Package/iptables-mod-extra
  239. $(call Package/iptables/Module, +kmod-ipt-extra)
  240. TITLE:=Other extra iptables extensions
  241. endef
  242. define Package/iptables-mod-extra/description
  243. Other extra iptables extensions.
  244. Matches:
  245. - addrtype
  246. - condition
  247. - owner
  248. - physdev (if ebtables is enabled)
  249. - pkttype
  250. - quota
  251. endef
  252. define Package/iptables-mod-led
  253. $(call Package/iptables/Module, +kmod-ipt-led)
  254. TITLE:=LED trigger iptables extension
  255. endef
  256. define Package/iptables-mod-led/description
  257. iptables extension for triggering a LED.
  258. Targets:
  259. - LED
  260. endef
  261. define Package/iptables-mod-tproxy
  262. $(call Package/iptables/Module, +kmod-ipt-tproxy)
  263. TITLE:=Transparent proxy iptables extensions
  264. endef
  265. define Package/iptables-mod-tproxy/description
  266. Transparent proxy iptables extensions.
  267. Matches:
  268. - socket
  269. Targets:
  270. - TPROXY
  271. endef
  272. define Package/iptables-mod-tee
  273. $(call Package/iptables/Module, +kmod-ipt-tee)
  274. TITLE:=TEE iptables extensions
  275. endef
  276. define Package/iptables-mod-tee/description
  277. TEE iptables extensions.
  278. Targets:
  279. - TEE
  280. endef
  281. define Package/iptables-mod-u32
  282. $(call Package/iptables/Module, +kmod-ipt-u32)
  283. TITLE:=U32 iptables extensions
  284. endef
  285. define Package/iptables-mod-u32/description
  286. U32 iptables extensions.
  287. Matches:
  288. - u32
  289. endef
  290. define Package/ip6tables
  291. $(call Package/iptables/Default)
  292. DEPENDS:=@IPV6 +kmod-ip6tables +iptables
  293. CATEGORY:=Network
  294. TITLE:=IPv6 firewall administration tool
  295. MENU:=1
  296. endef
  297. define Package/ip6tables-extra
  298. $(call Package/iptables/Default)
  299. DEPENDS:=ip6tables +kmod-ip6tables-extra
  300. TITLE:=IPv6 header matching modules
  301. endef
  302. define Package/ip6tables-mod-extra/description
  303. iptables header matching modules for IPv6
  304. endef
  305. define Package/ip6tables-mod-nat
  306. $(call Package/iptables/Default)
  307. DEPENDS:=ip6tables +kmod-ipt-nat6
  308. TITLE:=IPv6 NAT extensions
  309. endef
  310. define Package/ip6tables-mod-nat/description
  311. iptables extensions for IPv6-NAT targets.
  312. endef
  313. define Package/libiptc
  314. $(call Package/iptables/Default)
  315. SECTION:=libs
  316. CATEGORY:=Libraries
  317. DEPENDS:=+libip4tc +libip6tc +libxtables
  318. ABI_VERSION:=$(PKG_VERSION)
  319. TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
  320. endef
  321. define Package/libip4tc
  322. $(call Package/iptables/Default)
  323. SECTION:=libs
  324. CATEGORY:=Libraries
  325. TITLE:=IPv4 firewall - shared libiptc library
  326. ABI_VERSION:=$(PKG_VERSION)
  327. DEPENDS:=+libxtables
  328. endef
  329. define Package/libip6tc
  330. $(call Package/iptables/Default)
  331. SECTION:=libs
  332. CATEGORY:=Libraries
  333. TITLE:=IPv6 firewall - shared libiptc library
  334. ABI_VERSION:=$(PKG_VERSION)
  335. DEPENDS:=+libxtables
  336. endef
  337. define Package/libxtables
  338. $(call Package/iptables/Default)
  339. SECTION:=libs
  340. CATEGORY:=Libraries
  341. TITLE:=IPv4/IPv6 firewall - shared xtables library
  342. ABI_VERSION:=$(PKG_VERSION)
  343. DEPENDS:= \
  344. +IPTABLES_CONNLABEL:libnetfilter-conntrack \
  345. +IPTABLES_NFTABLES:libnftnl
  346. endef
  347. TARGET_CPPFLAGS := \
  348. -I$(PKG_BUILD_DIR)/include \
  349. -I$(LINUX_DIR)/user_headers/include \
  350. $(TARGET_CPPFLAGS)
  351. TARGET_CFLAGS += \
  352. -I$(PKG_BUILD_DIR)/include \
  353. -I$(LINUX_DIR)/user_headers/include \
  354. -ffunction-sections -fdata-sections \
  355. -DNO_LEGACY
  356. TARGET_LDFLAGS += \
  357. -Wl,--gc-sections
  358. CONFIGURE_ARGS += \
  359. --enable-shared \
  360. --enable-static \
  361. --enable-devel \
  362. --with-kernel="$(LINUX_DIR)/user_headers" \
  363. --with-xtlibdir=/usr/lib/iptables \
  364. $(if $(CONFIG_IPTABLES_CONNLABEL),,--disable-connlabel) \
  365. $(if $(CONFIG_IPTABLES_NFTABLES),,--disable-nftables) \
  366. $(if $(CONFIG_IPV6),,--disable-ipv6)
  367. MAKE_FLAGS := \
  368. $(TARGET_CONFIGURE_OPTS) \
  369. COPT_FLAGS="$(TARGET_CFLAGS)" \
  370. KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
  371. KBUILD_OUTPUT="$(LINUX_DIR)" \
  372. BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
  373. ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
  374. define Build/Configure/rebuild
  375. $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.\?o -or -name \*.a | $(XARGS) rm -f
  376. rm -f $(PKG_BUILD_DIR)/.config_*
  377. rm -f $(PKG_BUILD_DIR)/.configured_*
  378. touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
  379. endef
  380. endif
  381. define Build/Configure
  382. $(Build/Configure/rebuild)
  383. $(Build/Configure/Default)
  384. endef
  385. define Build/InstallDev
  386. $(INSTALL_DIR) $(1)/usr/include
  387. $(INSTALL_DIR) $(1)/usr/include/iptables
  388. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  389. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  390. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  391. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  392. $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
  393. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  394. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  395. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  396. $(INSTALL_DIR) $(1)/usr/lib
  397. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  398. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  399. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  400. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  401. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libip*tc.pc $(1)/usr/lib/pkgconfig/
  402. # XXX: needed by firewall3
  403. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext*.so $(1)/usr/lib/
  404. endef
  405. define Package/iptables/install
  406. $(INSTALL_DIR) $(1)/usr/sbin
  407. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
  408. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
  409. $(INSTALL_DIR) $(1)/usr/lib/iptables
  410. endef
  411. define Package/ip6tables/install
  412. $(INSTALL_DIR) $(1)/usr/sbin
  413. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
  414. endef
  415. define Package/libiptc/install
  416. $(INSTALL_DIR) $(1)/usr/lib
  417. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  418. endef
  419. define Package/libip4tc/install
  420. $(INSTALL_DIR) $(1)/usr/lib
  421. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
  422. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext4.so $(1)/usr/lib/
  423. endef
  424. define Package/libip6tc/install
  425. $(INSTALL_DIR) $(1)/usr/lib
  426. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
  427. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext6.so $(1)/usr/lib/
  428. endef
  429. define Package/libxtables/install
  430. $(INSTALL_DIR) $(1)/usr/lib
  431. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  432. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext.so $(1)/usr/lib/
  433. endef
  434. define BuildPlugin
  435. define Package/$(1)/install
  436. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  437. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
  438. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  439. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  440. fi; \
  441. done
  442. $(3)
  443. endef
  444. $$(eval $$(call BuildPackage,$(1)))
  445. endef
  446. $(eval $(call BuildPackage,iptables))
  447. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  448. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  449. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m)))
  450. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  451. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  452. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  453. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  454. $(eval $(call BuildPlugin,iptables-mod-cluster,$(IPT_CLUSTER-m)))
  455. $(eval $(call BuildPlugin,iptables-mod-clusterip,$(IPT_CLUSTERIP-m)))
  456. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  457. $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
  458. $(eval $(call BuildPlugin,iptables-mod-rpfilter,$(IPT_RPFILTER-m)))
  459. $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
  460. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  461. $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
  462. $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
  463. $(eval $(call BuildPlugin,iptables-mod-nflog,$(IPT_NFLOG-m)))
  464. $(eval $(call BuildPlugin,iptables-mod-nfqueue,$(IPT_NFQUEUE-m)))
  465. $(eval $(call BuildPackage,ip6tables))
  466. $(eval $(call BuildPlugin,ip6tables-extra,$(IPT_IPV6_EXTRA-m)))
  467. $(eval $(call BuildPlugin,ip6tables-mod-nat,$(IPT_NAT6-m)))
  468. $(eval $(call BuildPackage,libiptc))
  469. $(eval $(call BuildPackage,libip4tc))
  470. $(eval $(call BuildPackage,libip6tc))
  471. $(eval $(call BuildPackage,libxtables))