Makefile 15 KB

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