Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | SUMMARY = "Tools for managing kernel packet filtering capabilities" |
| 2 | DESCRIPTION = "iptables is the userspace command line program used to configure and control network packet \ |
| 3 | filtering code in Linux." |
| 4 | HOMEPAGE = "http://www.netfilter.org/" |
| 5 | BUGTRACKER = "http://bugzilla.netfilter.org/" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 6 | LICENSE = "GPL-2.0-or-later" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 7 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ |
| 8 | file://iptables/iptables.c;beginline=13;endline=25;md5=c5cffd09974558cf27d0f763df2a12dc \ |
| 9 | " |
| 10 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 11 | SRC_URI = "http://netfilter.org/projects/iptables/files/iptables-${PV}.tar.xz \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 12 | file://iptables.service \ |
| 13 | file://iptables.rules \ |
| 14 | file://ip6tables.service \ |
| 15 | file://ip6tables.rules \ |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 16 | file://0001-configure-Add-option-to-enable-disable-libnfnetlink.patch \ |
| 17 | file://0002-iptables-xshared.h-add-missing-sys.types.h-include.patch \ |
| 18 | file://0003-Makefile.am-do-not-install-etc-ethertypes.patch \ |
| 19 | file://0004-configure.ac-only-check-conntrack-when-libnfnetlink-.patch \ |
| 20 | file://format-security.patch \ |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 21 | " |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 22 | SRC_URI[sha256sum] = "ef6639a43be8325a4f8ea68123ffac236cb696e8c78501b64e8106afb008c87f" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 23 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 24 | SYSTEMD_SERVICE:${PN} = "\ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 25 | iptables.service \ |
| 26 | ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'ip6tables.service', '', d)} \ |
| 27 | " |
| 28 | |
| 29 | inherit autotools pkgconfig systemd |
| 30 | |
| 31 | EXTRA_OECONF = "--with-kernel=${STAGING_INCDIR}" |
| 32 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 33 | CFLAGS:append:libc-musl = " -D__UAPI_DEF_ETHHDR=0" |
| 34 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 35 | PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}" |
| 36 | PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6," |
| 37 | |
| 38 | # libnfnetlink recipe is in meta-networking layer |
| 39 | PACKAGECONFIG[libnfnetlink] = "--enable-libnfnetlink,--disable-libnfnetlink,libnfnetlink libnetfilter-conntrack" |
| 40 | |
| 41 | # libnftnl recipe is in meta-networking layer(previously known as libnftables) |
| 42 | PACKAGECONFIG[libnftnl] = "--enable-nftables,--disable-nftables,libnftnl" |
| 43 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 44 | do_configure:prepend() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 45 | # Remove some libtool m4 files |
| 46 | # Keep ax_check_linker_flags.m4 which belongs to autoconf-archive. |
| 47 | rm -f libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 48 | |
| 49 | # Copy a header to fix out of tree builds |
| 50 | cp -f ${S}/libiptc/linux_list.h ${S}/include/libiptc/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | IPTABLES_RULES_DIR ?= "${sysconfdir}/${BPN}" |
| 54 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 55 | do_install:append() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 56 | install -d ${D}${IPTABLES_RULES_DIR} |
| 57 | install -m 0644 ${WORKDIR}/iptables.rules ${D}${IPTABLES_RULES_DIR} |
| 58 | |
| 59 | install -d ${D}${systemd_system_unitdir} |
| 60 | install -m 0644 ${WORKDIR}/iptables.service ${D}${systemd_system_unitdir} |
| 61 | |
| 62 | sed -i \ |
| 63 | -e 's,@SBINDIR@,${sbindir},g' \ |
| 64 | -e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \ |
| 65 | ${D}${systemd_system_unitdir}/iptables.service |
| 66 | |
| 67 | if ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'true', 'false', d)} ; then |
| 68 | install -m 0644 ${WORKDIR}/ip6tables.rules ${D}${IPTABLES_RULES_DIR} |
| 69 | install -m 0644 ${WORKDIR}/ip6tables.service ${D}${systemd_system_unitdir} |
| 70 | |
| 71 | sed -i \ |
| 72 | -e 's,@SBINDIR@,${sbindir},g' \ |
| 73 | -e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \ |
| 74 | ${D}${systemd_system_unitdir}/ip6tables.service |
| 75 | fi |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 76 | |
| 77 | # if libnftnl is included, make the iptables symlink point to the nft-based binary by default |
| 78 | if ${@bb.utils.contains('PACKAGECONFIG', 'libnftnl', 'true', 'false', d)} ; then |
| 79 | ln -sf ${sbindir}/xtables-nft-multi ${D}${sbindir}/iptables |
| 80 | fi |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 81 | } |
| 82 | |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 83 | PACKAGES =+ "${PN}-modules ${PN}-apply" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 84 | PACKAGES_DYNAMIC += "^${PN}-module-.*" |
| 85 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 86 | python populate_packages:prepend() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 87 | modules = do_split_packages(d, '${libdir}/xtables', r'lib(.*)\.so$', '${PN}-module-%s', '${PN} module %s', extra_depends='') |
| 88 | if modules: |
| 89 | metapkg = d.getVar('PN') + '-modules' |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 90 | d.appendVar('RDEPENDS:' + metapkg, ' ' + ' '.join(modules)) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 91 | } |
| 92 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 93 | RDEPENDS:${PN} = "${PN}-module-xt-standard" |
| 94 | RRECOMMENDS:${PN} = " \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 95 | ${PN}-modules \ |
| 96 | kernel-module-x-tables \ |
| 97 | kernel-module-ip-tables \ |
| 98 | kernel-module-iptable-filter \ |
| 99 | kernel-module-iptable-nat \ |
| 100 | kernel-module-nf-defrag-ipv4 \ |
| 101 | kernel-module-nf-conntrack \ |
| 102 | kernel-module-nf-conntrack-ipv4 \ |
| 103 | kernel-module-nf-nat \ |
| 104 | kernel-module-ipt-masquerade \ |
| 105 | ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', '\ |
| 106 | kernel-module-ip6table-filter \ |
| 107 | kernel-module-ip6-tables \ |
| 108 | ', '', d)} \ |
| 109 | " |
| 110 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 111 | FILES:${PN} += "${datadir}/xtables" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 112 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 113 | FILES:${PN}-apply = "${sbindir}/ip*-apply" |
| 114 | RDEPENDS:${PN}-apply = "${PN} bash" |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 115 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 116 | # Include the symlinks as well in respective packages |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 117 | FILES:${PN}-module-xt-conntrack += "${libdir}/xtables/libxt_state.so" |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 118 | FILES:${PN}-module-xt-ct += "${libdir}/xtables/libxt_NOTRACK.so ${libdir}/xtables/libxt_REDIRECT.so" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 119 | FILES:${PN}-module-xt-nat += "${libdir}/xtables/libxt_SNAT.so ${libdir}/xtables/libxt_DNAT.so ${libdir}/xtables/libxt_MASQUERADE.so" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 120 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 121 | ALLOW_EMPTY:${PN}-modules = "1" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 122 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 123 | INSANE_SKIP:${PN}-module-xt-conntrack = "dev-so" |
| 124 | INSANE_SKIP:${PN}-module-xt-ct = "dev-so" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 125 | INSANE_SKIP:${PN}-module-xt-nat = "dev-so" |