M1: compat layer + pf.ko skeleton builds against Linux 7.3.4

- pfk.h: BSD types/ioctl encoding (OpenBSD bit layout), locks (NET_LOCK=rwsem),
  pools, timeouts, mbuf shim over sk_buff, ifnet registry, toeplitz/siphash
- pfk_mod/pfk_hooks: misc /dev/pf (0600), IPv4 netfilter hook skeleton,
  DIOCGETSTATUS answered (M1 skeleton; engine ioctls land with pf_ioctl.c)
- vendorize/stage-port scripts: deterministic upstream staging with seds
  (struct renames, IFF_*->PFIFF_*, sa_len drops) logged to docs/porting-notes
- fixes: modules_prepare+Module.symvers for out-of-tree builds
This commit is contained in:
lgcosta committed 2026-11-11 12:09:34 -03:00
1 parent ba81284bd3
commit da2e9b679a
87 files changed
+47256 -3

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
instance-id: pflab-@VM@-v3
local-hostname: @VM@
+14
View File
@@ -0,0 +1,14 @@
# cloud-init network config v2 — pftest-cli. mgmt dhcp gives DNS only
# (use-routes:false); default route goes through pf0 so LAN->WAN traffic
# exercises pf forwarding. Rendered by scripts/vm-create.sh.
version: 2
ethernets:
mgmt:
match: {macaddress: "@CLI_MAC_MGMT@"}
dhcp4: true
dhcp4-overrides: {use-routes: false}
lan:
match: {macaddress: "@CLI_MAC_LAN@"}
addresses: [@CLI@]
routes:
- {to: default, via: @CLI_GW@}
+13
View File
@@ -0,0 +1,13 @@
# cloud-init network config v2 — pftest-gw2. No mgmt NIC (contract):
# pf-wan2 + pf-wan only, forwards between them (ip_forward set in user-data);
# default via pf0 so the guest itself has egress for package installs.
version: 2
ethernets:
wan2:
match: {macaddress: "@GW2_MAC_WAN2@"}
addresses: [@GW2_WAN2@]
wan:
match: {macaddress: "@GW2_MAC_WAN@"}
addresses: [@GW2_WAN@]
routes:
- {to: default, via: @PF0_WAN_IP@}
+16
View File
@@ -0,0 +1,16 @@
# cloud-init network config v2 — pftest-pf0. mgmt=dhcp on default net,
# data ifaces static (lab/ips.env). Rendered by scripts/vm-create.sh.
version: 2
ethernets:
mgmt:
match: {macaddress: "@PF0_MAC_MGMT@"}
dhcp4: true
lan:
match: {macaddress: "@PF0_MAC_LAN@"}
addresses: [@PF0_LAN@]
wan:
match: {macaddress: "@PF0_MAC_WAN@"}
addresses: [@PF0_WAN@]
wan2:
match: {macaddress: "@PF0_MAC_WAN2@"}
addresses: [@PF0_WAN2@]
+15
View File
@@ -0,0 +1,15 @@
# cloud-init network config v2 — pftest-srv. mgmt dhcp gives DNS only;
# default via pf0 (SRV_GW); 10.0.3.0/24 pinned via gw2 so the srv->gw2
# path is exercised through gw forwarding instead of pf0's own link.
version: 2
ethernets:
mgmt:
match: {macaddress: "@SRV_MAC_MGMT@"}
dhcp4: true
dhcp4-overrides: {use-routes: false}
wan:
match: {macaddress: "@SRV_MAC_WAN@"}
addresses: [@SRV@]
routes:
- {to: default, via: @SRV_GW@}
- {to: 10.0.3.0/24, via: @GW2_WAN_IP@}
+23
View File
@@ -0,0 +1,23 @@
#cloud-config
# Rendered per VM by scripts/vm-create.sh (tokens: @...@).
hostname: @VM@
manage_etc_hosts: true
ssh_pwauth: true
users:
- name: root
lock_passwd: false
ssh_authorized_keys:
- @SSH_PUBKEY@
chpasswd:
expire: false
users:
- name: root
password: "@ROOT_PASS@"
type: text
packages: @LAB_PACKAGES@
runcmd:
- echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/00-pflab.conf
- sysctl -q -p /etc/sysctl.d/00-pflab.conf
- "printf '@ROOT_PASS@\\n@ROOT_PASS@\\n' | passwd root >/dev/null 2>&1 || true"
@RUNCMD_EXTRA@
- touch /run/pf-lab-ready
+49
View File
@@ -0,0 +1,49 @@
<domain type='kvm'>
<name>@NAME@</name>
<memory unit='MiB'>@VM_MEM_MB@</memory>
<vcpu>@VM_VCPUS@</vcpu>
<cpu mode='host-passthrough' check='partial'/>
<os>
<type arch='x86_64' machine='q35'>hvm</type>
<boot dev='hd'/>
@KERNELBLOCK@
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='@DISK@'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='@SEED@'/>
<target dev='sda' bus='sata'/>
<readonly/>
</disk>
<interface type='network'>
<mac address='@CLI_MAC_MGMT@'/>
<source network='@MGMT_NET@'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='@CLI_MAC_LAN@'/>
<source network='@NET_PF_LAN@'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<target type='isa-serial' port='0'><model name='isa-serial'/></target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<memballoon model='virtio'/>
</devices>
</domain>
+50
View File
@@ -0,0 +1,50 @@
<!-- gw2: no mgmt NIC by contract; reachable from deb via pf-wan2 bridge IP -->
<domain type='kvm'>
<name>@NAME@</name>
<memory unit='MiB'>@VM_MEM_MB@</memory>
<vcpu>@VM_VCPUS@</vcpu>
<cpu mode='host-passthrough' check='partial'/>
<os>
<type arch='x86_64' machine='q35'>hvm</type>
<boot dev='hd'/>
@KERNELBLOCK@
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='@DISK@'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='@SEED@'/>
<target dev='sda' bus='sata'/>
<readonly/>
</disk>
<interface type='network'>
<mac address='@GW2_MAC_WAN@'/>
<source network='@NET_PF_WAN@'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='@GW2_MAC_WAN2@'/>
<source network='@NET_PF_WAN2@'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<target type='isa-serial' port='0'><model name='isa-serial'/></target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<memballoon model='virtio'/>
</devices>
</domain>
+59
View File
@@ -0,0 +1,59 @@
<domain type='kvm'>
<name>@NAME@</name>
<memory unit='MiB'>@VM_MEM_MB@</memory>
<vcpu>@VM_VCPUS@</vcpu>
<cpu mode='host-passthrough' check='partial'/>
<os>
<type arch='x86_64' machine='q35'>hvm</type>
<boot dev='hd'/>
@KERNELBLOCK@
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='@DISK@'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='@SEED@'/>
<target dev='sda' bus='sata'/>
<readonly/>
</disk>
<interface type='network'>
<mac address='@PF0_MAC_MGMT@'/>
<source network='@MGMT_NET@'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='@PF0_MAC_LAN@'/>
<source network='@NET_PF_LAN@'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='@PF0_MAC_WAN@'/>
<source network='@NET_PF_WAN@'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='@PF0_MAC_WAN2@'/>
<source network='@NET_PF_WAN2@'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<target type='isa-serial' port='0'><model name='isa-serial'/></target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<memballoon model='virtio'/>
</devices>
</domain>
+49
View File
@@ -0,0 +1,49 @@
<domain type='kvm'>
<name>@NAME@</name>
<memory unit='MiB'>@VM_MEM_MB@</memory>
<vcpu>@VM_VCPUS@</vcpu>
<cpu mode='host-passthrough' check='partial'/>
<os>
<type arch='x86_64' machine='q35'>hvm</type>
<boot dev='hd'/>
@KERNELBLOCK@
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='@DISK@'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='@SEED@'/>
<target dev='sda' bus='sata'/>
<readonly/>
</disk>
<interface type='network'>
<mac address='@SRV_MAC_MGMT@'/>
<source network='@MGMT_NET@'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='@SRV_MAC_WAN@'/>
<source network='@NET_PF_WAN@'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<target type='isa-serial' port='0'><model name='isa-serial'/></target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<memballoon model='virtio'/>
</devices>
</domain>
+68
View File
@@ -0,0 +1,68 @@
# PF-on-Linux VM lab topology — single source of truth.
# Consumed by scripts/lab-lib.sh (sourced as shell). VM aliases: pf0 cli srv gw2
# (domain names are pftest-<alias>). Hypervisor host "deb" runs everything.
DEB=192.168.1.242
DEB_USER=root
# --- addressing (contract) ---
PF0_MGMT=dhcp # default-net NAT 192.168.122.0/24 (dhcp)
PF0_LAN=10.0.1.1/24
PF0_WAN=10.0.2.1/24
PF0_WAN2=10.0.3.1/24
CLI=10.0.1.10/24
CLI_GW=10.0.1.1
SRV=10.0.2.20/24
SRV_GW=10.0.2.1
GW2_WAN2=10.0.3.2/24
GW2_WAN=10.0.2.2/24 # gw2 ip_forward=1 forwards wan2<->wan
# IPs that laptop `ssh pf0|cli|srv|gw2` (ProxyJump via deb) and nested ssh use.
PF0_SSH=10.0.1.1
CLI_SSH=10.0.1.10
SRV_SSH=10.0.2.20
GW2_SSH=10.0.3.2 # reachable from deb via pf-wan2 bridge IP
# --- libvirt networks ---
MGMT_NET=default # start+autostart; NAT, dhcp
NET_PF_LAN=pf-lan # 10.0.1.0/24, forward=none
NET_PF_WAN=pf-wan
NET_PF_WAN2=pf-wan2
# Host-side bridge addresses (NOT used by any guest; let deb route to VMs).
PF_LAN_HOSTIP=10.0.1.254
PF_WAN_HOSTIP=10.0.2.254
PF_WAN2_HOSTIP=10.0.3.254
PF_NET_PREFIX=255.255.255.0
# --- domain sizing ---
VM_VCPUS=2
VM_MEM_MB=1024
# --- MACs (match blocks in network-config templates) ---
PF0_MAC_MGMT=52:54:00:aa:00:01
PF0_MAC_LAN=52:54:00:aa:00:02
PF0_MAC_WAN=52:54:00:aa:00:03
PF0_MAC_WAN2=52:54:00:aa:00:04
CLI_MAC_MGMT=52:54:00:bb:00:01
CLI_MAC_LAN=52:54:00:bb:00:02
SRV_MAC_MGMT=52:54:00:cc:00:01
SRV_MAC_WAN=52:54:00:cc:00:02
GW2_MAC_WAN=52:54:00:dd:00:01
GW2_MAC_WAN2=52:54:00:dd:00:02
# --- root creds / packages (cloud-init) ---
ROOT_PASS=pftest
LAB_PACKAGES='[iperf3, tcpdump, python3, py3-scapy, bash]'
# --- paths ---
IMG_DIR=/var/lib/libvirt/images
BASE_IMG=$IMG_DIR/alpine-base.qcow2 # immutable; per-VM disks back onto it
SEED_DIR=/var/lib/libvirt/pflab/seeds # cloud-init dirs + seed.iso per VM
DEPLOY_DIR=/var/lib/pflab/deploy # vm-deploy.sh landing zone (on deb)
BOOT_DIR=/var/lib/pflab/boot # --pf0-kernel artifacts (on deb)
LAB_KEY_DEB=/root/.ssh/pflab_ed # keypair injected into VM authorized_keys
LAB_KEY_LAPTOP=$HOME/.ssh/pflab_ed
LAPTOP_SSH_FRAG=$HOME/.ssh/config.d/pflab
# Laptop source image fetched by scripts/fetch-sources.sh (see vendorize.sh style).
BASE_SRC_REL=_vendor/images/alpine-3.22-x86_64-cloud.qcow2