106.2. nftables-1.1.7
Netfilter packet filtering and classification framework, and the nft tool the firewall is written in
| Version | 1.1.7, release 1 |
| Shelf | network — Host network configuration and connection management: links, Wi-Fi, DHCP, DNS forwarding, time, modems, firewall and VPN |
| Phase | 41_system (System), 310 of 1047 in build order |
| Licence | GPL-2.0-only AND GPL-2.0-or-later |
| Homepage | https://netfilter.org/projects/nftables/ |
| Build time | 0.4 SBU |
| Installed size | 1.4 MiB in 29 files |
| Recipe | ports/core/network/nftables/kpkgbuild |
About
nftables is the kernel’s packet filtering framework and nft, the program that loads and lists its rules. The KDOS firewall is written in it: /etc/init.d/25_nftables.sh checks /etc/nftables.conf and the drop-ins in /etc/nftables.d/ with nft -c and loads them at boot, and kdos-powerd rewrites 50-kdos-services.nft and reloads the ruleset when an administrator opens or closes a service. The shipped ruleset and how it is applied are in The firewall.
Container networking uses it as well. netavark, podman’s network backend, runs with its nftables firewall driver and drives nft in JSON mode. networkmanager, libvirt, dnsmasq and wireguard-tools depend on this port too.
Sources
nftables-1.1.7.tar.xz(1.0 MiB)
sha256a6fbf060d8d4fff001517a2b94f356bb4366bfbf0ba366366f9d27cc38caa58f
upstream: https://www.netfilter.org/pub/nftables/nftables-1.1.7.tar.xz
archive copy: sources-3/network--nftables-1.1.7.tar.xz
Dependencies
Depends on: libmnl, libnftnl, gmp, readline, jansson, bison, flex.
Required by (5): dnsmasq, libvirt, netavark, networkmanager, wireguard-tools.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install nftables'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/network/nftables.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/network/nftables
echo 'a6fbf060d8d4fff001517a2b94f356bb4366bfbf0ba366366f9d27cc38caa58f nftables-1.1.7.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/nftables
SRC=$SRC_ROOT/nftables-1.1.7
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf nftables-1.1.7.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--libdir=/usr/lib \
--with-cli=readline \
--with-json \
--without-xtables \
--enable-extended-parser-errors \
--enable-man-doc \
--disable-debug \
--disable-static
make
make DESTDIR=$PKG install
The switches, and why each is set:
--with-cli=readline— Buildsnft -i, the interactive shell, with GNU readline for line editing. configure’s default is editline.--with-json— Builds JSON input and output (nft -j) on jansson. netavark’s vendored nftables library runsnft -jboth to read the ruleset and to apply its own, so without this switch every one of those calls fails.--without-xtables— Builds without libxtables, the iptables library upstream uses “for iptables interaction”: rules that carry iptables match or target extensions. It is upstream’s default, and the KDOS ruleset is written in native nftables.--enable-extended-parser-errors— Builds the rule parser with Bison’sparse.error=customand LAC (lookahead correction) for its syntax error messages. It needs a bison recent enough forparse.error=custom; left unset, configure turns it on only when it finds one.--enable-man-doc— Installs the manual pagesnft(8),libnftables(3)andlibnftables-json(5). The release tarball carries them already built, soa2xis not needed. It is upstream’s default.--disable-debug— Leaves out the-g -DDEBUGthat the Makefile adds to every compile when this option is on, as it is by default.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/nftables, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf nftables-1.1.7-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/nftables, and runs the triggers its paths call for.
Contents
Installed programs: nft.
Installed libraries: libnftables.so.
Installed directories: /etc/nftables, /usr/include/nftables, /usr/share/doc/nftables, /usr/share/licenses/nftables, /usr/share/nftables.
Short descriptions
nft |
Administration tool of the nftables framework for packet filtering and classification |
libnftables.pc |
Netfilter nf_tables user library |