blob: cd2f3bce0be9816739a32613321ca4e2b1c1c183 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001SUMMARY = "Tools for managing kernel packet filtering capabilities"
2DESCRIPTION = "iptables is the userspace command line program used to configure and control network packet \
3filtering code in Linux."
4HOMEPAGE = "http://www.netfilter.org/"
5BUGTRACKER = "http://bugzilla.netfilter.org/"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00006LICENSE = "GPL-2.0-or-later"
Andrew Geissler82c905d2020-04-13 13:39:40 -05007LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
8 file://iptables/iptables.c;beginline=13;endline=25;md5=c5cffd09974558cf27d0f763df2a12dc \
9"
10
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050011SRC_URI = "http://netfilter.org/projects/iptables/files/iptables-${PV}.tar.xz \
Andrew Geissler82c905d2020-04-13 13:39:40 -050012 file://iptables.service \
13 file://iptables.rules \
14 file://ip6tables.service \
15 file://ip6tables.rules \
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050016 file://0001-configure-Add-option-to-enable-disable-libnfnetlink.patch \
17 file://0002-iptables-xshared.h-add-missing-sys.types.h-include.patch \
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050018 file://0004-configure.ac-only-check-conntrack-when-libnfnetlink-.patch \
Andrew Geissler6ce62a22020-11-30 19:58:47 -060019 "
Patrick Williamsda295312023-12-05 16:48:56 -060020SRC_URI[sha256sum] = "5cc255c189356e317d070755ce9371eb63a1b783c34498fb8c30264f3cc59c9c"
Andrew Geissler82c905d2020-04-13 13:39:40 -050021
Patrick Williams213cb262021-08-07 19:21:33 -050022SYSTEMD_SERVICE:${PN} = "\
Andrew Geissler82c905d2020-04-13 13:39:40 -050023 iptables.service \
24 ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'ip6tables.service', '', d)} \
25"
26
27inherit autotools pkgconfig systemd
28
29EXTRA_OECONF = "--with-kernel=${STAGING_INCDIR}"
30
Andrew Geisslerd5838332022-05-27 11:33:10 -050031CFLAGS:append:libc-musl = " -D__UAPI_DEF_ETHHDR=0"
32
Andrew Geissler82c905d2020-04-13 13:39:40 -050033PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
34PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
35
36# libnfnetlink recipe is in meta-networking layer
37PACKAGECONFIG[libnfnetlink] = "--enable-libnfnetlink,--disable-libnfnetlink,libnfnetlink libnetfilter-conntrack"
38
39# libnftnl recipe is in meta-networking layer(previously known as libnftables)
40PACKAGECONFIG[libnftnl] = "--enable-nftables,--disable-nftables,libnftnl"
41
Patrick Williams213cb262021-08-07 19:21:33 -050042do_configure:prepend() {
Andrew Geissler82c905d2020-04-13 13:39:40 -050043 # Remove some libtool m4 files
44 # Keep ax_check_linker_flags.m4 which belongs to autoconf-archive.
45 rm -f libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4
Andrew Geisslerd5838332022-05-27 11:33:10 -050046
47 # Copy a header to fix out of tree builds
48 cp -f ${S}/libiptc/linux_list.h ${S}/include/libiptc/
Andrew Geissler82c905d2020-04-13 13:39:40 -050049}
50
51IPTABLES_RULES_DIR ?= "${sysconfdir}/${BPN}"
52
Patrick Williams213cb262021-08-07 19:21:33 -050053do_install:append() {
Andrew Geissler82c905d2020-04-13 13:39:40 -050054 install -d ${D}${IPTABLES_RULES_DIR}
55 install -m 0644 ${WORKDIR}/iptables.rules ${D}${IPTABLES_RULES_DIR}
56
57 install -d ${D}${systemd_system_unitdir}
58 install -m 0644 ${WORKDIR}/iptables.service ${D}${systemd_system_unitdir}
59
60 sed -i \
61 -e 's,@SBINDIR@,${sbindir},g' \
62 -e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \
63 ${D}${systemd_system_unitdir}/iptables.service
64
65 if ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'true', 'false', d)} ; then
66 install -m 0644 ${WORKDIR}/ip6tables.rules ${D}${IPTABLES_RULES_DIR}
67 install -m 0644 ${WORKDIR}/ip6tables.service ${D}${systemd_system_unitdir}
68
69 sed -i \
70 -e 's,@SBINDIR@,${sbindir},g' \
71 -e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \
72 ${D}${systemd_system_unitdir}/ip6tables.service
73 fi
Andrew Geissler9aee5002022-03-30 16:27:02 +000074
75 # if libnftnl is included, make the iptables symlink point to the nft-based binary by default
76 if ${@bb.utils.contains('PACKAGECONFIG', 'libnftnl', 'true', 'false', d)} ; then
77 ln -sf ${sbindir}/xtables-nft-multi ${D}${sbindir}/iptables
78 fi
Andrew Geissler82c905d2020-04-13 13:39:40 -050079}
80
Andrew Geisslerd25ed322020-06-27 00:28:28 -050081PACKAGES =+ "${PN}-modules ${PN}-apply"
Andrew Geissler82c905d2020-04-13 13:39:40 -050082PACKAGES_DYNAMIC += "^${PN}-module-.*"
83
Patrick Williams213cb262021-08-07 19:21:33 -050084python populate_packages:prepend() {
Andrew Geissler82c905d2020-04-13 13:39:40 -050085 modules = do_split_packages(d, '${libdir}/xtables', r'lib(.*)\.so$', '${PN}-module-%s', '${PN} module %s', extra_depends='')
86 if modules:
87 metapkg = d.getVar('PN') + '-modules'
Patrick Williams213cb262021-08-07 19:21:33 -050088 d.appendVar('RDEPENDS:' + metapkg, ' ' + ' '.join(modules))
Andrew Geissler82c905d2020-04-13 13:39:40 -050089}
90
Patrick Williams213cb262021-08-07 19:21:33 -050091RDEPENDS:${PN} = "${PN}-module-xt-standard"
92RRECOMMENDS:${PN} = " \
Andrew Geissler82c905d2020-04-13 13:39:40 -050093 ${PN}-modules \
94 kernel-module-x-tables \
95 kernel-module-ip-tables \
96 kernel-module-iptable-filter \
97 kernel-module-iptable-nat \
98 kernel-module-nf-defrag-ipv4 \
99 kernel-module-nf-conntrack \
100 kernel-module-nf-conntrack-ipv4 \
101 kernel-module-nf-nat \
102 kernel-module-ipt-masquerade \
103 ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', '\
104 kernel-module-ip6table-filter \
105 kernel-module-ip6-tables \
106 ', '', d)} \
107"
108
Patrick Williams213cb262021-08-07 19:21:33 -0500109FILES:${PN} += "${datadir}/xtables"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500110
Patrick Williams213cb262021-08-07 19:21:33 -0500111FILES:${PN}-apply = "${sbindir}/ip*-apply"
112RDEPENDS:${PN}-apply = "${PN} bash"
Andrew Geisslerd25ed322020-06-27 00:28:28 -0500113
Andrew Geissler82c905d2020-04-13 13:39:40 -0500114# Include the symlinks as well in respective packages
Patrick Williams213cb262021-08-07 19:21:33 -0500115FILES:${PN}-module-xt-conntrack += "${libdir}/xtables/libxt_state.so"
Andrew Geisslerd5838332022-05-27 11:33:10 -0500116FILES:${PN}-module-xt-ct += "${libdir}/xtables/libxt_NOTRACK.so ${libdir}/xtables/libxt_REDIRECT.so"
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500117FILES:${PN}-module-xt-nat += "${libdir}/xtables/libxt_SNAT.so ${libdir}/xtables/libxt_DNAT.so ${libdir}/xtables/libxt_MASQUERADE.so"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500118
Patrick Williams213cb262021-08-07 19:21:33 -0500119ALLOW_EMPTY:${PN}-modules = "1"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500120
Patrick Williams213cb262021-08-07 19:21:33 -0500121INSANE_SKIP:${PN}-module-xt-conntrack = "dev-so"
122INSANE_SKIP:${PN}-module-xt-ct = "dev-so"
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500123INSANE_SKIP:${PN}-module-xt-nat = "dev-so"