M1 progress: engine port compiles except pf.c; AF_DIVERT socket family; ifq framework

- compat layer extended through the full BSD API surface pf_ioctl/pf_lb/
  pf_if/pf_norm/pf_table/pf_ruleset/radix/md5/sha2 need (all compile):
  cpumem/counters model, ifaddr/ifg groups, cred view, endian+in6 names,
  NAT46/64, SipHash24, mbuf_list, frag6 helpers, ip6 forward/checksum,
  tcp options/FSM names, taskqueue & sysctl shims (documented in
  docs/porting-notes.md)
- pfsrc/divert_sock.c: real BSD divert(4) as runtime-registered PF_DIVERT=32
  socket family inside the module (sock_register; NPROTO=AF_MAX=45 -> zero
  core patches); divert_packet/divert6_packet wired for pf.c
- compat/pfk_ifq.c: OpenBSD 8.0 ifq framework with priq back end; hfsc and
  fq_codel aliases pending M5 (recorded in feature matrix as pending)
- design + plan updated for the divert decision (user-requested)
- stage-port.sh: single deterministic rename program for headers and .c
This commit is contained in:
lgcosta committed 2026-11-11 13:35:53 -03:00
1 parent a84b2c91f3
commit 1fcd7b3046
77 files changed
+28002 -1114

No files matched your search

+539
View File
@@ -113,3 +113,542 @@ port_c crypto/md5.c -> compat/md5.c (includes→pfk.h; struct renames; sa_len nu
```sh
port_c crypto/sha2.c -> compat/sha2.c (includes→pfk.h; struct renames; sa_len nulled)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf.c -> pfsrc/pf.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_if.c -> pfsrc/pf_if.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_lb.c -> pfsrc/pf_lb.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_ruleset.c -> pfsrc/pf_ruleset.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_table.c -> pfsrc/pf_table.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_osfp.c -> pfsrc/pf_osfp.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/pf_syncookies.c -> pfsrc/pf_syncookies.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/ifq.c -> pfsrc/ifq.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/hfsc.c -> pfsrc/hfsc.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/fq_codel.c -> pfsrc/fq_codel.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c net/if_pflog.c -> pfsrc/if_pflog.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c netinet/ip_divert.c -> pfsrc/ip_divert.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c crypto/md5.c -> compat/md5.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:22:35-03:00 staging
```sh
port_c crypto/sha2.c -> compat/sha2.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:23:13-03:00 staging
```sh
port_c net/radix.c -> compat/radix.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:23:13-03:00 staging
```sh
port_c net/rtable.c -> compat/rtable.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:31:22-03:00 staging
```sh
stage: headers + skeletons
```
## 2026-11-11T12:33:23-03:00 staging
```sh
stage: headers + skeletons
```
## 2026-11-11T12:33:35-03:00 staging
```sh
stage: headers + skeletons
```
## 2026-11-11T12:35:29-03:00 staging
```sh
stage: headers + skeletons
```
## 2026-11-11T12:36:13-03:00 staging
```sh
stage: headers + skeletons
```
## 2026-11-11T12:38:18-03:00 staging
```sh
port_c net/radix.c -> compat/radix.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:38:18-03:00 staging
```sh
port_c net/rtable.c -> compat/rtable.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:39:29-03:00 staging
```sh
port_c net/pf.c -> pfsrc/pf.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:39:29-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf.c -> pfsrc/pf.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_if.c -> pfsrc/pf_if.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_lb.c -> pfsrc/pf_lb.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_ruleset.c -> pfsrc/pf_ruleset.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_table.c -> pfsrc/pf_table.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_osfp.c -> pfsrc/pf_osfp.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/pf_syncookies.c -> pfsrc/pf_syncookies.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/ifq.c -> pfsrc/ifq.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/hfsc.c -> pfsrc/hfsc.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/fq_codel.c -> pfsrc/fq_codel.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c net/if_pflog.c -> pfsrc/if_pflog.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c netinet/ip_divert.c -> pfsrc/ip_divert.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c crypto/md5.c -> compat/md5.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:42:35-03:00 staging
```sh
port_c crypto/sha2.c -> compat/sha2.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:10-03:00 staging
```sh
port_c net/pf.c -> pfsrc/pf.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:10-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/pf_if.c -> pfsrc/pf_if.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/pf_lb.c -> pfsrc/pf_lb.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/pf_ruleset.c -> pfsrc/pf_ruleset.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/pf_table.c -> pfsrc/pf_table.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/pf_osfp.c -> pfsrc/pf_osfp.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/pf_syncookies.c -> pfsrc/pf_syncookies.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/ifq.c -> pfsrc/ifq.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/hfsc.c -> pfsrc/hfsc.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/fq_codel.c -> pfsrc/fq_codel.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c net/if_pflog.c -> pfsrc/if_pflog.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:11-03:00 staging
```sh
port_c netinet/ip_divert.c -> pfsrc/ip_divert.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf.c -> pfsrc/pf.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_if.c -> pfsrc/pf_if.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_lb.c -> pfsrc/pf_lb.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_ruleset.c -> pfsrc/pf_ruleset.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_table.c -> pfsrc/pf_table.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_osfp.c -> pfsrc/pf_osfp.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/pf_syncookies.c -> pfsrc/pf_syncookies.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/ifq.c -> pfsrc/ifq.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/hfsc.c -> pfsrc/hfsc.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/fq_codel.c -> pfsrc/fq_codel.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c net/if_pflog.c -> pfsrc/if_pflog.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:43:44-03:00 staging
```sh
port_c netinet/ip_divert.c -> pfsrc/ip_divert.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:49:48-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:56:45-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:56:46-03:00 staging
```sh
port_c net/pf.c -> pfsrc/pf.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:56:46-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:56:46-03:00 staging
```sh
port_c net/pf_if.c -> pfsrc/pf_if.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:56:46-03:00 staging
```sh
port_c net/pf_lb.c -> pfsrc/pf_lb.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:57:50-03:00 staging
```sh
stage: headers + skeletons
```
## 2026-11-11T12:57:50-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped->pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf.c -> pfsrc/pf.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_norm.c -> pfsrc/pf_norm.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_if.c -> pfsrc/pf_if.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_lb.c -> pfsrc/pf_lb.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_ruleset.c -> pfsrc/pf_ruleset.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_table.c -> pfsrc/pf_table.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_osfp.c -> pfsrc/pf_osfp.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/pf_syncookies.c -> pfsrc/pf_syncookies.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/ifq.c -> pfsrc/ifq.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/hfsc.c -> pfsrc/hfsc.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/fq_codel.c -> pfsrc/fq_codel.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c net/if_pflog.c -> pfsrc/if_pflog.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c netinet/ip_divert.c -> pfsrc/ip_divert.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c crypto/md5.c -> compat/md5.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
port_c crypto/sha2.c -> compat/sha2.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T12:58:34-03:00 staging
```sh
stage: headers
```
## 2026-11-11T13:00:24-03:00 staging
```sh
port_c net/pf_if.c -> pfsrc/pf_if.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T13:06:14-03:00 staging
```sh
port_c net/pf_syncookies.c -> pfsrc/pf_syncookies.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T13:06:41-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T13:14:45-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T13:17:40-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T13:18:44-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
## 2026-11-11T13:25:25-03:00 staging
```sh
port_c net/pf_ioctl.c -> pfsrc/pf_ioctl.c (includes dropped -> pfk.h; -D_KERNEL mode; renames)
```
@@ -124,11 +124,11 @@
- [ ] Step 1: implement + port `pf_route/pf_route6` glue; compile.
- [ ] Step 2: tests `09-routeto.sh` (tcpdump counts wan vs wan2: rr alternation exact, hash-source deterministic per src; loop-guard: pf0->pf0 route-to with gw=pf0 must not livelock: bounded pkts then block `block loop drop`? use upstream `pf_route` loop detection → drop; assert), `10-dup-fail.sh`; commit.
### Task 15: divert
**Files:** `module/pf/pf_divert_nl.c` (kernel: `netlink_kernel_create(NETLINK_USERSOCK, proto=31? use NETLINK_USERSOCK group id per divert port)`, table port→socket, `divert-to` path: copy skb → nl msg `{cookie, divport, af, ip hdr+payload}`; reinjection path on user `send`: parse → route per original semantics `ip_divert.c` reference (divert-to: re-route to original dst via gw if needed; plain divert tag: re-enter `netif_receive_skb`/local_xmit per 8.0 `pf_send` behavior; drop-after-timeout via per-packet timer default 5s? match upstream: no accept → packet never delivered (copy consumed? original held until accept/timeout then free — mirror OpenBSD: keep, timeout drop).
**Interfaces:** `pdivert -p 10000` + rule `pass in divert-to 127.0.0.1 10000`? upstream model: `divert-to` sends to divert socket at **host:port**; ours: netlink port id; document mapping in `docs/en/divert.md`; stats `DIOCBUSYSTATS` unchanged.
- [ ] Step 1: implement + tool link already from T8.
- [ ] Step 2: test `11-divert.sh`: pdivert on pf0 flips a byte of ping payload → cli receives modified echo-replies; kill pdivert → traffic stops (timeout) not leaks; commit.
### Task 15: divert — AF_DIVERT socket family (design §4.4, user-requested)
**Files:** `module/pfsrc/divert_sock.c` (kernel-internal PF_DIVERT=32 family via `sock_register`, zero core patches), `tools/pdivert/` (BSD divert(8) workflow over the socket), tests reuse upstream `regress/sys/net/pf_divert` semantics (Perl client adapted to our socket).
**Interfaces:** `divert_packet/divert6_packet(mbuf, dir, port)` consumed by pf.c (already wired); userspace ABI: `socket(PF_DIVERT=32, SOCK_RAW, IPPROTO_DIVERT=254)`, `bind(sin_port=divert_port)`, `recvmsg` → raw IP packet + cmsgs (IFINDEX/DIR/TYPE/DST), `sendmsg` → re-inject (divert-to ⇒ local `netif_rx`; tag-divert ⇒ re-route).
- [ ] Step 1: kernel self-test (module_param `divert_selftest`): inject synthetic packet → socket recv → send → observed re-injection; no netfilter re-entry loop.
- [ ] Step 2: test `11-divert.sh`: pdivert on pf0 flips a byte of ping payload → cli receives modified echo-replies; kill pdivert → traffic stops (no leak); `divert-to 10.0.99.9 10000` cross-host variant; commit.
### Task 16: ifq + pfq queueing
**Files:** `module/ifq/ifq.c ifq.h hfsc.c fq_codel.c` ported (skb-backed via pfk_mbuf), `module/pfq/pfq_qdisc.c` (classful qdisc `pfq`: root=ifq attach; ops: enqueue→`ifq_enqueue(ifq_for_class)`, dequeue loop; classid = queue index from pf rule queue tag), `module/pf/pf_ifq_bridge.c` (DIOCADDQUEUE/GETQUEUES/GETQUEUE/QSTATS + `pf_test` queue assignment + `set queue` default-class + ifq per-iface registry via `pfq_q_enter`), scripts `pf-qdisc.sh` auto-attach on `queue on` detection at DIOCADDQUEUE.
@@ -139,16 +139,22 @@ priority bits). `DIOCADDQUEUE/DIOCGETQUEUES/DIOCGETQUEUE/DIOCGETQSTATS` (the rea
fq_codel** with rate gates (§7); class visibility via `tc -s qdisc show` is a
stretch goal, counters via `pfctl` are the gate.
### 4.4 divert
- In-pf action `divert-to host:port` / tag `divert port`: packet copied to
userspace divert channel; **channel = kernel netlink** (`NETLINK_USERSOCK` proto)
because Linux has no `AF_DIVERT` (in-tree reference logic ported from
`sys/netinet/ip_divert.c`; userland `pdivert` tool implements `divert(8)`-style
rewrite-loop over the netlink channel; wire format documented; `DIOCBUSYSTATS`
etc. unchanged). Diverted flow re-enters via the channel write →
`__dev_queue_xmit`/`netif_receive_skb` following ip_divert `divert_output`
semantics (re-route via gw neighbor for `divert-to`).
- Test parity anchored by upstream `regress/sys/net/pf_divert` semantics.
### 4.4 divert — real AF_DIVERT in the kernel (no netlink substitute)
OpenBSD's `divert(4)` socket family is ported as a **runtime-registered
socket family inside pf.ko**: Linux 7.3 registers protocol families with
`sock_register()` and `NPROTO = AF_MAX = 45`, so BSD's `PF_DIVERT = 32`
(the unused legacy PF_IUCV slot) fits with **zero core changes**. Implemented
in `module/pfsrc/divert_sock.c`: `socket(PF_DIVERT, SOCK_RAW, IPPROTO_DIVERT)`
+ `bind(port)` + `recvmsg/sendmsg`, packet metadata via cmsg (ifindex, dir,
divert type, original dst). `divert_packet()/divert6_packet()` (called by the
ported pf.c) queue to the bound socket; `sendmsg` re-injects with OpenBSD
semantics: `PF_DIVERT_TO` → local delivery (`netif_rx` on the recorded
interface), plain `divert` tag → re-route (`dst->output`), mirroring
`ip_divert.c:divert_output()`. The BSD `divert(8)` workflow (upstream
`regress/sys/net/pf_divert`) drives this socket unchanged; our shipped
`pdivert` is a thin Linux port. Wire format documented in
`docs/en/divert-wireformat.md`. pflog keeps its netlink multicast channel
(slot PFLOG_PROTO=1 on `NETLINK_USERSOCK`).
### 4.5 route-to / dup-to / fail-to
`pf_route6`/`pf_route` port: pool selection via `pf_lb.c` (as-is), next-hop
+1 -1
View File
@@ -11,4 +11,4 @@ ethernets:
match: {macaddress: "@CLI_MAC_LAN@"}
addresses: [@CLI@]
routes:
- {to: default, via: @CLI_GW@}
- {to: 0.0.0.0/0, via: @CLI_GW@}
+2 -1
View File
@@ -9,5 +9,6 @@ ethernets:
wan:
match: {macaddress: "@GW2_MAC_WAN@"}
addresses: [@GW2_WAN@]
nameservers: {addresses: ["192.168.122.1"]}
routes:
- {to: default, via: @PF0_WAN_IP@}
- {to: 0.0.0.0/0, via: @PF0_WAN_IP@}
+1 -1
View File
@@ -11,5 +11,5 @@ ethernets:
match: {macaddress: "@SRV_MAC_WAN@"}
addresses: [@SRV@]
routes:
- {to: default, via: @SRV_GW@}
- {to: 0.0.0.0/0, via: @SRV_GW@}
- {to: 10.0.3.0/24, via: @GW2_WAN_IP@}
+4 -2
View File
@@ -17,8 +17,10 @@ chpasswd:
package_update: true
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 'net.ipv4.ip_forward=1\nnet.ipv4.conf.all.rp_filter=0\nnet.ipv4.conf.default.rp_filter=0\n' > /etc/sysctl.d/00-pflab.conf
sysctl -q -p /etc/sysctl.d/00-pflab.conf
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > "$f"; done
- "printf '@ROOT_PASS@\\n@ROOT_PASS@\\n' | passwd root >/dev/null 2>&1 || true"
@RUNCMD_EXTRA@
- touch /run/pf-lab-ready
+1 -1
View File
@@ -1 +1 @@
savedcmd_pf.mod := printf '%s\n' pfsrc/pfk_mod.o pfsrc/pfk_hooks.o compat/pfk_mbuf.o compat/pfk_kern.o compat/pfk_if.o compat/pfk_xmit.o compat/siphash.o compat/toeplitz.o compat/md5.o compat/sha2.o | awk '!x[$$0]++ { print("./"$$0) }' > pf.mod
savedcmd_pf.mod := printf '%s\n' pfsrc/pfk_mod.o pfsrc/pfk_hooks.o compat/pfk_mbuf.o compat/pfk_kern.o compat/pfk_if.o compat/pfk_xmit.o compat/siphash.o compat/toeplitz.o compat/md5.o compat/sha2.o compat/radix.o compat/pfk_rtable.o compat/pfk_ip6.o pfsrc/pf_ruleset.o pfsrc/pf_table.o pfsrc/pf_norm.o pfsrc/pf_if.o pfsrc/pf_lb.o pfsrc/pf_osfp.o pfsrc/pf_syncookies.o pfsrc/pf_ioctl.o pfsrc/pf.o pfsrc/divert_sock.o compat/pfk_ifq.o | awk '!x[$$0]++ { print("./"$$0) }' > pf.mod
+19 -9
View File
@@ -1,17 +1,27 @@
# PF-on-Linux kernel module build (out-of-tree)
# Build: make -C /path/to/linux-7.3.4 M=$PWD (or scripts/build-module.sh)
#
# -D_KERNEL=1 selects the kernel-side branches of the staged OpenBSD sources
# (the same files also contain userland-only code guarded by #ifndef _KERNEL).
ccflags-y := -I$(src)/include -I$(src)/include/compat -DPFLINUX=1 \
-Wno-declaration-after-statement
-D_KERNEL=1 \
-Wno-declaration-after-statement \
-Wno-implicit-fallthrough \
-Wno-frame-larger-than
# M1 skeleton set — staged engine files (pf.c, pf_ioctl.c, ...) are added
# per plan tasks T7b/T10/T11/T12; keep list explicit (no wildcards).
# our glue + compat layer
pf-objs := pfsrc/pfk_mod.o pfsrc/pfk_hooks.o \
compat/pfk_mbuf.o compat/pfk_kern.o compat/pfk_if.o compat/pfk_xmit.o \
compat/siphash.o compat/toeplitz.o compat/md5.o compat/sha2.o
# staged BSD sources (uncomment as ported):
# pf-objs += compat/sha2.o compat/sha1.o compat/siphash.o compat/toeplitz.o
# pf-objs += compat/radix.o compat/rtable.o
# pf-objs += pfsrc/pf.o pfsrc/pf_ioctl.o pfsrc/pf_norm.o pfsrc/pf_if.o pfsrc/pf_lb.o
# pf-objs += pfsrc/pf_ruleset.o pfsrc/pf_table.o pfsrc/pf_osfp.o pfsrc/pf_syncookies.o
compat/siphash.o compat/toeplitz.o compat/md5.o compat/sha2.o \
compat/radix.o compat/pfk_rtable.o compat/pfk_ip6.o
# ported OpenBSD 8.0 engine
pf-objs += pfsrc/pf_ruleset.o pfsrc/pf_table.o pfsrc/pf_norm.o pfsrc/pf_if.o \
pfsrc/pf_lb.o pfsrc/pf_osfp.o pfsrc/pf_syncookies.o \
pfsrc/pf_ioctl.o pfsrc/pf.o pfsrc/divert_sock.o
# queueing framework (compat/pfk_ifq.c implements the ifq API with priq
# semantics; the OpenBSD hfsc/fq_codel back ends land in milestone M5)
pf-objs += compat/pfk_ifq.o
obj-m := pf.o
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/md5.o := gcc -Wp,-MMD,compat/.md5.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"md5"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/md5.o compat/md5.c
savedcmd_compat/md5.o := gcc -Wp,-MMD,compat/.md5.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"md5"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/md5.o compat/md5.c
source_compat/md5.o := compat/md5.c
@@ -1108,6 +1108,11 @@ deps_compat/md5.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1153,7 +1158,6 @@ deps_compat/md5.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/md5.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/md5.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/md5.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
compat/md5.o: $(deps_compat/md5.o)
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/pfk_if.o := gcc -Wp,-MMD,compat/.pfk_if.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"pfk_if"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_if.o compat/pfk_if.c
savedcmd_compat/pfk_if.o := gcc -Wp,-MMD,compat/.pfk_if.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"pfk_if"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_if.o compat/pfk_if.c
source_compat/pfk_if.o := compat/pfk_if.c
@@ -1109,6 +1109,11 @@ deps_compat/pfk_if.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1154,7 +1159,6 @@ deps_compat/pfk_if.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/pfk_if.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/pfk_if.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/pfk_if.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
compat/pfk_if.o: $(deps_compat/pfk_if.o)
File diff suppressed because it is too large. Load diff
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/pfk_kern.o := gcc -Wp,-MMD,compat/.pfk_kern.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"pfk_kern"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_kern.o compat/pfk_kern.c
savedcmd_compat/pfk_kern.o := gcc -Wp,-MMD,compat/.pfk_kern.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"pfk_kern"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_kern.o compat/pfk_kern.c
source_compat/pfk_kern.o := compat/pfk_kern.c
@@ -1108,6 +1108,11 @@ deps_compat/pfk_kern.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1153,7 +1158,6 @@ deps_compat/pfk_kern.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/pfk_kern.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/pfk_kern.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/pfk_kern.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
compat/pfk_kern.o: $(deps_compat/pfk_kern.o)
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/pfk_mbuf.o := gcc -Wp,-MMD,compat/.pfk_mbuf.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"pfk_mbuf"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_mbuf.o compat/pfk_mbuf.c
savedcmd_compat/pfk_mbuf.o := gcc -Wp,-MMD,compat/.pfk_mbuf.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"pfk_mbuf"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_mbuf.o compat/pfk_mbuf.c
source_compat/pfk_mbuf.o := compat/pfk_mbuf.c
@@ -1108,6 +1108,11 @@ deps_compat/pfk_mbuf.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1153,7 +1158,6 @@ deps_compat/pfk_mbuf.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/pfk_mbuf.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/pfk_mbuf.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/pfk_mbuf.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
compat/pfk_mbuf.o: $(deps_compat/pfk_mbuf.o)
File diff suppressed because it is too large. Load diff
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/pfk_xmit.o := gcc -Wp,-MMD,compat/.pfk_xmit.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"pfk_xmit"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_xmit.o compat/pfk_xmit.c
savedcmd_compat/pfk_xmit.o := gcc -Wp,-MMD,compat/.pfk_xmit.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"pfk_xmit"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/pfk_xmit.o compat/pfk_xmit.c
source_compat/pfk_xmit.o := compat/pfk_xmit.c
@@ -1109,6 +1109,11 @@ deps_compat/pfk_xmit.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1154,7 +1159,6 @@ deps_compat/pfk_xmit.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/pfk_xmit.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/pfk_xmit.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/pfk_xmit.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
compat/pfk_xmit.o: $(deps_compat/pfk_xmit.o)
File diff suppressed because it is too large. Load diff
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/sha2.o := gcc -Wp,-MMD,compat/.sha2.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"sha2"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/sha2.o compat/sha2.c
savedcmd_compat/sha2.o := gcc -Wp,-MMD,compat/.sha2.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"sha2"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/sha2.o compat/sha2.c
source_compat/sha2.o := compat/sha2.c
@@ -1108,6 +1108,11 @@ deps_compat/sha2.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1153,7 +1158,6 @@ deps_compat/sha2.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/sha2.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/sha2.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/sha2.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
compat/sha2.o: $(deps_compat/sha2.o)
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/siphash.o := gcc -Wp,-MMD,compat/.siphash.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"siphash"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/siphash.o compat/siphash.c
savedcmd_compat/siphash.o := gcc -Wp,-MMD,compat/.siphash.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"siphash"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/siphash.o compat/siphash.c
source_compat/siphash.o := compat/siphash.c
@@ -1108,6 +1108,11 @@ deps_compat/siphash.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1153,7 +1158,6 @@ deps_compat/siphash.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/siphash.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/siphash.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/siphash.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
compat/siphash.o: $(deps_compat/siphash.o)
+16 -6
View File
@@ -1,4 +1,4 @@
savedcmd_compat/toeplitz.o := gcc -Wp,-MMD,compat/.toeplitz.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"toeplitz"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/toeplitz.o compat/toeplitz.c
savedcmd_compat/toeplitz.o := gcc -Wp,-MMD,compat/.toeplitz.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"toeplitz"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o compat/toeplitz.o compat/toeplitz.c
source_compat/toeplitz.o := compat/toeplitz.c
@@ -1108,6 +1108,11 @@ deps_compat/toeplitz.o := \
$(wildcard include/config/UNWINDER_ORC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
@@ -1153,7 +1158,6 @@ deps_compat/toeplitz.o := \
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
$(wildcard include/config/X86_ESPFIX64) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
$(wildcard include/config/DEVICE_PRIVATE) \
@@ -1754,10 +1758,6 @@ deps_compat/toeplitz.o := \
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
@@ -1810,6 +1810,7 @@ deps_compat/toeplitz.o := \
include/compat/sys/socket.h \
include/compat/net/if_types.h \
include/compat/net/if_var.h \
include/compat/net/ifq.h \
include/pfk_mbuf.h \
include/pfk_net.h \
include/pfk_if.h \
@@ -1817,6 +1818,15 @@ deps_compat/toeplitz.o := \
include/compat/crypto/md5.h \
include/compat/crypto/siphash.h \
include/compat/net/toeplitz.h \
include/net/pfvar.h \
include/compat/sys/syslimits.h \
include/compat/netinet/in.h \
include/compat/net/radix.h \
include/net/pfvar_priv.h \
include/compat/sys/rwlock.h \
include/compat/sys/mutex.h \
include/compat/sys/pclock.h \
include/compat/sys/percpu.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/crypto/hash.h \
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/crypto.h \
+22
View File
@@ -1,5 +1,27 @@
/* PFLINUX port of OpenBSD 8.0 crypto/md5.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: md5.c,v 1.4 2014/12/28 10:04:35 tedu Exp $ */
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
#define PUT_64BIT_LE(cp, value) do { \
(cp)[7] = (value) >> 56; \
+41 -30
View File
@@ -108,33 +108,32 @@ pfk_if_stats(struct pfk_ifnet *ifp, struct pfk_if_data *out)
}
/* -------- address snapshots -------- */
static struct pfk_ifaddr *
/* Build a BSD-style ifaddr for the given interface address. */
static struct ifaddr *
pfkifa_new(struct pfk_ifnet *ifp, int family)
{
struct pfk_ifaddr *ifa = kzalloc(sizeof(*ifa), GFP_KERNEL);
struct ifaddr *ifa = kzalloc(sizeof(*ifa), GFP_KERNEL);
if (!ifa)
return NULL;
ifa->ifa_ifp = ifp;
ifa->dev = ifp->dev;
ifa->family = family;
ifa->ifa_refcnt = 1;
ifa->ifa_addr = (struct sockaddr *)&ifa->ifa_addr_storage;
refcnt_init(&ifa->ifa_refcnt);
return ifa;
}
int
pfk_if_addrlist_refresh(struct pfk_ifnet *ifp)
{
struct pfk_ifaddr *ifa, *next;
struct ifaddr *ifa;
struct net_device *dev = ifp->dev;
/* free old */
for (ifa = ifp->if_addrlist; ifa; ifa = next) {
next = ifa->ifa_next;
while (!TAILQ_EMPTY(&ifp->if_addrlist)) {
ifa = TAILQ_FIRST(&ifp->if_addrlist);
TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
kfree(ifa->ifa_addr);
kfree(ifa);
}
ifp->if_addrlist = NULL;
rcu_read_lock();
/* IPv4 */
@@ -148,16 +147,20 @@ pfk_if_addrlist_refresh(struct pfk_ifnet *ifp)
ifa = pfkifa_new(ifp, AF_INET);
if (!ifa)
continue;
ifa->addr4 = ifa4->ifa_address;
ifa->ifa_addr->sa_family = AF_INET;
ifa->ifa_addr = kmalloc(sizeof(struct sockaddr_in),
GFP_KERNEL);
if (!ifa->ifa_addr) {
kfree(ifa);
continue;
}
{
struct sockaddr_in *sin =
sintosa(ifa->ifa_addr);
sin->sin_addr.s_addr = ifa4->ifa_address;
memset(sin, 0, sizeof(*sin));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = ifa4->ifa_address;
}
ifa->ifa_next = ifp->if_addrlist;
ifp->if_addrlist = ifa;
TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list);
}
}
/* IPv6 */
@@ -171,17 +174,20 @@ pfk_if_addrlist_refresh(struct pfk_ifnet *ifp)
ifa = pfkifa_new(ifp, AF_INET6);
if (!ifa)
continue;
ifa->addr6 = ifa6->addr;
ifa->scope = ifa6->scope;
ifa->ifa_addr->sa_family = AF_INET6;
ifa->ifa_addr = kmalloc(sizeof(struct sockaddr_in6),
GFP_KERNEL);
if (!ifa->ifa_addr) {
kfree(ifa);
continue;
}
{
struct sockaddr_in6 *sin6 =
sin6tosa(ifa->ifa_addr);
memset(sin6, 0, sizeof(*sin6));
sin6->sin6_family = AF_INET6;
sin6->sin6_addr = ifa6->addr;
}
ifa->ifa_next = ifp->if_addrlist;
ifp->if_addrlist = ifa;
TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list);
}
}
#endif
@@ -189,22 +195,25 @@ pfk_if_addrlist_refresh(struct pfk_ifnet *ifp)
return 0;
}
struct pfk_ifaddr *
struct ifaddr *
pfk_ifwithaddr(const struct sockaddr *sa)
{
struct pfk_ifnet *ifp;
struct pfk_ifaddr *ifa;
struct ifaddr *ifa;
for (ifp = pfk_if_first(); ifp; ifp = pfk_if_next(ifp)) {
for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
if (ifa->family != sa->sa_family)
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (!ifa->ifa_addr ||
ifa->ifa_addr->sa_family != sa->sa_family)
continue;
if (sa->sa_family == AF_INET &&
ifa->addr4 == sintosa(sa)->sin_addr.s_addr)
sintosa(ifa->ifa_addr)->sin_addr.s_addr ==
sintosa(sa)->sin_addr.s_addr)
return ifa;
if (sa->sa_family == AF_INET6 &&
!memcmp(&ifa->addr6, &sin6tosa(sa)->sin6_addr,
sizeof(struct in6_addr)))
!memcmp(&sin6tosa(ifa->ifa_addr)->sin6_addr,
&sin6tosa(sa)->sin6_addr,
sizeof(struct in6_addr)))
return ifa;
}
}
@@ -214,10 +223,12 @@ pfk_ifwithaddr(const struct sockaddr *sa)
void
pfk_if_free(struct pfk_ifnet *ifp)
{
struct pfk_ifaddr *ifa, *next;
struct ifaddr *ifa;
for (ifa = ifp->if_addrlist; ifa; ifa = next) {
next = ifa->ifa_next;
while (!TAILQ_EMPTY(&ifp->if_addrlist)) {
ifa = TAILQ_FIRST(&ifp->if_addrlist);
TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
kfree(ifa->ifa_addr);
kfree(ifa);
}
kfree(ifp);
+424
View File
@@ -0,0 +1,424 @@
/*
* PF-on-Linux ifq (transmit queue) framework (ISC 2026)
*
* Implements the OpenBSD 8.0 sys/net/ifq.c interface used by PF's queue
* support, with priq semantics (OpenBSD's own default back end). The
* OpenBSD hfsc.c / fq_codel.c back ends are ported in milestone M5 and
* plug into the same struct ifq_ops / struct pfq_ops interfaces.
*/
#include <pfk.h>
#include "compat/net/ifq.h"
/* One queue slot per priority level (OpenBSD's priq uses 32 slots). */
#define PFQ_PRIQ_SLOTS 32
struct pfk_priq {
struct mbuf *head[PFQ_PRIQ_SLOTS];
struct mbuf *tail[PFQ_PRIQ_SLOTS];
unsigned int len[PFQ_PRIQ_SLOTS];
};
static unsigned int
pfk_priq_idx(unsigned int nifqs, const struct mbuf *m)
{
int prio = 0;
if (m && m->m_pkthdr.pf.prio)
prio = m->m_pkthdr.pf.prio;
if (prio < 0)
prio = 0;
if (prio >= PFQ_PRIQ_SLOTS)
prio = PFQ_PRIQ_SLOTS - 1;
(void)nifqs;
return (unsigned int)prio;
}
static struct mbuf *
pfk_priq_enq(struct ifqueue *ifq, struct mbuf *m)
{
struct pfk_priq *pq = ifq->ifq_softc;
unsigned int idx = pfk_priq_idx(0, m);
if (!pq)
return NULL;
if (!pq->head[idx]) {
pq->head[idx] = m;
m->m_next = NULL;
} else {
pq->tail[idx]->m_next = m;
m->m_next = NULL;
}
pq->tail[idx] = m;
pq->len[idx]++;
ifq->ifq_len++;
ifq->ifq_bytes += m->m_len;
return m;
}
static struct mbuf *
pfk_priq_deq_begin(struct ifqueue *ifq, void **cookie)
{
struct pfk_priq *pq = ifq->ifq_softc;
unsigned int idx;
*cookie = NULL;
if (!pq)
return NULL;
for (idx = 0; idx < PFQ_PRIQ_SLOTS; idx++) {
if (pq->head[idx]) {
struct mbuf *m = pq->head[idx];
pq->head[idx] = m->m_next;
if (!pq->head[idx])
pq->tail[idx] = NULL;
pq->len[idx]--;
m->m_next = NULL;
*cookie = (void *)(uintptr_t)idx;
return m;
}
}
return NULL;
}
static void
pfk_priq_deq_commit(struct ifqueue *ifq, struct mbuf *m, void *cookie)
{
(void)cookie;
if (m) {
ifq->ifq_len--;
ifq->ifq_bytes -= m->m_len;
}
}
static void
pfk_priq_purge(struct ifqueue *ifq, struct mbuf_list *ml)
{
struct pfk_priq *pq = ifq->ifq_softc;
unsigned int idx;
if (!pq)
return;
for (idx = 0; idx < PFQ_PRIQ_SLOTS; idx++) {
struct mbuf *m = pq->head[idx];
pq->head[idx] = pq->tail[idx] = NULL;
pq->len[idx] = 0;
while (m) {
struct mbuf *n = m->m_next;
m->m_next = NULL;
if (ml) {
if (ml->ml_last)
ml->ml_last->m_next = m;
else
ml->ml_first = m;
ml->ml_last = m;
ml->ml_len++;
} else
m_freem(m);
m = n;
}
}
ifq->ifq_len = 0;
ifq->ifq_bytes = 0;
}
static void *
pfk_priq_alloc(unsigned int size, void *arg)
{
struct pfk_priq *pq = kzalloc(sizeof(*pq), GFP_KERNEL);
(void)size;
(void)arg;
return pq;
}
static void
pfk_priq_free(unsigned int size, void *arg)
{
(void)size;
kfree(arg);
}
static const struct ifq_ops pfk_priq_ifq_ops = {
.ifqop_idx = pfk_priq_idx,
.ifqop_enq = pfk_priq_enq,
.ifqop_deq_begin = pfk_priq_deq_begin,
.ifqop_deq_commit = pfk_priq_deq_commit,
.ifqop_purge = pfk_priq_purge,
.ifqop_alloc = pfk_priq_alloc,
.ifqop_free = pfk_priq_free,
};
const struct ifq_ops * const ifq_priq_ops = &pfk_priq_ifq_ops;
/*
* PF queue manager back end (pfq_ops): wraps the ifq back end so that PF
* can attach a queue to an interface and query its statistics.
*/
struct pfk_pfq {
struct ifqueue ifq;
struct pfk_ifnet *ifp;
};
static void *
pfk_pfq_alloc(struct ifnet *ifp)
{
struct pfk_pfq *pfq = kzalloc(sizeof(*pfq), GFP_KERNEL);
if (!pfq)
return NULL;
pfq->ifp = ifp;
ifq_init(&pfq->ifq, ifp, IFQ_MAXLEN);
return pfq;
}
static int
pfk_pfq_addqueue(void *arg, struct pf_queuespec *qspec)
{
(void)qspec;
return arg ? 0 : EINVAL;
}
static void
pfk_pfq_free(void *arg)
{
struct pfk_pfq *pfq = arg;
if (!pfq)
return;
ifq_destroy(&pfq->ifq);
kfree(pfq);
}
static int
pfk_pfq_qstats(struct pf_queuespec *qspec, void *arg, int *pkts)
{
struct pfk_pfq *pfq = arg;
(void)qspec;
if (!pfq || !pkts)
return EINVAL;
*pkts = (int)pfq->ifq.ifq_len;
return 0;
}
static unsigned int
pfk_pfq_qlength(void *arg)
{
struct pfk_pfq *pfq = arg;
return pfq ? pfq->ifq.ifq_len : 0;
}
static struct mbuf *
pfk_pfq_enqueue(void *arg, struct mbuf *m)
{
struct pfk_pfq *pfq = arg;
if (!pfq)
return NULL;
if (ifq_enqueue(&pfq->ifq, m) != 0)
return NULL;
return m;
}
static struct mbuf *
pfk_pfq_deq_begin(void *arg, void **cookie, struct mbuf_list *ml)
{
struct pfk_pfq *pfq = arg;
(void)ml;
if (!pfq)
return NULL;
return ifq_deq_begin(&pfq->ifq);
}
static void
pfk_pfq_deq_commit(void *arg, struct mbuf *m, void *cookie)
{
struct pfk_pfq *pfq = arg;
(void)cookie;
if (pfq)
ifq_deq_commit(&pfq->ifq, m);
}
static void
pfk_pfq_purge(void *arg, struct mbuf_list *ml)
{
struct pfk_pfq *pfq = arg;
if (pfq)
ifq_purge(&pfq->ifq);
(void)ml;
}
static const struct pfq_ops pfk_priq_pfq_ops = {
.pfq_alloc = pfk_pfq_alloc,
.pfq_addqueue = pfk_pfq_addqueue,
.pfq_free = pfk_pfq_free,
.pfq_qstats = pfk_pfq_qstats,
.pfq_qlength = pfk_pfq_qlength,
.pfq_enqueue = pfk_pfq_enqueue,
.pfq_deq_begin = pfk_pfq_deq_begin,
.pfq_deq_commit = pfk_pfq_deq_commit,
.pfq_purge = pfk_pfq_purge,
};
/*
* HFSC / fq_codel back ends: OpenBSD 8.0 ships sys/net/hfsc.c and
* sys/net/fq_codel.c; those files are ported in milestone M5. Until then
* the queue framework keeps priq semantics (the queue ioctls still work and
* packets are still queued, but the traffic shaping curves are not yet
* applied — recorded in the feature matrix as pending M5).
*/
const struct ifq_ops * const ifq_hfsc_ops = &pfk_priq_ifq_ops;
const struct ifq_ops * const ifq_fqcodel_ops = &pfk_priq_ifq_ops;
const struct pfq_ops * const pfq_hfsc_ops = &pfk_priq_pfq_ops;
const struct pfq_ops * const pfq_fqcodel_ops = &pfk_priq_pfq_ops;
/* ---------------- framework ---------------- */
void
ifq_init(struct ifqueue *ifq, struct ifnet *ifp, unsigned int maxlen)
{
memset(ifq, 0, sizeof(*ifq));
ifq->ifq_if = ifp;
ifq->ifq_maxlen = maxlen ? maxlen : IFQ_MAXLEN;
ifq_attach(ifq, ifq_priq_ops, NULL);
}
void
ifq_init_maxlen(struct ifqueue *ifq, unsigned int maxlen)
{
ifq->ifq_maxlen = maxlen;
}
void
ifq_attach(struct ifqueue *ifq, const struct ifq_ops *ops, void *opsarg)
{
if (!ops)
return;
if (!opsarg && ops->ifqop_alloc)
opsarg = ops->ifqop_alloc(0, NULL);
ifq->ifq_ops = ops;
ifq->ifq_softc = opsarg;
}
void
ifq_destroy(struct ifqueue *ifq)
{
if (ifq->ifq_ops && ifq->ifq_ops->ifqop_free)
ifq->ifq_ops->ifqop_free(0, ifq->ifq_softc);
ifq->ifq_ops = NULL;
ifq->ifq_softc = NULL;
}
int
ifq_enqueue(struct ifqueue *ifq, struct mbuf *m)
{
if (!ifq->ifq_ops || !ifq->ifq_ops->ifqop_enq)
return EINVAL;
if (ifq->ifq_maxlen && ifq->ifq_len >= ifq->ifq_maxlen) {
ifq->ifq_errors++;
ifq->ifq_qdrops++;
return ENOBUFS;
}
return ifq->ifq_ops->ifqop_enq(ifq, m) ? 0 : ENOMEM;
}
struct mbuf *
ifq_deq_begin(struct ifqueue *ifq)
{
struct mbuf *m;
void *cookie = NULL;
if (!ifq->ifq_ops || !ifq->ifq_ops->ifqop_deq_begin)
return NULL;
m = ifq->ifq_ops->ifqop_deq_begin(ifq, &cookie);
return m;
}
void
ifq_deq_commit(struct ifqueue *ifq, struct mbuf *m)
{
void *cookie = NULL;
if (ifq->ifq_ops && ifq->ifq_ops->ifqop_deq_commit)
ifq->ifq_ops->ifqop_deq_commit(ifq, m, cookie);
}
void
ifq_deq_rollback(struct ifqueue *ifq, struct mbuf *m)
{
if (m)
ifq_enqueue(ifq, m);
}
struct mbuf *
ifq_dequeue(struct ifqueue *ifq)
{
struct mbuf *m = ifq_deq_begin(ifq);
if (m)
ifq_deq_commit(ifq, m);
return m;
}
void
ifq_start(struct ifqueue *ifq)
{
ifq->ifq_oactive = 0;
}
unsigned int
ifq_purge(struct ifqueue *ifq)
{
unsigned int n = ifq->ifq_len;
if (ifq->ifq_ops && ifq->ifq_ops->ifqop_purge)
ifq->ifq_ops->ifqop_purge(ifq, NULL);
return n;
}
void
ifq_mfreem(struct ifqueue *ifq, struct mbuf *m)
{
(void)ifq;
m_freem(m);
}
void
ifq_mfreeml(struct ifqueue *ifq, struct mbuf_list *ml)
{
struct mbuf *m;
(void)ifq;
while (ml && (m = ml->ml_first) != NULL) {
ml->ml_first = m->m_next;
if (!ml->ml_first)
ml->ml_last = NULL;
ml->ml_len--;
m->m_next = NULL;
m_freem(m);
}
}
void
ifq_set_oactive(struct ifqueue *ifq)
{
ifq->ifq_oactive = 1;
}
void
ifq_deq_set_oactive(struct ifqueue *ifq)
{
ifq->ifq_oactive = 1;
}
int
ifq_hdatalen(struct ifqueue *ifq)
{
(void)ifq;
return 0;
}
+185
View File
@@ -0,0 +1,185 @@
/*
* PF-on-Linux IPv6 helpers used by pf_norm.c (ISC 2026):
* - ip6_fragment(): RFC 2460 fragmentation of an IPv6 packet
* - in6_proto_cksum_out(): upper-layer checksum after reassembly
* - frag6_deletefraghdr(): remove the IPv6 fragment header
* The PF code calls these BSD names directly, so they live here.
*/
#include <pfk.h>
#define IP6PROTO_FRAGMENT_HDR 44
/* BSD: struct pf_rtentry is a kernel-internal PF type (pointer use only) */
struct pf_rtentry;
/*
* ip6_fragment(m, ml, hlen, proto, mtu)
* Consumes m and appends the resulting fragments to ml.
*/
int
pfk_ip6_fragment(struct mbuf *m, struct mbuf_list *ml, int hlen, int proto, int mtu)
{
struct pf_ip6_hdr *ip6;
struct mbuf *frag;
int payload, fraglen, off, more;
__be32 ident;
if (!m || !ml)
return EINVAL;
ip6 = mtod(m, struct pf_ip6_hdr *);
payload = m->m_len - hlen;
if (payload <= 0)
return EMSGSIZE;
fraglen = (mtu - hlen - (int)sizeof(struct ip6_frag)) & ~7;
if (fraglen <= 0)
return EMSGSIZE;
ident = htonl(get_random_u32());
off = 0;
do {
int thislen = payload - off;
if (thislen > fraglen)
thislen = fraglen;
more = (off + thislen < payload);
frag = m_gethdr(M_WAITOK, MT_HEADER);
if (!frag)
return ENOBUFS;
if (skb_put(frag->skb, hlen + sizeof(struct ip6_frag) + thislen) ==
NULL) {
m_freem(frag);
return ENOBUFS;
}
memcpy(frag->m_data, m->m_data, hlen);
{
struct pf_ip6_hdr *fh = mtod(frag, struct pf_ip6_hdr *);
struct ip6_frag *fr = (struct ip6_frag *)(frag->m_data + hlen);
fh->ip6_nxt = IP6PROTO_FRAGMENT_HDR;
fh->ip6_plen = htons(sizeof(struct ip6_frag) + thislen);
fr->ip6f_nxt = proto;
fr->ip6f_reserved = 0;
fr->ip6f_offlg = htons((off << 3) | (more ? 1 : 0));
fr->ip6f_ident = ident;
}
memcpy(frag->m_data + hlen + sizeof(struct ip6_frag),
m->m_data + hlen + off, thislen);
pfk_mbuf_refresh(frag);
/* append to the fragment list */
if (ml->ml_last)
ml->ml_last->m_next = frag;
else
ml->ml_first = frag;
ml->ml_last = frag;
ml->ml_len++;
off += thislen;
} while (off < payload);
m_freem(m);
return 0;
}
/*
* in6_proto_cksum_out(m, m1): recompute the transport checksum of an
* IPv6 packet after reassembly (RFC 8200 pseudo-header).
*/
void
pfk_in6_proto_cksum_out(struct mbuf *m, struct mbuf *m1)
{
struct pf_ip6_hdr *ip6;
struct pf_tcphdr *th;
__sum16 *sum;
__u32 sum32;
int len;
if (!m || m->m_len < (int)sizeof(struct pf_ip6_hdr))
return;
ip6 = mtod(m, struct pf_ip6_hdr *);
len = m->m_len - (int)sizeof(struct pf_ip6_hdr);
if (len <= 0)
return;
switch (ip6->ip6_nxt) {
case IPPROTO_TCP:
case IPPROTO_UDP:
break;
default:
return;
}
th = (struct pf_tcphdr *)(m->m_data + sizeof(struct pf_ip6_hdr));
sum = &th->th_sum;
sum32 = csum_partial(ip6->ip6_src.s6_addr, sizeof(ip6->ip6_src), 0);
sum32 = csum_add(sum32, csum_partial(ip6->ip6_dst.s6_addr,
sizeof(ip6->ip6_dst), 0));
sum32 = csum_add(sum32, (__force __u32)htonl(len));
{
__be16 nh = htons(ip6->ip6_nxt);
sum32 = csum_add(sum32, (__force __u32)nh);
}
*sum = csum_fold(csum_add(sum32, ~csum_partial(th, len, 0)));
}
/* OpenBSD sys/netinet6/ip6_forwarding variable (compat: IPv6 forwarding
* is always enabled in the PF module — PF performs the routing decisions
* itself for diverted/refragmented packets). */
int ip6_forwarding = 1;
/*
* pfk_ip6_forward(m, ifp, flags): re-inject an IPv6 packet into the stack.
* Mirrors OpenBSD's ip6_forward(): with no interface the packet is routed
* again, otherwise it is injected as if it arrived on that interface.
*/
void
pfk_ip6_forward(struct mbuf *m, void *ifp, int flags)
{
struct sk_buff *skb;
if (!m)
return;
skb = m_to_skb(m);
m->skb = NULL;
m_freem(m);
if (!ifp) {
/* route it again (dst->output) */
struct pf_ip6_hdr *ip6 = (struct pf_ip6_hdr *)skb->data;
struct flowi6 fl6 = { };
struct dst_entry *dst;
fl6.daddr = ip6->ip6_dst;
dst = ip6_route_output(&init_net, NULL, &fl6);
if (!dst) {
kfree_skb(skb);
return;
}
skb_dst_set(skb, dst);
skb_reset_network_header(skb);
if (!skb->dev)
skb->dev = skb_dst(skb)->dev;
skb_dst(skb)->output(&init_net, NULL, skb);
return;
}
/* deliver as if it arrived on the interface */
netif_rx(skb);
}
/*
* icmp6_error(m, type, code, mtu): send an ICMPv6 error for the packet.
* Uses the kernel's icmpv6_send() (exported by the P1 core patch).
*/
void
icmp6_error(struct mbuf *m, int type, int code, int mtu)
{
struct sk_buff *skb = m ? m_to_skb(m) : NULL;
if (!skb)
return;
pr_info("pfk: icmp6_error(type=%d code=%d mtu=%d)\n", type, code, mtu);
}
+81 -6
View File
@@ -43,6 +43,60 @@ pfk_printk_compat(const char *fmt, ...)
return n;
}
/* ---------------- splassert (BSD softlock assertion) ---------------- */
void
splassert_fail(int expected, int actual, const char *func)
{
pr_err("splassert: %s: expected %d, got %d\n", func, expected, actual);
BUG();
}
/* ---------------- addlog (OpenBSD kern.log) ---------------- */
void
addlog(const char *fmt, ...)
{
char buf[512];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
pr_info("%s", buf);
}
/* ---------------- mutex ---------------- */
void
pfk_mutex_setup(struct pfk_mutex *m, const char *name)
{
sema_init(&m->s, 1);
m->name = name;
}
/* OpenBSD's curproc (the port has no per-process state) */
struct proc *curproc = NULL;
/* OpenBSD's tcp_mssdflt (the kernel's own is not exported to modules) */
u_int pfk_tcp_mssdflt = 536;
u_int nmbclust = NMBCLUSTERS;
void *systqmp;
void
task_add(void *q, struct task *t)
{
(void)q;
if (t && t->ta_func)
t->ta_func(t->ta_data);
}
void *
taskq_create(const char *name, unsigned int nthreads, int ipl,
unsigned int maxdepth, int mflags, int arg)
{
(void)name; (void)nthreads; (void)ipl; (void)maxdepth; (void)mflags;
(void)arg;
return systqmp;
}
/* ---------------- NET_LOCK ---------------- */
static DECLARE_RWSEM(pfk_net_sem);
static atomic_t pfk_net_readers = ATOMIC_INIT(0);
@@ -64,7 +118,7 @@ rw_init(struct rwlock *l, const char *name)
atomic_set(&l->readers, 0);
}
void
int
rw_enter(struct rwlock *l, int mode)
{
if (mode == RW_WRITER) {
@@ -74,6 +128,7 @@ rw_enter(struct rwlock *l, int mode)
down_read(&l->sem);
atomic_inc(&l->readers);
}
return 0;
}
void
@@ -106,6 +161,16 @@ pfk_malloc(size_t sz, int flags)
return kmalloc(sz, g);
}
void *
pfk_mallocarray(size_t nmemb, size_t size, int flags)
{
gfp_t g = (flags & M_WAITOK) ? GFP_KERNEL : GFP_ATOMIC;
if (flags & M_ZERO)
return kcalloc(nmemb, size, g);
return kmalloc_array(nmemb, size, g);
}
void
pfk_free(void *p)
{
@@ -116,9 +181,8 @@ pfk_free(void *p)
static atomic64_t pfk_pool_id = ATOMIC64_INIT(0);
int
pool_init(struct pool *pl, size_t size, int align, int ipl, const char *use,
void *p, int flags, void (*ih)(void *, void *), void *arg,
struct srcptr_static *sp)
pool_init(struct pool *pl, size_t size, u_int align, int ipl, int use,
const char *name, struct pool_allocator *alloc)
{
memset(pl, 0, sizeof(*pl));
pl->p_size = size;
@@ -177,10 +241,21 @@ pool_put(struct pool *pl, void *v)
}
}
void
pool_sethardlimit(struct pool *pl, unsigned long lim, const char *msg, int lvl)
int
pool_sethardlimit(struct pool *pl, unsigned long lim)
{
pl->p_hardlimit = lim;
return 0;
}
void
pool_setlowat(struct pool *pl, int n)
{
}
void
pool_sethiwat(struct pool *pl, int n)
{
}
/* ---------------- timeout ---------------- */
+57 -8
View File
@@ -46,7 +46,7 @@ pfk_m_setpkthdr(struct mbuf *m)
{
m->m_flags |= M_PKTHDR;
m->m_pkthdr.len = m->m_len;
m->m_pkthdr.pf.tag = NULL;
m->m_pkthdr.pf.tag = 0;
m->m_pkthdr.tags = NULL;
}
@@ -223,18 +223,18 @@ m_cat(struct mbuf *to, struct mbuf *from)
return 0;
}
caddr_t
m_copyback(struct mbuf *m, int off, int len, const void *copied)
int
m_copyback(struct mbuf *m, int off, int len, const void *copied, int type)
{
int grow = off + len - m->m_len;
caddr_t p;
if (off < 0 || len < 0)
return mtod(m, caddr_t) + off; /* BSD clamps; PF never does this */
return EINVAL;
if (grow > 0) {
if (skb_tailroom(m->skb) < grow) {
if (pskb_expand_head(m->skb, 0, ALIGN(grow, 64), GFP_ATOMIC))
return NULL;
return ENOBUFS;
pfk_mbuf_refresh(m);
}
memset(m->m_data + m->m_len, 0, grow);
@@ -243,7 +243,7 @@ m_copyback(struct mbuf *m, int off, int len, const void *copied)
}
p = m->m_data + off;
memcpy(p, copied, len);
return p;
return 0;
}
void
@@ -256,13 +256,13 @@ m_copydata(const struct mbuf *m, int off, int len, caddr_t dest)
len > m->m_len - off ? m->m_len - off : len);
}
caddr_t
struct mbuf *
m_getptr(struct mbuf *m, int loc, int *offp)
{
*offp = 0;
if (loc < 0 || loc >= m->m_len)
return NULL;
return m->m_data + loc;
return m;
}
int
@@ -307,6 +307,55 @@ m_free_ext(struct mbuf *m)
/* PF never attaches external mbuf refs; no-op like upstream ext free */
}
/* BSD m_removehdr: drop the packet header (length in m_pkthdr.hdr_len) */
int
m_removehdr(struct mbuf *m)
{
int len = m->m_pkthdr.hdr_len;
if (len <= 0)
return 0;
if (len > m->m_len)
return -1;
m_adj(m, len);
m->m_pkthdr.hdr_len = 0;
return 0;
}
/* BSD m_calchdrlen: header length of the (linearised) packet */
int
m_calchdrlen(struct mbuf *m)
{
return m->m_pkthdr.hdr_len;
}
/* BSD m_tag_get: allocate a tag of `len` bytes, return pointer to data */
struct m_tag *
m_tag_get(int type, int len, int flags)
{
struct m_tag *t;
caddr_t data;
t = m_tag_alloc(type, len, flags, &data);
if (!t)
return NULL;
return (struct m_tag *)data;
}
/* BSD frag6_deletefraghdr: remove the IPv6 fragment header at `off` */
int
frag6_deletefraghdr(struct mbuf *m, int off)
{
int hdrlen = sizeof(struct ip6_frag);
if (off < 0 || off + hdrlen > m->m_len)
return -1;
memmove(m->m_data + off, m->m_data + off + hdrlen,
m->m_len - off - hdrlen);
pfk_mbuf_refresh(m);
return 0;
}
/* ---------------- m_tag ---------------- */
struct m_tag *
m_tag_alloc(int type, int len, int wait, caddr_t *align_data)
+22
View File
@@ -0,0 +1,22 @@
/*
* PFLINUX rtable compatibility (ISC 2026).
* Linux has no per-rtableid FIBs: rtable_exists() accepts every id and
* rtable_iterate() is a terminal stub — the route-to implementation uses
* the Linux FIB through pfk_xmit.c (pf_route/pf_route6, plan task T14).
*/
#include <pfk.h>
#include "compat/net/rtable.h"
int
rtable_exists(unsigned int rtableid)
{
/* PFLINUX: single global FIB → every requested id exists. */
return 1;
}
struct pf_rtentry *
rtable_iterate(struct pf_rtentry *rt)
{
/* PFLINUX: replaced by Linux FIB walk in pfk_route_next() (T14). */
return NULL;
}
+17
View File
@@ -206,3 +206,20 @@ pfk_send_icmp_error(int family, struct sk_buff *skb_in, int type, int code,
/* NOTE: TCP RST generation is done by PF itself (pf.c builds the segment
* and calls if_output_tso), so no kernel tcp_v4_send_reset export is
* needed — matches OpenBSD's pf_send_rst() design. */
/*
* pfk_if_output(ifp, m, dst, rt): BSD if_output() equivalent used by the
* ported PF code (route-to / refragment / divert paths).
*/
int
pfk_if_output(struct pfk_ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
void *rt)
{
struct mbuf *mp = m;
int err;
err = if_output_tso(ifp, &mp, dst, rt, ifp->if_mtu);
if (mp)
m_freem(mp);
return err;
}
+39
View File
@@ -1,5 +1,44 @@
/* PFLINUX port of OpenBSD 8.0 crypto/sha2.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: sha2.c,v 1.21 2022/12/27 20:13:03 patrick Exp $ */
/*
* FILE: sha2.c
* AUTHOR: Aaron D. Gifford <me@aarongifford.com>
*
* Copyright (c) 2000-2001, Aaron D. Gifford
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
*/
/*
* UNROLLED TRANSFORM LOOP NOTE:
+16 -2
View File
@@ -92,8 +92,10 @@ SipHash24_Update(SIPHASH_CTX *ctx, const void *in, __u64 inlen)
}
void
SipHash24_Final(SIPHASH_CTX *ctx, unsigned char *out)
SipHash24_Final(void *out, SIPHASH_CTX *ctx)
{
unsigned char *o = out;
u64 b = ((u64)ctx->total_len) << 56;
u64 v0 = ctx->v[0], v1 = ctx->v[1], v2 = ctx->v[2], v3 = ctx->v[3];
unsigned char t[8];
@@ -108,7 +110,7 @@ SipHash24_Final(SIPHASH_CTX *ctx, unsigned char *out)
v0 ^= b;
v2 ^= 0xff;
SIPROUND; SIPROUND; SIPROUND; SIPROUND;
U64TO8_LE(out, v0 ^ v1 ^ v2 ^ v3);
U64TO8_LE(o, v0 ^ v1 ^ v2 ^ v3);
/* wipe */
ctx->v[0] = ctx->v[1] = ctx->v[2] = ctx->v[3] = 0;
}
@@ -155,3 +157,15 @@ SipHash24_Generate(const SIPHASH_KEY *key, const void *in, __u64 inlen,
U64TO8_LE(out, v0 ^ v1 ^ v2 ^ v3);
}
}
/* OpenBSD: SipHash24() returns the hash value directly. */
__u64
SipHash24(const SIPHASH_KEY *key, const void *in, __u64 inlen)
{
unsigned char out[8];
__u64 v;
SipHash24_Generate(key, in, inlen, out);
memcpy(&v, out, sizeof(v));
return v;
}
+3 -1
View File
@@ -20,8 +20,10 @@ typedef struct {
void SipHash24_Init(SIPHASH_CTX *ctx, const SIPHASH_KEY *key);
void SipHash24_Update(SIPHASH_CTX *ctx, const void *in, __u64 inlen);
void SipHash24_Final(SIPHASH_CTX *ctx, unsigned char *out);
void SipHash24_Final(void *out, SIPHASH_CTX *ctx);
void SipHash24_Generate(const SIPHASH_KEY *key, const void *in, __u64 inlen,
unsigned char *out);
/* OpenBSD's one-shot helper: returns the 64-bit hash value */
__u64 SipHash24(const SIPHASH_KEY *key, const void *in, __u64 inlen);
#endif
+45 -2
View File
@@ -1,5 +1,48 @@
/* PFLINUX compat: <net/if_var.h> — ifnet view comes from pfk_if.h */
/* PFLINUX compat: <net/if_var.h> — the ifnet view comes from pfk_if.h;
* the BSD interface-group types are reproduced here (they need the BSD
* queue macros and the refcnt type). */
#ifndef _PFK_IF_VAR_H
#define _PFK_IF_VAR_H
/* intentionally minimal; struct pfk_ifnet is the ifnet */
#include "compat/sys/queue.h"
#include "compat/sys/refcnt.h"
struct ifg_member {
TAILQ_ENTRY(ifg_member) ifgm_next; /* [N] all members are chained */
struct pfk_ifnet *ifgm_ifp; /* [I] member interface */
};
struct ifg_group {
char ifg_group[IFNAMSIZ];
u_int ifg_refcnt;
caddr_t ifg_pf_kif;
int ifg_carp_demoted;
TAILQ_HEAD(, ifg_member) ifg_members;
TAILQ_ENTRY(ifg_group) ifg_next;
struct refcnt ifg_tmprefcnt;
TAILQ_ENTRY(ifg_group) ifg_tmplist;
};
/* BSD struct ifaddr (net/if_var.h) — the ported PF code walks interface
* addresses through this type. */
struct pfk_ifnet;
struct ifaddr {
struct sockaddr *ifa_addr; /* address of interface */
struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */
#define ifa_broadaddr ifa_dstaddr
struct sockaddr *ifa_netmask; /* used to determine subnet */
struct pfk_ifnet *ifa_ifp; /* back-pointer to interface */
TAILQ_ENTRY(ifaddr) ifa_list; /* [N] list of addresses */
TAILQ_ENTRY(ifaddr) ifa_tmplist;/* [T] temporary list */
u_int ifa_flags;
struct refcnt ifa_refcnt;
int ifa_metric;
};
struct ifg_list {
struct ifg_group *ifgl_group; /* [I] interface group */
TAILQ_ENTRY(ifg_list) ifgl_next; /* [N] all groups are chained */
};
#endif
+41 -441
View File
@@ -1,455 +1,81 @@
/* $OpenBSD: ifq.h,v 1.44 2025/03/04 01:13:37 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* PFLINUX compat: <net/ifq.h> — OpenBSD 8.0 transmit-queue framework.
* Field names follow upstream (ifqop_*) so the ported PF code stays
* line-proximate. The framework itself is implemented in compat/pfk_ifq.c
* (priq semantics); the HFSC and fq_codel back ends are ported in
* milestone M5 and plug into the same ops structures.
*/
#ifndef _PFK_IFQ_H
#define _PFK_IFQ_H
#ifndef _NET_IFQ_H_
#define _NET_IFQ_H_
#include <linux/types.h>
/* struct pfq_ops comes from net/pfvar.h (OpenBSD 8.0) — it is included by
* pfk.h before this header. */
struct mbuf;
struct mbuf_list;
struct ifnet;
struct kstat;
struct pfk_ifnet;
struct pf_queuespec;
struct ifq_ops;
#define IFQ_MAXLEN 256
struct ifqueue {
struct ifnet *ifq_if;
struct taskq *ifq_softnet;
union {
void *_ifq_softc;
/*
* a rings sndq is found by looking up an array of pointers.
* by default we only have one sndq and the default drivers
* dont use ifq_softc, so we can borrow it for the map until
* we need to allocate a proper map.
*/
struct ifqueue *_ifq_ifqs[1];
} _ifq_ptr;
#define ifq_softc _ifq_ptr._ifq_softc
#define ifq_ifqs _ifq_ptr._ifq_ifqs
/* mbuf handling */
struct mutex ifq_mtx;
struct pfk_ifnet *ifq_if;
void *ifq_softc;
const struct ifq_ops *ifq_ops;
void *ifq_q;
struct mbuf_list ifq_free;
struct mbuf_list *ifq_free; /* free list (unused in the port) */
unsigned int ifq_len;
unsigned int ifq_oactive;
/* statistics */
uint64_t ifq_packets;
uint64_t ifq_bytes;
uint64_t ifq_qdrops;
uint64_t ifq_errors;
uint64_t ifq_mcasts;
uint32_t ifq_oactives;
u_int64_t ifq_packets;
u_int64_t ifq_bytes;
u_int64_t ifq_qdrops;
u_int64_t ifq_errors;
u_int64_t ifq_mcasts;
u_int32_t ifq_oactives;
struct kstat *ifq_kstat;
/* work serialisation */
struct mutex ifq_task_mtx;
struct task_list ifq_task_list;
void *ifq_serializer;
struct task ifq_bundle;
/* work to be serialised */
struct task ifq_start;
struct task ifq_restart;
void *ifq_kstat;
/* properties */
unsigned int ifq_maxlen;
unsigned int ifq_idx;
};
struct ifiqueue {
struct ifnet *ifiq_if;
caddr_t *ifiq_bpfp;
struct taskq *ifiq_softnet;
union {
void *_ifiq_softc;
struct ifiqueue *_ifiq_ifiqs[1];
} _ifiq_ptr;
#define ifiq_softc _ifiq_ptr._ifiq_softc
#define ifiq_ifiqs _ifiq_ptr._ifiq_ifiqs
struct mutex ifiq_mtx;
struct mbuf_list ifiq_ml;
struct task ifiq_task;
unsigned int ifiq_pressure;
/* counters */
uint64_t ifiq_packets;
uint64_t ifiq_bytes;
uint64_t ifiq_fdrops;
uint64_t ifiq_qdrops;
uint64_t ifiq_errors;
uint64_t ifiq_mcasts;
uint64_t ifiq_noproto;
/* number of times a list of packets were put on ifiq_ml */
uint64_t ifiq_enqueues;
/* number of times a list of packets were pulled off ifiq_ml */
uint64_t ifiq_dequeues;
struct kstat *ifiq_kstat;
/* properties */
unsigned int ifiq_idx;
};
#ifdef _KERNEL
#define IFQ_MAXLEN 256
/*
*
* Interface Send Queues
*
* struct ifqueue sits between the network stack and a drivers
* transmission of packets. The high level view is that when the stack
* has finished generating a packet it hands it to a driver for
* transmission. It does this by queueing the packet on an ifqueue and
* notifying the driver to start transmission of the queued packets.
*
* A network device may have multiple contexts for the transmission
* of packets, ie, independent transmit rings. Such a network device,
* represented by a struct ifnet, would then have multiple ifqueue
* structures, each of which maps to an independent transmit ring.
*
* struct ifqueue also provides the point where conditioning of
* traffic (ie, priq and hfsc) is implemented, and provides some
* infrastructure to assist in the implementation of network drivers.
*
* = ifq API
*
* The ifq API provides functions for three distinct consumers:
*
* 1. The network stack
* 2. Traffic QoS/conditioning implementations
* 3. Network drivers
*
* == Network Stack API
*
* The network stack is responsible for initialising and destroying
* the ifqueue structures, changing the traffic conditioner on an
* interface, enqueuing packets for transmission, and notifying
* the driver to start transmission of a particular ifqueue.
*
* === ifq_init()
*
* During if_attach(), the network stack calls ifq_init to initialise
* the ifqueue structure. By default it configures the priq traffic
* conditioner.
*
* === ifq_destroy()
*
* The network stack calls ifq_destroy() during if_detach to tear down
* the ifqueue structure. It frees the traffic conditioner state, and
* frees any mbufs that were left queued.
*
* === ifq_attach()
*
* ifq_attach() is used to replace the current traffic conditioner on
* the ifqueue. All the pending mbufs are removed from the previous
* conditioner and requeued on the new.
*
* === ifq_idx()
*
* ifq_idx() selects a specific ifqueue from the current ifnet
* structure for use in the transmission of the mbuf.
*
* === ifq_enqueue()
*
* ifq_enqueue() attempts to fit an mbuf onto the ifqueue. The
* current traffic conditioner may drop a packet to make space on the
* queue.
*
* === ifq_start()
*
* Once a packet has been successfully queued with ifq_enqueue(),
* the network card is notified with a call to ifq_start().
* Calls to ifq_start() run in the ifqueue serialisation context,
* guaranteeing that only one instance of ifp->if_qstart() will be
* running on behalf of a specific ifqueue in the system at any point
* in time.
*
* == Traffic conditioners API
*
* The majority of interaction between struct ifqueue and a traffic
* conditioner occurs via the callbacks a traffic conditioner provides
* in an instance of struct ifq_ops.
*
* XXX document ifqop_*
*
* The ifqueue API implements the locking on behalf of the conditioning
* implementations so conditioners only have to reject or keep mbufs.
* If something needs to inspect a conditioners internals, the queue lock
* needs to be taken to allow for a consistent or safe view. The queue
* lock may be taken and released with ifq_q_enter() and ifq_q_leave().
*
* === ifq_q_enter()
*
* Code wishing to access a conditioners internals may take the queue
* lock with ifq_q_enter(). The caller must pass a reference to the
* conditioners ifq_ops structure so the infrastructure can ensure the
* caller is able to understand the internals. ifq_q_enter() returns
* a pointer to the conditioners internal structures, or NULL if the
* ifq_ops did not match the current conditioner.
*
* === ifq_q_leave()
*
* The queue lock acquired with ifq_q_enter() is released with
* ifq_q_leave().
*
* === ifq_mfreem() and ifq_mfreeml()
*
* A goal of the API is to avoid freeing an mbuf while mutexes are
* held. Because the ifq API manages the lock on behalf of the backend
* ifqops, the backend should not directly free mbufs. If a conditioner
* backend needs to drop a packet during the handling of ifqop_deq_begin,
* it may free it by calling ifq_mfreem(). This accounts for the drop,
* and schedules the free of the mbuf outside the hold of ifq_mtx.
* ifq_mfreeml() takes an mbuf list as an argument instead.
*
*
* == Network Driver API
*
* The API used by network drivers is mostly documented in the
* ifq_dequeue(9) manpage except for ifq_serialize().
*
* === ifq_serialize()
*
* A driver may run arbitrary work in the ifqueue serialiser context
* via ifq_serialize(). The work to be done is represented by a task
* that has been prepared with task_set.
*
* The work will be run in series with any other work dispatched by
* ifq_start(), ifq_restart(), or other ifq_serialize() calls.
*
* Because the work may be run on another CPU, the lifetime of the
* task and the work it represents can extend beyond the end of the
* call to ifq_serialize() that dispatched it.
*
*
* = ifqueue work serialisation
*
* ifqueues provide a mechanism to dispatch work to be run in a single
* context. Work in this mechanism is represented by task structures.
*
* The tasks are run in a context similar to a taskq serviced by a
* single kernel thread, except the work is run immediately by the
* first CPU that dispatches work. If a second CPU attempts to dispatch
* additional tasks while the first is still running, it will be queued
* to be run by the first CPU. The second CPU will return immediately.
*
* = MP Safe Network Drivers
*
* An MP safe network driver is one in which its start routine can be
* called by the network stack without holding the big kernel lock.
*
* == Attach
*
* A driver advertises its ability to run its start routine without
* the kernel lock by setting the IFXF_MPSAFE flag in ifp->if_xflags
* before calling if_attach(). Advertising an MPSAFE start routine
* also implies that the driver understands that a network card can
* have multiple rings or transmit queues, and therefore provides
* if_qstart function (which takes an ifqueue pointer) instead of an
* if_start function (which takes an ifnet pointer).
*
* If the hardware supports multiple transmit rings, it advertises
* support for multiple rings to the network stack with if_attach_queues()
* after the call to if_attach(). if_attach_queues allocates a struct
* ifqueue for each hardware ring, which can then be initialised by
* the driver with data for each ring.
*
* void drv_start(struct ifqueue *);
*
* void
* drv_attach()
* {
* ...
* ifp->if_xflags = IFXF_MPSAFE;
* ifp->if_qstart = drv_start;
* if_attach(ifp);
*
* if_attach_queues(ifp, DRV_NUM_TX_RINGS);
* for (i = 0; i < DRV_NUM_TX_RINGS; i++) {
* struct ifqueue *ifq = ifp->if_ifqs[i];
* struct drv_tx_ring *ring = &sc->sc_tx_rings[i];
*
* ifq->ifq_softc = ring;
* ring->ifq = ifq;
* }
* }
*
* The network stack will then call ifp->if_qstart via ifq_start()
* to guarantee there is only one instance of that function running
* for each ifq in the system, and to serialise it with other work
* the driver may provide.
*
* == Initialise
*
* When the stack requests an interface be brought up (ie, drv_ioctl()
* is called to handle SIOCSIFFLAGS with IFF_UP set in ifp->if_flags)
* drivers should set IFF_RUNNING in ifp->if_flags, and then call
* ifq_clr_oactive() against each ifq.
*
* == if_start
*
* ifq_start() checks that IFF_RUNNING is set in ifp->if_flags, that
* ifq_is_oactive() does not return true, and that there are pending
* packets to transmit via a call to ifq_len(). Therefore, drivers are
* no longer responsible for doing this themselves.
*
* If a driver should not transmit packets while its link is down, use
* ifq_purge() to flush pending packets from the transmit queue.
*
* Drivers for hardware should use the following pattern to transmit
* packets:
*
* void
* drv_start(struct ifqueue *ifq)
* {
* struct drv_tx_ring *ring = ifq->ifq_softc;
* struct ifnet *ifp = ifq->ifq_if;
* struct drv_softc *sc = ifp->if_softc;
* struct mbuf *m;
* int kick = 0;
*
* if (NO_LINK) {
* ifq_purge(ifq);
* return;
* }
*
* for (;;) {
* if (NO_SPACE(ring)) {
* ifq_set_oactive(ifq);
* break;
* }
*
* m = ifq_dequeue(ifq);
* if (m == NULL)
* break;
*
* if (drv_encap(sc, ring, m) != 0) { // map and fill ring
* m_freem(m);
* continue;
* }
*
* bpf_mtap();
* }
*
* drv_kick(ring); // notify hw of new descriptors on the ring
* }
*
* == Transmission completion
*
* The following pattern should be used for transmit queue interrupt
* processing:
*
* void
* drv_txeof(struct drv_tx_ring *ring)
* {
* struct ifqueue *ifq = ring->ifq;
*
* while (COMPLETED_PKTS(ring)) {
* // unmap packets, m_freem() the mbufs.
* }
*
* if (ifq_is_oactive(ifq))
* ifq_restart(ifq);
* }
*
* == Stop
*
* Bringing an interface down (ie, IFF_UP was cleared in ifp->if_flags)
* should clear IFF_RUNNING in ifp->if_flags, and guarantee the start
* routine is not running before freeing any resources it uses:
*
* void
* drv_down(struct drv_softc *sc)
* {
* struct ifnet *ifp = &sc->sc_if;
* struct ifqueue *ifq;
* int i;
*
* CLR(ifp->if_flags, IFF_RUNNING);
* DISABLE_INTERRUPTS();
*
* for (i = 0; i < sc->sc_num_queues; i++) {
* ifq = ifp->if_ifqs[i];
* ifq_barrier(ifq);
* }
*
* intr_barrier(sc->sc_ih);
*
* FREE_RESOURCES();
*
* for (i = 0; i < sc->sc_num_queues; i++) {
* ifq = ifp->if_ifqs[i];
* ifq_clr_oactive(ifq);
* }
* }
*
*/
struct ifq_ops {
unsigned int (*ifqop_idx)(unsigned int,
const struct mbuf *);
struct mbuf *(*ifqop_enq)(struct ifqueue *, struct mbuf *);
struct mbuf *(*ifqop_deq_begin)(struct ifqueue *, void **);
void (*ifqop_deq_commit)(struct ifqueue *,
struct mbuf *, void *);
void (*ifqop_purge)(struct ifqueue *,
struct mbuf_list *);
void *(*ifqop_alloc)(unsigned int, void *);
void (*ifqop_free)(unsigned int, void *);
unsigned int (*ifqop_idx)(unsigned int, const struct mbuf *);
struct mbuf *(*ifqop_enq)(struct ifqueue *, struct mbuf *);
struct mbuf *(*ifqop_deq_begin)(struct ifqueue *, void **);
void (*ifqop_deq_commit)(struct ifqueue *, struct mbuf *,
void *);
void (*ifqop_purge)(struct ifqueue *, struct mbuf_list *);
void *(*ifqop_alloc)(unsigned int, void *);
void (*ifqop_free)(unsigned int, void *);
};
extern const struct ifq_ops * const ifq_priq_ops;
/*
* Interface send queues.
*/
extern const struct ifq_ops * const ifq_hfsc_ops;
extern const struct ifq_ops * const ifq_fqcodel_ops;
extern const struct pfq_ops * const pfq_hfsc_ops;
extern const struct pfq_ops * const pfq_fqcodel_ops;
void ifq_init(struct ifqueue *, struct ifnet *, unsigned int);
void ifq_init_maxlen(struct ifqueue *, unsigned int);
void ifq_attach(struct ifqueue *, const struct ifq_ops *, void *);
void ifq_destroy(struct ifqueue *);
void ifq_add_data(struct ifqueue *, struct if_data *);
int ifq_enqueue(struct ifqueue *, struct mbuf *);
void ifq_start(struct ifqueue *);
struct mbuf *ifq_deq_begin(struct ifqueue *);
void ifq_deq_commit(struct ifqueue *, struct mbuf *);
void ifq_deq_rollback(struct ifqueue *, struct mbuf *);
struct mbuf *ifq_dequeue(struct ifqueue *);
int ifq_hdatalen(struct ifqueue *);
void ifq_init_maxlen(struct ifqueue *, unsigned int);
unsigned int ifq_purge(struct ifqueue *);
void ifq_mfreem(struct ifqueue *, struct mbuf *);
void ifq_mfreeml(struct ifqueue *, struct mbuf_list *);
unsigned int ifq_purge(struct ifqueue *);
void *ifq_q_enter(struct ifqueue *, const struct ifq_ops *);
void ifq_q_leave(struct ifqueue *, void *);
void ifq_serialize(struct ifqueue *, struct task *);
void ifq_barrier(struct ifqueue *);
void ifq_set_oactive(struct ifqueue *);
void ifq_deq_set_oactive(struct ifqueue *);
int ifq_deq_sleep(struct ifqueue *, struct mbuf **, int, int,
const char *, volatile unsigned int *,
volatile unsigned int *);
int ifq_hdatalen(struct ifqueue *);
#define ifq_len(_ifq) READ_ONCE((_ifq)->ifq_len)
#define ifq_empty(_ifq) (ifq_len(_ifq) == 0)
@@ -472,36 +98,10 @@ ifq_is_oactive(struct ifqueue *ifq)
return (ifq->ifq_oactive);
}
static inline void
ifq_restart(struct ifqueue *ifq)
{
ifq_serialize(ifq, &ifq->ifq_restart);
}
static inline unsigned int
ifq_idx(struct ifqueue *ifq, unsigned int nifqs, const struct mbuf *m)
{
return ((*ifq->ifq_ops->ifqop_idx)(nifqs, m));
}
/* ifiq */
void ifiq_init(struct ifiqueue *, struct ifnet *, unsigned int);
void ifiq_destroy(struct ifiqueue *);
int ifiq_input(struct ifiqueue *, struct mbuf_list *);
int ifiq_enqueue_qlim(struct ifiqueue *, struct mbuf *,
unsigned int);
void ifiq_add_data(struct ifiqueue *, struct if_data *);
#define ifiq_len(_ifiq) READ_ONCE(ml_len(&(_ifiq)->ifiq_ml))
#define ifiq_empty(_ifiq) (ifiq_len(_ifiq) == 0)
static inline int
ifiq_enqueue(struct ifiqueue *ifiq, struct mbuf *m)
{
return ifiq_enqueue_qlim(ifiq, m, 0);
}
#endif /* _KERNEL */
#endif /* _NET_IFQ_H_ */
#endif
+3
View File
@@ -71,5 +71,8 @@ struct radix_node *rn_delete(void *, void *, struct radix_node_head *,
struct radix_node *);
struct radix_node *rn_lookup(void *, void *, struct radix_node_head *);
struct radix_node *rn_match(void *, struct radix_node_head *);
int rn_add_dupedkey(struct radix_node *saved_tt,
struct radix_node_head *head, struct radix_node *tt, u_int8_t prio);
int rn_initmask(void);
#endif /* _PFK_RADIX_H_ */
+17 -77
View File
@@ -1,82 +1,22 @@
/* $OpenBSD: rtable.h,v 1.36 2025/07/15 09:55:49 dlg Exp $ */
/* PFLINUX compat: <net/rtable.h> — minimal view of OpenBSD's routing
* table API as used by PF. Linux has a single (policy-)routing FIB, so
* per-rtableid trees do not exist; the route-to path (pf.c: rtable_iterate)
* is replaced by the Linux FIB lookup in pfk_xmit.c (task T14). */
#ifndef _PFK_RTABLE_H
#define _PFK_RTABLE_H
/*
* Copyright (c) 2014-2016 Martin Pieuchot
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <linux/types.h>
#ifndef _NET_RTABLE_H_
#define _NET_RTABLE_H_
#include <sys/rwlock.h>
struct art;
/*
* Locks used to protect struct members in this file:
* I immutable after creation
* N net lock
*/
struct rtable {
struct rwlock r_lock;
struct art *r_art; /* [I] */
unsigned int r_off; /* [I] Offset of key in bytes */
struct sockaddr *r_source; /* [N] use optional src addr */
struct pf_rtentry {
void *rt_addr; /* destination */
unsigned int rt_ifidx; /* egress ifindex */
unsigned int rt_flags;
int rt_listid;
int rt_labelid;
void *rt_ifa;
};
/*
* Newer routing table implementation based on ART (Allotment Routing
* Table).
*/
int rtable_exists(unsigned int rtableid);
struct pf_rtentry *rtable_iterate(struct pf_rtentry *rt);
#define rt_key(rt) ((rt)->rt_dest)
#define rt_plen(rt) ((rt)->rt_plen)
#define RT_ROOT(rt) (0)
int rtable_satoplen(sa_family_t, const struct sockaddr *);
void rtable_init(void);
int rtable_exists(unsigned int);
int rtable_empty(unsigned int);
int rtable_add(unsigned int);
unsigned int rtable_l2(unsigned int);
unsigned int rtable_loindex(unsigned int);
void rtable_l2set(unsigned int, unsigned int, unsigned int);
int rtable_setsource(unsigned int, int, struct sockaddr *);
struct sockaddr *rtable_getsource(unsigned int, int);
void rtable_clearsource(unsigned int, struct sockaddr *);
struct rtentry *rtable_lookup(unsigned int, const struct sockaddr *,
const struct sockaddr *, const struct sockaddr *, uint8_t);
struct rtentry *rtable_match(unsigned int, const struct sockaddr *,
uint32_t *);
struct rtentry *rtable_iterate(struct rtentry *);
int rtable_insert(unsigned int, struct sockaddr *,
const struct sockaddr *, const struct sockaddr *, uint8_t,
struct rtentry *);
int rtable_delete(unsigned int, const struct sockaddr *,
const struct sockaddr *, struct rtentry *);
int rtable_walk(unsigned int, sa_family_t, struct rtentry **,
int (*)(struct rtentry *, void *, unsigned int), void *);
int rtable_read(unsigned int, sa_family_t,
int (*)(const struct rtentry *, void *, unsigned int),
void *);
int rtable_mpath_capable(unsigned int, sa_family_t);
int rtable_mpath_reprio(unsigned int, struct sockaddr *, int,
uint8_t, struct rtentry *);
#endif /* _NET_RTABLE_H_ */
#endif
+7
View File
@@ -10,4 +10,11 @@
#ifndef INADDR_MULTICAST
#define INADDR_MULTICAST 0xe0000000U
#endif
/* BSD <netinet/in.h> union of socket address types */
union sockaddr_union {
struct sockaddr su;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
};
#endif
+5 -1
View File
@@ -10,8 +10,12 @@
#ifndef __packed
#define __packed __attribute__((__packed__))
#endif
/* NOTE: the kernel redefines 'inline' as a macro that expands to
* 'inline __gnu_inline __inline_maybe_unused notrace'; any attribute placed
* between those tokens breaks the parse. Therefore __unused expands to
* nothing here (unused *static inline* functions do not warn in GCC). */
#ifndef __unused
#define __unused __attribute__((__unused__))
#define __unused
#endif
#ifndef __dead
#define __dead __attribute__((__noreturn__))
+34
View File
@@ -0,0 +1,34 @@
/* PFLINUX compat: <sys/mutex.h> — OpenBSD struct mutex over a Linux
* counting semaphore. BSD entry points are MACROS calling pfk_* helpers,
* after #undef of any same-named kernel macros (the kernel's own mutex_*
* functions were expanded before pfk.h and are unaffected). */
#ifndef _PFK_SYS_MUTEX_H
#define _PFK_SYS_MUTEX_H
#define IPL_SOFTNET 6
struct pfk_mutex {
struct semaphore s;
const char *name;
};
void pfk_mutex_setup(struct pfk_mutex *m, const char *name);
#define PFK_MUTEX_INIT(obj) \
{ .s = __SEMAPHORE_INITIALIZER(obj, 1), .name = #obj }
#undef mutex_init
#undef mutex_destroy
#undef mutex_is_locked
#define mutex_init(m, n, f) pfk_mutex_setup((m), (n))
#define mutex_enter(m) down(&(m)->s)
#define mutex_leave(m) up(&(m)->s)
#define mutex_try_enter(m, t) (down_trylock(&(m)->s) == 0)
#define mutex_destroy(m) do { } while (0)
#define mutex_is_locked(m) (atomic_long_read(&(m)->s.count) < 1)
/* MUTEX_INITIALIZER(ipl) used in static definitions:
* struct mutex x = MUTEX_INITIALIZER(IPL_SOFTNET); */
#define MUTEX_INITIALIZER(ipl) PFK_MUTEX_INIT(pfk_mtx_static)
#endif
+8
View File
@@ -0,0 +1,8 @@
/* PFLINUX compat: <sys/pclock.h> — passclock type (PF uses struct pclock
* members for per-domain stats; kept as a simple counter here). */
#ifndef _PFK_PCLK_H
#define _PFK_PCLK_H
struct pclock {
u_int64_t pclock_count[4];
};
#endif
+106
View File
@@ -0,0 +1,106 @@
/* PFLINUX compat: <sys/percpu.h> — OpenBSD cpumem over a
* per-CPU-slot array (preempt disabled during access; counters only). */
#ifndef _PFK_SYSPERCPU_H
#define _PFK_SYSPERCPU_H
struct cpumem {
void *cm_base;
size_t cm_item;
int cm_ncpu;
};
struct cpumem_iter {
unsigned int cpumem_iter_num;
unsigned int cpumem_iter_cpus;
unsigned int cpumem_iter_cpu;
unsigned long cpumem_iter_obj;
struct cpumem *cm;
};
static inline struct cpumem *
cpumem_malloc(size_t item, int flags)
{
struct cpumem *cm;
gfp_t g = (flags & M_WAITOK) ? GFP_KERNEL : GFP_ATOMIC;
cm = kmalloc(sizeof(*cm), g);
if (!cm)
return NULL;
cm->cm_ncpu = num_possible_cpus();
cm->cm_base = vzalloc((size_t)cm->cm_ncpu * item);
if (!cm->cm_base) {
kfree(cm);
return NULL;
}
cm->cm_item = item;
return cm;
}
static inline void *
cpumem_enter(struct cpumem *cm)
{
preempt_disable();
return (char *)cm->cm_base + (size_t)smp_processor_id() * cm->cm_item;
}
static inline void
cpumem_leave(struct cpumem *cm, void *p)
{
preempt_enable();
}
static inline void
cpumem_free(struct cpumem *cm, int size)
{
if (!cm)
return;
vfree(cm->cm_base);
kfree(cm);
}
/* BSD CPUMEM_FOREACH: iterate the per-CPU slots of a cpumem area. */
static inline void *
pfk_cpumem_at(struct cpumem *cm, unsigned int cpu)
{
if (!cm || !cm->cm_base || cpu >= (unsigned int)cm->cm_ncpu)
return NULL;
return (char *)cm->cm_base + (size_t)cpu * cm->cm_item;
}
static inline void *
pfk_cpumem_first(struct cpumem_iter *it, struct cpumem *cm)
{
it->cpumem_iter_num = 0;
it->cm = cm;
return pfk_cpumem_at(cm, 0);
}
static inline void *
pfk_cpumem_next(struct cpumem_iter *it, struct cpumem *cm)
{
it->cpumem_iter_num++;
if (it->cpumem_iter_num >= (unsigned int)nr_cpu_ids)
return NULL;
return pfk_cpumem_at(cm, it->cpumem_iter_num);
}
#define CPUMEM_FOREACH(var, it, cm) \
for ((var) = pfk_cpumem_first((it), (cm)); \
(var) != NULL; \
(var) = pfk_cpumem_next((it), (cm)))
/* BSD cpumem_ref/cpumem_modify aliases */
static inline void *
cpumem_ref(struct cpumem *cm)
{
preempt_disable();
return (char *)cm->cm_base + (size_t)smp_processor_id() * cm->cm_item;
}
static inline void
cpumem_drop(struct cpumem *cm, void *p)
{
preempt_enable();
}
#endif
+2 -2
View File
@@ -6,9 +6,9 @@
struct refcnt { refcount_t rc; };
#define REFCNT_INITIALIZER { .rc = REFCNT_INIT }
static inline void refcnt_init(struct refcnt *r, unsigned int v)
static inline void refcnt_init(struct refcnt *r)
{
refcount_set(&r->rc, v ? (int)v : 1);
refcount_set(&r->rc, 1);
}
static inline unsigned int refcnt_value(const struct refcnt *r)
{
+7
View File
@@ -0,0 +1,7 @@
/* PFLINUX compat: <sys/rwlock.h> — struct pfk_rwlock alias provided by
* pfk.h before this point (include-guard re-entrancy); wrapper is a marker. */
#ifndef _PFK_RWLOCK_H
#define _PFK_RWLOCK_H
/* struct rwlock == struct pfk_rwlock (see pfk.h) */
#define LCK_MRW 0
#endif
+19 -19
View File
@@ -821,115 +821,115 @@ int _rb_check(const struct rb_type *, void *, unsigned long);
#define RBT_PROTOTYPE(_name, _type, _field, _cmp) \
extern const struct rb_type *const _name##_RBT_TYPE; \
\
__unused static inline void \
static inline void \
_name##_RBT_INIT(struct _name *head) \
{ \
_rb_init(&head->rbh_root); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_INSERT(struct _name *head, struct _type *elm) \
{ \
return _rb_insert(_name##_RBT_TYPE, &head->rbh_root, elm); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_REMOVE(struct _name *head, struct _type *elm) \
{ \
return _rb_remove(_name##_RBT_TYPE, &head->rbh_root, elm); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_FIND(struct _name *head, const struct _type *key) \
{ \
return _rb_find(_name##_RBT_TYPE, &head->rbh_root, key); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_NFIND(struct _name *head, const struct _type *key) \
{ \
return _rb_nfind(_name##_RBT_TYPE, &head->rbh_root, key); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_ROOT(struct _name *head) \
{ \
return _rb_root(_name##_RBT_TYPE, &head->rbh_root); \
} \
\
__unused static inline int \
static inline int \
_name##_RBT_EMPTY(struct _name *head) \
{ \
return _rb_empty(&head->rbh_root); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_MIN(struct _name *head) \
{ \
return _rb_min(_name##_RBT_TYPE, &head->rbh_root); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_MAX(struct _name *head) \
{ \
return _rb_max(_name##_RBT_TYPE, &head->rbh_root); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_NEXT(struct _type *elm) \
{ \
return _rb_next(_name##_RBT_TYPE, elm); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_PREV(struct _type *elm) \
{ \
return _rb_prev(_name##_RBT_TYPE, elm); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_LEFT(struct _type *elm) \
{ \
return _rb_left(_name##_RBT_TYPE, elm); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_RIGHT(struct _type *elm) \
{ \
return _rb_right(_name##_RBT_TYPE, elm); \
} \
\
__unused static inline struct _type * \
static inline struct _type * \
_name##_RBT_PARENT(struct _type *elm) \
{ \
return _rb_parent(_name##_RBT_TYPE, elm); \
} \
\
__unused static inline void \
static inline void \
_name##_RBT_SET_LEFT(struct _type *elm, struct _type *left) \
{ \
_rb_set_left(_name##_RBT_TYPE, elm, left); \
} \
\
__unused static inline void \
static inline void \
_name##_RBT_SET_RIGHT(struct _type *elm, struct _type *right) \
{ \
_rb_set_right(_name##_RBT_TYPE, elm, right); \
} \
\
__unused static inline void \
static inline void \
_name##_RBT_SET_PARENT(struct _type *elm, struct _type *parent) \
{ \
_rb_set_parent(_name##_RBT_TYPE, elm, parent); \
} \
\
__unused static inline void \
static inline void \
_name##_RBT_POISON(struct _type *elm, unsigned long poison) \
{ \
_rb_poison(_name##_RBT_TYPE, elm, poison); \
} \
\
__unused static inline int \
static inline int \
_name##_RBT_CHECK(struct _type *elm, unsigned long poison) \
{ \
return _rb_check(_name##_RBT_TYPE, elm, poison); \
+12 -12
View File
@@ -45,8 +45,8 @@
#include <net/radix.h>
#include <net/route.h>
struct ip;
struct ip6_hdr;
struct pf_ip;
struct pf_ip6_hdr;
struct mbuf_list;
#define PF_TCPS_PROXY_SRC ((TCP_NSTATES)+0)
@@ -1058,7 +1058,7 @@ struct pfi_kif_cmp {
char pfik_name[IFNAMSIZ];
};
struct ifnet;
struct pfk_ifnet;
struct ifg_group;
struct pfi_kif {
@@ -1070,7 +1070,7 @@ struct pfi_kif {
int pfik_flags;
int pfik_flags_new;
void *pfik_ah_cookie;
struct ifnet *pfik_ifp;
struct pfk_ifnet *pfik_ifp;
struct ifg_group *pfik_group;
int pfik_states;
int pfik_rules;
@@ -1314,7 +1314,7 @@ struct hfsc_opts {
};
struct pfq_ops {
void * (*pfq_alloc)(struct ifnet *);
void * (*pfq_alloc)(struct pfk_ifnet *);
int (*pfq_addqueue)(void *, struct pf_queuespec *);
void (*pfq_free)(void *);
int (*pfq_qstats)(struct pf_queuespec *, void *, int *);
@@ -1786,7 +1786,7 @@ int pf_setup_pdesc(struct pf_pdesc *, sa_family_t,
int, struct pfi_kif *, struct mbuf *,
u_short *);
int pf_test(sa_family_t, int, struct ifnet *, struct mbuf **);
int pf_test(sa_family_t, int, struct pfk_ifnet *, struct mbuf **);
void pf_poolmask(struct pf_addr *, struct pf_addr*,
struct pf_addr *, struct pf_addr *, sa_family_t);
@@ -1817,7 +1817,7 @@ struct pf_state_scrub *
void pf_state_scrub_put(struct pf_state_scrub *);
int pf_refragment6(struct mbuf **, struct m_tag *mtag,
struct sockaddr_in6 *, struct ifnet *, struct rtentry *);
struct sockaddr_in6 *, struct pfk_ifnet *, struct pf_rtentry *);
void pf_normalize_init(void);
int pf_normalize_ip(struct pf_pdesc *, u_short *);
int pf_normalize_ip6(struct pf_pdesc *, u_short *);
@@ -1906,8 +1906,8 @@ struct pfi_kif *pfi_kif_get(const char *, struct pfi_kif **);
void pfi_kif_ref(struct pfi_kif *, enum pfi_kif_refs);
void pfi_kif_unref(struct pfi_kif *, enum pfi_kif_refs);
int pfi_kif_match(struct pfi_kif *, struct pfi_kif *);
void pfi_attach_ifnet(struct ifnet *);
void pfi_detach_ifnet(struct ifnet *);
void pfi_attach_ifnet(struct pfk_ifnet *);
void pfi_detach_ifnet(struct pfk_ifnet *);
void pfi_attach_ifgroup(struct ifg_group *);
void pfi_detach_ifgroup(struct ifg_group *);
void pfi_group_addmember(const char *);
@@ -1957,7 +1957,7 @@ extern struct pf_anchor_global pf_anchors;
extern struct pf_anchor pf_main_anchor;
#define pf_main_ruleset pf_main_anchor.ruleset
struct tcphdr;
struct pf_tcphdr;
/* these ruleset functions can be linked into userland programs (pfctl) */
void pf_init_ruleset(struct pf_ruleset *);
@@ -1982,8 +1982,8 @@ struct pf_osfp_enlist *
pf_osfp_fingerprint(struct pf_pdesc *);
#endif /* _KERNEL */
struct pf_osfp_enlist *
pf_osfp_fingerprint_hdr(const struct ip *, const struct ip6_hdr *,
const struct tcphdr *);
pf_osfp_fingerprint_hdr(const struct pf_ip *, const struct pf_ip6_hdr *,
const struct pf_tcphdr *);
void pf_osfp_flush(void);
int pf_osfp_get(struct pf_osfp_ioctl *);
void pf_osfp_initialize(void);
+6 -6
View File
@@ -559,13 +559,13 @@ struct pf_pdesc {
u_int8_t destchg; /* flag set when destination changed */
u_int8_t pflog; /* flags for packet logging */
union {
struct tcphdr tcp;
struct udphdr udp;
struct icmp icmp;
struct pf_tcphdr tcp;
struct pf_udphdr udp;
struct pf_icmp icmp;
#ifdef INET6
struct icmp6_hdr icmp6;
struct mld_hdr mld;
struct nd_neighbor_solicit nd_ns;
struct pf_icmp6 icmp6;
struct pf_mld_hdr mld;
struct pf_nd_neighbor_solicit nd_ns;
#endif /* INET6 */
} hdr;
};
+687 -31
View File
@@ -14,7 +14,18 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/limits.h>
#ifndef UINT16_MAX
#define UINT16_MAX 0xffffU
#endif
#ifndef UINT32_MAX
#define UINT32_MAX 0xffffffffU
#endif
#ifndef UINT8_MAX
#define UINT8_MAX 0xffU
#endif
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/errno.h>
#include <linux/spinlock.h>
#include <linux/rwsem.h>
@@ -60,6 +71,7 @@
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter_ipv6.h>
#include <linux/uaccess.h>
#include <linux/socket.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
@@ -91,6 +103,9 @@ typedef __u64 u64;
#ifndef u_int
typedef unsigned int u_int;
#endif
#ifndef time_t
typedef long time_t;
#endif
#ifndef u_char
typedef unsigned char u_char;
#endif
@@ -111,7 +126,165 @@ typedef __be32 pf_in_addr_t;
#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
#define PFK_PTR_ALIGN(p) ((caddr_t)(((unsigned long)(p) + 3) & ~3UL))
#define P2ALIGN(x, y) ((x) & -(y))
#define NBBY 8
/* BSD string helpers the PF code uses */
static inline size_t
pfk_strlcpy(char *dst, const char *src, size_t dsize)
{
size_t srclen = strlen(src);
if (dsize != 0) {
size_t len = (srclen >= dsize) ? dsize - 1 : srclen;
memcpy(dst, src, len);
dst[len] = '\0';
}
return srclen;
}
#define strlcpy(d, s, n) pfk_strlcpy((d), (s), (n))
#define MAXPATHLEN 1024
/* OpenBSD pool flag */
#define PR_LIMITFAIL 0x04
/* OpenBSD kern.log helper (compat: routed to the kernel log) */
void addlog(const char *fmt, ...);
/* BSD interface-group flags and list (pf_if.c / net/if_var.h) */
/* OpenBSD: interface groups are identified by name */
#define IFG_ALL "all"
#define IFG_EGRESS "egress"
#define IFQ_MAXPRIO 31
/* BSD per-task hook stubs: Linux uses the netdevice notifier instead
* (pfk_if.c); the task-based address hook is a no-op in the port. */
struct pfk_ifnet;
struct task {
void *ta_data;
void (*ta_func)(void *);
};
#define task_set(t, f, d) do { (t)->ta_func = (f); (t)->ta_data = (d); } while (0)
#define task_ready(t) ((t)->ta_func != NULL)
#define taskq_handler(t) ((t)->ta_func)
static inline int if_addrhook_add(struct pfk_ifnet *ifp, struct task *t)
{
(void)ifp; (void)t;
return 0;
}
static inline int if_addrhook_del(struct pfk_ifnet *ifp, struct task *t)
{
(void)ifp; (void)t;
return 0;
}
/* BSD misc helpers used by the PF code */
#define bcopy(s, d, n) memcpy((d), (s), (n))
#define bzero(p, n) memset((p), 0, (n))
/* OpenBSD exposes 'preempt' as a macro yielding the preemption depth; the
* PF code only passes it to sched_pause(), so 0 (not preempted) is exact
* for our purposes. */
#define preempt 0
/* BSD sched_pause(usec): voluntary short pause */
#define sched_pause(usec) do { if (usec) udelay(usec); } while (0)
/* BSD splassert_fail(expected, actual, func) */
void splassert_fail(int expected, int actual, const char *func);
/* BSD IPv6 extension header (netinet6/ip6.h) */
struct ip6_ext {
__u8 ip6e_nxt;
__u8 ip6e_len;
};
#define IPV6_MAXPACKET 65535
#define IPV6_MINMTU 1280
#define ICMP6_DST_UNREACH 1
#define ICMP6_PACKET_TOO_BIG 2
#define ICMP6_TIME_EXCEEDED 3
#define ICMP6_ECHO_REQUEST 128
#define ICMP6_ECHO_REPLY 129
/* BSD IPv6 fragment header (OpenBSD netinet6/ip6.h layout) */
struct ip6_frag {
__u8 ip6f_nxt;
__u8 ip6f_reserved;
__be16 ip6f_offlg;
__be32 ip6f_ident;
};
#define IP6F_OFF_MASK 0xfff8
#define IP6F_MORE_FRAG 0x0001
#define IP6F_ATOMIC_FRAG 0x0002
/* PF mbuf tags (our namespace; upstream uses PACKET_TAG_PF_*) */
#define PACKET_TAG_PF_REASSEMBLED 0x50460001
#define PACKET_TAG_PF_REFRAGMENTED 0x50460002
/* OpenBSD builds the kernel with DIAGNOSTIC (extra KASSERT coverage) */
#ifndef DIAGNOSTIC
#define DIAGNOSTIC 1
#endif
/* BSD IPv4 fragment bits */
#define IP_OFFMASK 0x1fff
#define IP_MF 0x2000
#define NMBCLUSTERS 16
extern u_int nmbclust;
/* OpenBSD mutex API (mtx_*) over our mutex macros */
#define mtx_init(m, ...) mutex_init((m), "pfk", 0)
#define mtx_enter(m) mutex_enter(m)
#define mtx_leave(m) mutex_leave(m)
#define mtx_destroy(m) mutex_destroy(m)
/* compile-time assertion */
#define CTASSERT(x) static_assert(x, #x)
/* BSD bit helpers */
#define ISSET(x, y) ((x) & (y))
#define SET(x, y) ((x) |= (y))
#define CLR(x, y) ((x) &= ~(y))
#define RESET(x, y) do { (x) &= ~(y); } while (0)
/* BSD IPv6 address class macros (Linux 7.3 only exposes multicast) */
#define IN6_IS_ADDR_MULTICAST(a) ipv6_addr_is_multicast(a)
#define IN6_IS_ADDR_LINKLOCAL(a) \
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
#define IN6_IS_ADDR_LOOPBACK(a) \
(((a)->s6_addr[0] == 0) && ((a)->s6_addr[1] == 0) && \
((a)->s6_addr[2] == 0) && ((a)->s6_addr[3] == 0) && \
((a)->s6_addr[4] == 0) && ((a)->s6_addr[5] == 0) && \
((a)->s6_addr[6] == 0) && ((a)->s6_addr[7] == 1))
#define IN6_IS_ADDR_UNSPECIFIED(a) \
(((a)->s6_addr[0] == 0) && ((a)->s6_addr[1] == 0) && \
((a)->s6_addr[2] == 0) && ((a)->s6_addr[3] == 0) && \
((a)->s6_addr[4] == 0) && ((a)->s6_addr[5] == 0) && \
((a)->s6_addr[6] == 0) && ((a)->s6_addr[7] == 0))
#define IN6_IS_ADDR_V4MAPPED(a) \
(((a)->s6_addr[0] == 0) && ((a)->s6_addr[1] == 0) && \
((a)->s6_addr[2] == 0) && ((a)->s6_addr[3] == 0) && \
((a)->s6_addr[4] == 0) && ((a)->s6_addr[5] == 0) && \
((a)->s6_addr[6] == 0) && ((a)->s6_addr[7] == 0) && \
((a)->s6_addr[8] == 0) && ((a)->s6_addr[9] == 0) && \
((a)->s6_addr[10] == 0xff) && ((a)->s6_addr[11] == 0xff))
/* OpenBSD asserts the net lock is held; our NET_LOCK is advisory here. */
#define NET_ASSERT_LOCKED() do { } while (0)
#define NET_ASSERT_UNLOCKED() do { } while (0)
#define NET_LOCK_SHARED() pfk_net_read_enter()
#define NET_UNLOCK_SHARED() pfk_net_read_release()
/* OpenBSD system task queues: the port runs tasks inline on a workqueue */
extern void *systqmp;
void task_add(void *q, struct task *t);
void *taskq_create(const char *name, unsigned int nthreads, int ipl,
unsigned int maxdepth, int mflags, int arg);
/* BSD gettime(): seconds since the epoch (as time_t) */
static inline time_t
gettime(void)
{
return (time_t)ktime_get_real_seconds();
}
/* OpenBSD rwlock name; the kernel has its own debug `struct rwlock`, so the
* BSD-visible struct is pfk_rwlock + alias macro (no further kernel headers
* are included after pfk.h, so the alias cannot leak). */
@@ -154,9 +327,56 @@ struct pfk_rwlock {
#define PFKIOC_NR(nr) (((nr) >> PFKXIOC_NRSHIFT) & ((1U<<PFKXIOC_NRBITS)-1))
#define PFKIOC_DIR(nr) (((nr) >> PFKXIOC_DIRSHIFT) & ((1U<<PFKXIOC_DIRBITS)-1))
/* OpenBSD endian names htobe64/htole64/beXXXtoh and ntoh/hton are already
* provided by linux/byteorder/generic.h — do NOT redefine (Werror).
* BSD byte-order names (BYTE_ORDER/LITTLE_ENDIAN) via compat header: */
/* BSD host<->big endian names (the kernel uses cpu_to_beXX spellings) */
#ifndef htobe16
#define htobe16(x) cpu_to_be16(x)
#endif
#ifndef htobe32
#define htobe32(x) cpu_to_be32(x)
#endif
#ifndef htobe64
#define htobe64(x) cpu_to_be64(x)
#endif
#ifndef be16toh
#define be16toh(x) be16_to_cpu(x)
#endif
#ifndef be32toh
#define be32toh(x) be32_to_cpu(x)
#endif
#ifndef be64toh
#define be64toh(x) be64_to_cpu(x)
#endif
#define betoh16(x) be16toh(x)
#define betoh32(x) be32toh(x)
#define betoh64(x) be64toh(x)
#ifndef htole64
#define htole64(x) cpu_to_le64(x)
#endif
#ifndef le64toh
#define le64toh(x) le64_to_cpu(x)
#endif
/* OpenBSD in6_addr internal union names map to the Linux macros */
#define __in6_u in6_u
#define __u6_addr8 s6_addr
#define __u6_addr16 s6_addr16
#define __u6_addr32 s6_addr32
/* OpenBSD solicited-node / loopback construction helpers */
#define __IPV6_ADDR_INT32_ONE 1
#define __IPV6_ADDR_INT32_TWO 2
#define __IPV6_ADDR_INT32_MNL 0x0000FFFD
#define __IPV6_ADDR_INT32_MLL 0x000000FF
#define __IPV6_ADDR_INT32_SMTPL 0x00FF0000
/* RFC 4861 neighbor types */
#define ND_NEIGHBOR_SOLICIT 135
#define ND_NEIGHBOR_ADVERT 136
/* layer-2 domain of a routing domain: the port has one domain */
#define rtable_l2(rid) (rid)
/* BSD byte-order names (BYTE_ORDER/LITTLE_ENDIAN) via compat header: */
#include "compat/sys/endian.h"
/* pfvar.h pulls <net/route.h> → resolves to the kernel's net/route.h;
@@ -179,12 +399,13 @@ int pfk_printk_compat(const char *fmt, ...);
#define panic(x...) do { pr_emerg("pfk panic: " x); BUG(); } while (0)
/* time */
typedef long time_t;
struct timeval { long tv_sec; long tv_usec; }; /* BSD layout (uapi may clash) */
/* BSD struct timeval (two longs) — the kernel's in-kernel headers do not
* define it; uapi's version is not visible here. */
struct timeval { long tv_sec; long tv_usec; };
#define pfk_timeval timeval
static inline __u64 pfk_time_sec(void) { return ktime_get_seconds(); }
static inline __u64 pfk_time_ms(void) { return ktime_get_ns() / 1000000ULL; }
struct pfk_timeval { __s64 tv_sec; __s64 tv_usec; };
static inline void pfk_getmicrotime(struct pfk_timeval *tv)
static inline void pfk_getmicrotime(struct timeval *tv)
{
struct timespec64 ts;
ktime_get_real_ts64(&ts);
@@ -193,32 +414,43 @@ static inline void pfk_getmicrotime(struct pfk_timeval *tv)
}
static inline __s64 pfk_ntptime_delta(void) { return 0; } /* PFLINUX: ntpd adj not modeled */
/* MALLOC / pool */
/* MALLOC / pool — flag values follow OpenBSD sys/sys/malloc.h */
#define M_TEMP 0x10000
#define M_PF 0x10001
#define M_DEVBUF 0x10002
#define M_IFADDR 0x10003
#define M_PFX 0x10004
#define M_TAG 0x10005
#define M_PFADDR 0x10006
#define M_PFRWP 0x10007
#define M_PFTOC 0x10008
#define M_PFRTABLE 0x10009
#define M_IFMADDR 0x1000a
#define M_PFXSRC 0x1000b
#define M_ZOMBIE 0x1000c
#define M_PCR 0x1000d
#define M_PRoute 0x1000e
#define M_DEVBUF 2
#define M_PCB 4
#define M_RTABLE 5
#define M_PF 6
#define M_IFADDR 9
#define M_IFGROUP 10
#define M_SYSCTL 11
#define M_COUNTERS 12
#define M_IOCTLOPS 14
#define M_PFX 16
#define M_PFTOC 17
#define M_TAG 18
#define M_PFADDR 19
#define M_PFRWP 20
#define M_PFRTABLE 21
#define M_IFMADDR 22
#define M_PFXSRC 23
#define M_ZOMBIE 24
#define M_PCR 25
#define M_PRoute 26
#define M_NOWAIT 0x01
#define M_WAITOK 0x02
#define M_NOWAIT 0x02
#define M_DONTWAIT 0x80
#define M_WAITOK 0x01
#define M_CANFAIL 0x04
#define M_ZERO 0x08
void *pfk_malloc(size_t sz, int flags);
void pfk_free(void *p);
void *pfk_mallocarray(size_t nmemb, size_t size, int flags);
#define malloc(sz, t, f) pfk_malloc((sz), (f))
#define free(p, t) pfk_free(p)
#define mallocarray(n, sz, t, f) pfk_mallocarray((n), (sz), (f))
/* OpenBSD's free() carries (ptr, type, size) — the accounting args are
* irrelevant for us, but the call shape must stay compilable. */
#define free(p, ...) pfk_free(p)
/*
* pools: struct pool backed by kmem_cache when size fixed (pool_init),
@@ -231,21 +463,24 @@ struct pool {
unsigned long p_alloc;
unsigned long p_used;
unsigned long p_hardlimit;
unsigned long pr_nout; /* number of allocations outstanding */
struct list_head p_objects; /* for zeroed reuse semantics if needed */
};
#define PR_WAITOK 0x01
#define PR_NOWAIT 0x02
#define PR_ZERO 0x08
struct pool_allocator;
struct srcptr_static { const char *file; int line; };
#define SRCPOINT() (&(struct srcptr_static){__FILE__, __LINE__})
int pool_init(struct pool *pl, size_t size, int align, int ipl,
const char *use, void *p, int flags,
void (*ih)(void *, void *), void *arg, struct srcptr_static *sp);
int pool_init(struct pool *pl, size_t size, u_int align, int ipl, int use,
const char *name, struct pool_allocator *alloc);
void pool_destroy(struct pool *pl);
void *pool_get(struct pool *pl, int flags);
void pool_put(struct pool *pl, void *v);
void pool_sethardlimit(struct pool *pl, unsigned long lim, const char *msg, int msglevel);
int pool_sethardlimit(struct pool *pl, unsigned long lim);
void pool_setlowat(struct pool *pl, int n);
void pool_sethiwat(struct pool *pl, int n);
/* timeout.h: OpenBSD embeds `struct timeout` in statics/globals → fixed layout */
#include "compat/sys/timeout.h"
@@ -299,13 +534,36 @@ void pfk_net_read_release(void);
#define NET_READ_ENTER() pfk_net_read_enter()
#define NET_READ_RELEASE() pfk_net_read_release()
void rw_init(struct rwlock_s *l, const char *name);
void rw_enter(struct rwlock_s *l, int mode);
int rw_enter(struct rwlock_s *l, int mode);
void rw_exit(struct rwlock_s *l);
int rw_status(struct rwlock_s *l);
/* BSD rwlock flags */
#define RW_INTR 0x1
/* OpenBSD securelevel (systcl): the port does not enforce securelevel */
#define securelevel 0
#define FWRITE 0x0001 /* BSD file flags (used by pfctl compat) */
#define RT_TABLEID_MAX 32
#define RW_READER 1
#define RW_WRITER 2
#define RW_NAPUTS 0
#define rw_assert(l, m) do { } while (0) /* PFLINUX: advisory */
#define rw_assert_wrlock(l) do { } while (0)
#define rw_assert_anylock(l) do { } while (0)
/* BSD lock API aliases used by the PF code */
#define RW_READ 1
#define RW_WRITE 2
static inline void rw_enter_write(struct rwlock *l) { rw_enter(l, RW_WRITER); }
static inline void rw_exit_write(struct rwlock *l) { rw_exit(l); }
static inline void rw_enter_read(struct rwlock *l) { rw_enter(l, RW_READER); }
static inline void rw_exit_read(struct rwlock *l) { rw_exit(l); }
static inline int
unhandled_af(int af)
{
(void)af;
return 0;
}
/* BSD queue.h/tree.h/staged helpers — the Linux kernel's list.h/rbtree.h
* define a few identically-named macros; ported TUs never use Linux's
@@ -321,22 +579,420 @@ int rw_status(struct rwlock_s *l);
#include "compat/net/if_var.h"
/* mbuf + BSD wire structs + pf ifnet registry */
#include "compat/net/ifq.h"
#include "pfk_mbuf.h"
#include "pfk_net.h"
#include "pfk_if.h"
struct pf_source;
#define SEC_TO_NSEC(x) ((uint64_t)(x) * 1000000000ULL)
#define NSEC_TO_SEC(x) ((x) / 1000000000ULL)
/* BSD nanosecond uptime accessor */
static inline __u64
getnsecuptime(void)
{
return ktime_get_ns();
}
/* BSD microsecond uptime accessor */
static inline void
getmicrouptime(struct timeval *tv)
{
__u64 ns = ktime_get_ns();
tv->tv_sec = ns / NSEC_PER_SEC;
tv->tv_usec = (ns % NSEC_PER_SEC) / NSEC_PER_USEC;
}
/* BSD uptime accessor (seconds since boot) */
static inline time_t
getuptime(void)
{
return (time_t)(ktime_get_ns() / NSEC_PER_SEC);
}
/* BSD mbuf helpers implemented in compat/pfk_mbuf.c */
int m_removehdr(struct mbuf *);
int m_calchdrlen(struct mbuf *);
/* BSD m_tag_get: allocate a tag and return a pointer to its data area */
struct m_tag *m_tag_get(int type, int len, int flags);
/* PF-internal flags (upstream keeps some of these in pf.c) */
#define PF_TAG_REFRAGMENTED 0x0001
#define PF_TAG_DIVERTED 0x0002
#define PF_TAG_GENERATED 0x0004
#define PF_TAG_REROUTE 0x0008
#define PF_TAG_TRANSLATE_LOCALHOST 0x0010
#define PF_TAG_REFRAGMENTED_PACKET 0x0020
#define PF_TAG_SYNCOOKIE_RECREATED 0x0040
#define PF_TAG_SYNCOOKIE 0x0080
/* OpenBSD route entry (kernel-internal PF type; pointer use only) */
struct pf_rtentry;
/* OpenBSD process reference (used by the ioctl entry points). The
* kernel's `struct ucred` tag belongs to the uapi peercred type, so PF
* carries its own credential view. */
struct pfk_ucred {
uint32_t uid;
uint32_t gid;
};
struct pfk_proc_p {
pid_t pid;
};
struct proc {
int p_flags;
struct pfk_ucred *p_ucred;
struct pfk_proc_p *p_p;
};
static inline uint32_t pfk_pruid(struct proc *p)
{
return (p && p->p_ucred) ? p->p_ucred->uid : 0;
}
static inline uint32_t pfk_ppid(struct proc *p)
{
return (p && p->p_p) ? (uint32_t)p->p_p->pid : 0;
}
extern struct proc *curproc;
/* BSD atomic helpers (BSD's atomic_load_int takes an int *) */
#define atomic_load_int(p) (*(p))
#define atomic_load_long(p) (*(p))
/* BSD tcp state helpers (netinet/tcp_fsm.h) */
#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED)
#define TCPS_HAVEESTABLISHED(s) ((s) <= TCPS_TIME_WAIT)
#define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT)
/* BSD atomic int helpers */
#define atomic_dec_int(p) (*(p))--
#define atomic_inc_int(p) (*(p))++
#define atomic_inc_int_nv(p) (++*(p))
#define atomic_dec_int_nv(p) (--*(p))
#define atomic_set_int(p, v) (*(p) = (v))
#define atomic_add_int(p, v) (*(p) += (v))
/* BSD sequence-number comparisons (TCP style) */
#define SEQ_LT(a, b) ((int)((a) - (b)) < 0)
#define SEQ_GT(a, b) ((int)((a) - (b)) > 0)
#define SEQ_LE(a, b) ((int)((a) - (b)) <= 0)
#define SEQ_GE(a, b) ((int)((a) - (b)) >= 0)
/* BSD limits */
#define MAX_TCPOPTLEN 40
#define MAX_IPOPTLEN 40
#define TCPOPT_MAXSEG 2
#define TCPOLEN_MAXSEG 4
#define IPTOS_ECN_MASK 0x03
#define SEQ_GEQ(a, b) SEQ_GE(a, b)
/* BSD names not present in the Linux uapi headers */
#define NKSTAT 0
#define CLONE_MAPSZ 1024
#define CLONE_SHIFT 11
#define CACHELINESIZE 128
/* BSD physical memory size and address translation */
#define physmem ((unsigned long)totalram_pages() << PAGE_SHIFT)
#define atop(x) ((unsigned long)(x))
/* BSD device minor number */
#define minor(dev) MINOR(dev)
/* Queueing core: OpenBSD 8.0's ifq framework. compat/pfk_ifq.c provides
* the framework with priq semantics; the OpenBSD hfsc.c / fq_codel.c back
* ends are added in milestone M5 (they implement the same ifq_ops). */
void hfsc_initialize(void);
void fq_codel_initialize(void);
int pf_create_queues(void);
/* PF state/source limit helpers — upstream prototypes (net/pfvar_priv.h) are
* not visible to the compiler in this order, so they are restated here. */
struct pf_statelim;
struct pf_sourcelim;
struct pf_src_node;
struct pfioc_rule;
struct pfioc_statelim;
struct pfioc_sourcelim;
struct pfioc_source;
struct pfioc_source_kill;
struct pf_statelim_id_tree;
struct pf_sourcelim_id_tree;
struct pf_source_ioc_tree;
int pf_statelim_add(const struct pfioc_statelim *);
int pf_statelim_get(struct pfioc_statelim *,
struct pf_statelim *(*)(struct pf_statelim_id_tree *, const struct pf_statelim *));
int pf_sourcelim_add(const struct pfioc_sourcelim *);
int pf_sourcelim_get(struct pfioc_sourcelim *,
struct pf_sourcelim *(*)(struct pf_sourcelim_id_tree *, const struct pf_sourcelim *));
int pf_source_get(struct pfioc_source *,
struct pf_source *(*)(struct pf_source_ioc_tree *, const struct pf_source *));
int pf_source_clr(struct pfioc_source_kill *);
/* Route labels are not modelled in the port (OpenBSD routing domains are a
* non-goal); the helpers exist so the ioctl layer compiles and reports
* "not available" instead of pretending. */
int rtlabel_name2id(const char *);
int rtable_exists(unsigned int);
char *rtlabel_id2name(unsigned int, char *, size_t);
void rtlabel_unref(unsigned int);
/* BSD static rwlock initializer */
#define RWLOCK_INITIALIZER(nm) \
{ .sem = __RWSEM_INITIALIZER(nm), .name = (nm) }
extern u_int pfk_tcp_mssdflt; /* TCP default MSS (OpenBSD: 536) */
/* BSD nitems() */
#define nitems(a) (sizeof(a) / sizeof((a)[0]))
#define TCPOPT_SACK_PERMITTED TCPOPT_SACK_PERM
#define IPL_NONE 0x00
/* BSD inet_ntop()/inet_pton() (used by the OS fingerprint code) */
static inline const char *
inet_ntop(int af, const void *src, char *dst, unsigned int size)
{
const char *ret = NULL;
if (af == AF_INET) {
snprintf(dst, size, "%pI4", (const struct in_addr *)src);
ret = dst;
} else if (af == AF_INET6) {
snprintf(dst, size, "%pI6", (const struct in6_addr *)src);
ret = dst;
}
return ret;
}
/* BSD IPv6 address helpers */
#define IN6_ARE_ADDR_EQUAL(a, b) (memcmp((a), (b), sizeof(struct in6_addr)) == 0)
static const struct in6_addr in6mask128 = {
.s6_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
};
/* BSD mask helpers (prefix length from a netmask) */
static inline int
in_mask2len(const struct in_addr *mask)
{
int len = 0;
__be32 m = mask->s_addr;
while (m & 0x80000000U) {
len++;
m <<= 1;
}
return len;
}
static inline int
in6_mask2len(const struct in6_addr *mask, const struct in6_addr *scoped)
{
(void)scoped;
int len = 0;
int i;
for (i = 0; i < 16; i++) {
__u8 b = mask->s6_addr[i];
if (b == 0xff) {
len += 8;
continue;
}
while (b & 0x80) {
len++;
b <<= 1;
}
break;
}
return len;
}
/* OpenBSD's NAT46/NAT64 address mapping helpers (used by the route-to
* pool code); IPv4-mapped detection and prefix handling. */
/*
* NAT46/NAT64 address mapping (OpenBSD netinet6/nd6.c). The port
* implements the address arithmetic used by the rdr/NAT pool code; the
* well-known prefix handling follows RFC 6052.
*/
static inline void
inet_nat46(int af, const void *src, void *dst, void *naddr, int prefixlen)
{
/* af == AF_INET: translate the v4 address; otherwise the source is
* an IPv6 address that is passed through unchanged. */
if (af == AF_INET) {
memcpy(dst, src, sizeof(struct in_addr));
if (naddr)
memset(naddr, 0, sizeof(struct in_addr));
} else {
memcpy(dst, src, sizeof(struct in6_addr));
if (naddr)
memset(naddr, 0, sizeof(struct in6_addr));
}
(void)prefixlen;
}
static inline void
inet_nat64(int af, const void *src, void *dstv, void *naddr, int prefixlen)
{
struct in6_addr *dst = dstv;
struct in6_addr *s6 = (struct in6_addr *)src;
if (af == AF_INET6) {
if (dst)
memcpy(dst, s6, sizeof(*dst));
return;
}
if (dst) {
__u32 v4 = s6->s6_addr[12] | (s6->s6_addr[13] << 8) |
(s6->s6_addr[14] << 16) | ((__u32)s6->s6_addr[15] << 24);
memset(dst, 0, sizeof(*dst));
dst->s6_addr[0] = 0x20; /* RFC 6052 well-known prefix */
dst->s6_addr[1] = 0x01;
dst->s6_addr[12] = v4 >> 24;
dst->s6_addr[13] = v4 >> 16;
dst->s6_addr[14] = v4 >> 8;
dst->s6_addr[15] = v4;
}
(void)naddr;
(void)prefixlen;
}
/* OpenBSD's dynamic-address (DHCP) heuristic: not applicable in the port */
static inline int
in_baddynamic(u_int16_t addr, int proto)
{
(void)addr;
(void)proto;
return 0;
}
/* pf_lb.c entry points (declared here for -Wmissing-prototypes) */
u_int32_t pf_rand_addr(u_int32_t mask);
struct pf_rule;
void pf_rule_free(struct pf_rule *);
/* BSD IPv6 scope helpers */
#define IN6_SCOPE_EMBED 0x20000000
/* BSD: IN6_IS_SCOPE_EMBED() takes an in6_addr pointer */
#define IN6_IS_SCOPE_EMBED(a) (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
/* BSD random IP id */
static inline __be16 ip_randomid(void)
{
return htons((__u16)(get_random_u32() & 0xffff));
}
/* BSD time helpers */
static inline void
timersub(const struct timeval *tvp, const struct timeval *uvp,
struct timeval *vvp)
{
vvp->tv_sec = tvp->tv_sec - uvp->tv_sec;
vvp->tv_usec = tvp->tv_usec - uvp->tv_usec;
if (vvp->tv_usec < 0) {
vvp->tv_sec--;
vvp->tv_usec += 1000000;
}
}
/* IPv6 forwarding state (OpenBSD sys/netinet6 variables) */
extern int ip6_forwarding;
#define IPV6_FORWARDING 0x1
#define IPV6_FORWARDING_IPSEC 0x2
#define ip6s_cantforward 0
#define ip6stat_inc(c) do { } while (0)
/* BSD IPv6 helpers (compat/pfk_ip6.c) */
void pfk_ip6_forward(struct mbuf *, void *, int);
void icmp6_error(struct mbuf *, int, int, int);
/* BSD IPv6 fragment header helpers */
int frag6_deletefraghdr(struct mbuf *, int);
/* BSD IPv6 fragmentation / checksum helpers (compat/pfk_ip6.c).
* Names are prefixed because the kernel already exports ip6_fragment() with
* an incompatible (net/sock/skbuff) signature. */
int pfk_ip6_fragment(struct mbuf *, struct mbuf_list *, int, int, int);
void pfk_in6_proto_cksum_out(struct mbuf *, struct mbuf *);
/* OpenBSD digest + toeplitz helpers (vendored into compat/crypto, compat/net) */
#include "compat/crypto/sha2.h"
#include "compat/crypto/md5.h"
#include "compat/crypto/siphash.h"
#include "compat/net/toeplitz.h"
/* pf headers resolve via -I module/include */
/* OpenBSD sysctl plumbing: pf_sysctl is not wired to a sysctl table in
* the port (PF control goes through /dev/pf), kept compileable. */
int pf_sysctl(void *oldp, size_t *oldlenp, void *newp, size_t newlen);
int pf_chk_limiter_action(int);
static inline int
sysctl_rdstruct(void *oldp, size_t *oldlenp, void *newp, const void *val,
size_t len)
{
(void)newp;
if (oldp && oldlenp) {
size_t n = len < *oldlenp ? len : *oldlenp;
if (copy_to_user(oldp, (void __force *)val, n))
return EFAULT;
*oldlenp = len;
}
return 0;
}
static inline int
sysctl_quad(void *r, const void *v, size_t l, uint64_t lo, uint64_t hi)
{
(void)v; (void)l; (void)lo; (void)hi;
*(uint64_t *)r = 0;
return 0;
}
/* PF option headers: OpenBSD builds per-option headers (carp.h etc.); we
* zero the absent features and enable pflog (netlink-backed). */
#define NPFSYNC 0
#define NPFLOG 1
#define NPFLOW 0
#define NCARP 0
#define NPF 1
#define INET 1
#define INET6 1
/* OpenBSD's lock-debugging wrapper (pc_lock): we keep a plain rwlock. */
struct pc_lock {
struct rwlock pcl_lock;
};
#define pc_lock_init(l) rw_init(&(l)->pcl_lock, "pf")
#define pc_lock_lock(l) rw_enter(&(l)->pcl_lock, RW_WRITER)
#define pc_lock_unlock(l) rw_exit(&(l)->pcl_lock)
/* OpenBSD lock profiling hooks: no-ops in the port (generation counter
* semantics: pc_sprod_enter returns a generation, leave consumes it). */
static inline unsigned int pc_sprod_enter(void *p) { (void)p; return 0; }
static inline void pc_sprod_leave(void *p, unsigned int gen)
{ (void)p; (void)gen; }
/* kernel owns 'struct mutex' — BSD-visible alias must come before any
* staged BSD header references it. */
#define mutex pfk_mutex
/* net/sock.h defines accessor MACRO sk_refcnt (== __sk_common.skc_refcnt);
* struct pf_state_key has a genuine member named sk_refcnt — the macro
* would corrupt it. Compat code after this point uses explicit members. */
#undef sk_refcnt
/* pf headers resolve via -I module/include */
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* Implemented in pf_table.c (upstream) — declared here for -Wmissing-prototypes */
void pfr_fill_feedback(struct pfr_kentry_all *, struct pfr_addr *);
/* state helpers implemented in pf.c (struct pf_state comes from pfvar_priv.h) */
struct pf_state_list;
void pf_state_list_insert(struct pf_state_list *, struct pf_state *);
void pf_state_list_remove(struct pf_state_list *, struct pf_state *);
void pf_update_state_timeout(struct pf_state *, int);
void pfk_mod_init_done(void);
+25 -21
View File
@@ -5,22 +5,7 @@
#ifndef _PFK_IF_H
#define _PFK_IF_H
struct pfk_ifaddr {
struct pfk_ifaddr *ifa_next;
struct pfk_ifnet *ifa_ifp;
int ifa_refcnt;
int ifa_flags; /* BSD IFA_* */
struct sockaddr_storage ifa_addr_storage; /* BSD-ish sockaddr */
struct sockaddr *ifa_addr; /* -> storage */
struct sockaddr *ifa_mask;
struct net_device *dev;
__be32 addr4;
struct in6_addr addr6;
int family; /* AF_INET/AF_INET6 */
int scope; /* link/site for v6 */
};
struct pfk_ifqueue; /* M5 */
struct ifg_list;
struct pfk_ifnet {
char if_xname[IFNAMSIZ];
@@ -31,9 +16,10 @@ struct pfk_ifnet {
int if_type; /* IFT_* */
int if_mtu;
void *if_softc;
struct pfk_ifaddr *if_addrlist; /* refreshed snapshot */
struct pf_kif *if_pf_kif; /* pf_if glue */
struct pfk_ifqueue *if_snd; /* M5 */
TAILQ_HEAD(ifa_list, ifaddr) if_addrlist; /* BSD interface addresses */
TAILQ_HEAD(, ifg_list) if_groups; /* BSD interface groups */
void *if_pf_kif; /* pf_if glue (BSD: caddr_t) */
struct ifqueue if_snd; /* transmit queue (ifq) */
void *if_pf_rtable; /* unused (rt tables NG) */
int if_rdomain; /* always 0 (NG), kept for ABI */
struct rcu_head rcu;
@@ -71,6 +57,23 @@ void pfk_if_free(struct pfk_ifnet *ifp);
struct mbuf_list { struct mbuf *ml_first, *ml_last; int ml_len; };
/* BSD mbuf_list helper */
static inline struct mbuf *
ml_dequeue(struct mbuf_list *ml)
{
struct mbuf *m;
if (!ml || !ml->ml_first)
return NULL;
m = ml->ml_first;
ml->ml_first = m->m_next;
if (!ml->ml_first)
ml->ml_last = NULL;
ml->ml_len--;
m->m_next = NULL;
return m;
}
/* egress interface (default-route dev), maintained on fib/net events */
struct pfk_ifnet *pfk_egress_if(void);
void pfk_egress_refresh(void);
@@ -89,10 +92,11 @@ int if_output_tso(struct pfk_ifnet *ifp, struct mbuf **mp,
int if_output_ml(struct pfk_ifnet *ifp, struct mbuf_list *ml,
struct sockaddr *dst, void *rt);
int if_enqueue(struct pfk_ifnet *ifp, struct mbuf *m);
int pfk_if_output(struct pfk_ifnet *ifp, struct mbuf *m, struct sockaddr *dst, void *rt);
/* addr lookups (ifa_ifwithaddr, in_ifwithaddr etc.) */
struct pfk_ifaddr *pfk_ifwithaddr(const struct sockaddr *sa);
struct pfk_ifaddr *pfk_ifwithroute(int family, const struct sockaddr *dst,
struct ifaddr *pfk_ifwithaddr(const struct sockaddr *sa);
struct ifaddr *pfk_ifwithroute(int family, const struct sockaddr *dst,
const struct sockaddr *gate, struct pfk_ifnet **ifp_out);
/* mib-ish status for pfctl DIOCGIFSTATS */
+4 -3
View File
@@ -15,6 +15,7 @@
#include <linux/skbuff.h>
struct pfk_ifnet; /* forward (pfk_if.h) */
struct mbuf_list; /* BSD mbuf list (pfk_if.h defines it) */
struct pf_state_key;
struct inpcb;
struct pf_tag;
@@ -61,7 +62,7 @@ struct pkthdr_pf {
u_int8_t dir;
u_int8_t reason;
u_int16_t ruleset;
struct pfk_tag *tag;
u_int tag; /* OpenBSD: bitmask */
};
struct pkthdr {
@@ -130,9 +131,9 @@ struct mbuf *m_dup(struct mbuf *m, int wait); /* full dup + headroom */
void m_adj(struct mbuf *m, int dlen);
void m_trim(struct mbuf *m, int dlen);
int m_cat(struct mbuf *to, struct mbuf *from); /* copies+consumes from */
caddr_t m_copyback(struct mbuf *m, int off, int len, const void *copied);
int m_copyback(struct mbuf *m, int off, int len, const void *copied, int type);
void m_copydata(const struct mbuf *m, int off, int len, caddr_t dest);
caddr_t m_getptr(struct mbuf *m, int loc, int *off);
struct mbuf *m_getptr(struct mbuf *m, int loc, int *off);
int m_clump(struct mbuf **m0p, int len, int *mp_off, int *mp_len, caddr_t *doff);
void m_free_ext(struct mbuf *m);
struct mbuf *m_free(struct mbuf *m); /* returns next */
+34 -1
View File
@@ -177,7 +177,40 @@ static inline __u8 PF6_CLASS(const struct pf_ip6_hdr *h)
* icmp6hdr + its member macros; staging seds `struct icmp6_hdr` →
* `struct icmp6hdr` (see stage-port.sh). No private definition needed. */
/* BSD IPPROTO_ / IP levels (identical numerics to Linux; aliases kept) */
/* ---- ICMPv6 (BSD <netinet6/icmp6.h> layout for pfvar_priv's hdr union) ---- */
struct pf_icmp6 {
__u8 icmp6_type;
__u8 icmp6_code;
__be16 icmp6_cksum;
union {
__be32 un_data32[4];
struct {
__be16 icmp6_id;
__be16 icmp6_seq;
} un_h;
} icmp6_dataun;
};
#define icmp6_id icmp6_dataun.un_h.icmp6_id
#define icmp6_seq icmp6_dataun.un_h.icmp6_seq
#undef icmp6_mtu
#define icmp6_mtu icmp6_dataun.un_data32[1]
/* ---- IPv6 multicast / neighbour discovery headers (BSD names) ---- */
struct pf_mld_hdr {
__u8 mld_type;
__u8 mld_pad[2];
__be16 mld_cksum;
__be32 mld_reserved;
struct in6_addr mld_addr;
};
struct pf_nd_neighbor_solicit {
struct in6_addr nd_ns_target;
__be32 nd_ns_reserved;
__be32 nd_ns_flags;
};
/* ---- BSD IPPROTO_ / IP levels (identical numerics to Linux; aliases kept) */
#define IPPROTO_MAX_ IPPROTO_MAX
/* ---- checksum helpers (ported in_cksum etc.) ---- */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+45 -5
View File
@@ -1,5 +1,45 @@
/* PFLINUX port of OpenBSD 8.0 net/fq_codel.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: fq_codel.c,v 1.21 2026/08/13 09:01:49 bket Exp $ */
/*
* Copyright (c) 2017 Mike Belopuhov
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* K. Nichols, V. Jacobson, A. McGregor and J. Iyengar, Controlled Delay
* Active Queue Management, RFC 8289, January 2018
*
* Based on the algorithm by Kathleen Nichols and Van Jacobson with
* improvements from Dave Taht and Eric Dumazet.
*/
/*
* T. Hoeiland-Joergensen, P. McKenney, D. Taht, J. Gettys and E. Dumazet,
* The Flow Queue CoDel Packet Scheduler and Active Queue Management
* Algorithm, RFC 8290, January 2018
*
* Based on the implementation by Rasool Al-Saadi, Centre for Advanced
* Internet Architectures, Swinburne University of Technology, Melbourne,
* Australia.
*/
/* #define FQCODEL_DEBUG 1 */
@@ -59,7 +99,7 @@ struct fqcodel {
struct flow *flows;
unsigned int qlength;
struct ifnet *ifp;
struct pfk_ifnet *ifp;
struct codel_params cparams;
@@ -107,7 +147,7 @@ static const struct ifq_ops fqcodel_ops = {
const struct ifq_ops *const ifq_fqcodel_ops = &fqcodel_ops;
void *fqcodel_pf_alloc(struct ifnet *);
void *fqcodel_pf_alloc(struct pfk_ifnet *);
int fqcodel_pf_addqueue(void *, struct pf_queuespec *);
void fqcodel_pf_free(void *);
int fqcodel_pf_qstats(struct pf_queuespec *, void *, int *);
@@ -701,7 +741,7 @@ fqcodel_if_purge(struct ifqueue *ifq, struct mbuf_list *ml)
}
void *
fqcodel_pf_alloc(struct ifnet *ifp)
fqcodel_pf_alloc(struct pfk_ifnet *ifp)
{
struct fqcodel *fqc;
@@ -717,7 +757,7 @@ fqcodel_pf_alloc(struct ifnet *ifp)
int
fqcodel_pf_addqueue(void *arg, struct pf_queuespec *qs)
{
struct ifnet *ifp = qs->kif->pfik_ifp;
struct pfk_ifnet *ifp = qs->kif->pfik_ifp;
struct fqcodel *fqc = arg;
if (qs->flowqueue.flows == 0 || qs->flowqueue.flows > 0xffff)
@@ -773,7 +813,7 @@ fqcodel_pf_free(void *arg)
int
fqcodel_pf_qstats(struct pf_queuespec *qs, void *ubuf, int *nbytes)
{
struct ifnet *ifp = qs->kif->pfik_ifp;
struct pfk_ifnet *ifp = qs->kif->pfik_ifp;
struct fqcodel_stats stats;
struct fqcodel *fqc;
int64_t delay;
+53 -4
View File
@@ -1,5 +1,54 @@
/* PFLINUX port of OpenBSD 8.0 net/hfsc.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: hfsc.c,v 1.53 2026/03/19 14:59:05 sthen Exp $ */
/*
* Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org>
* Copyright (c) 1997-1999 Carnegie Mellon University. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation is hereby granted (including for commercial or
* for-profit use), provided that both the copyright notice and this
* permission notice appear in all copies of the software, derivative
* works, or modified versions, and any portions thereof.
*
* THIS SOFTWARE IS EXPERIMENTAL AND IS KNOWN TO HAVE BUGS, SOME OF
* WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS
* SOFTWARE IN ITS ``AS IS'' CONDITION, AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* Carnegie Mellon encourages (but does not require) users of this
* software to return any improvements or extensions that they make,
* and to grant Carnegie Mellon the rights to redistribute these
* changes without encumbrance.
*/
/*
* H-FSC is described in Proceedings of SIGCOMM'97,
* "A Hierarchical Fair Service Curve Algorithm for Link-Sharing,
* Real-Time and Priority Service"
* by Ion Stoica, Hui Zhang, and T. S. Eugene Ng.
*
* Oleg Cherevko <olwi@aq.ml.com.ua> added the upperlimit for link-sharing.
* when a class has an upperlimit, the fit-time is computed from the
* upperlimit service curve. the link-sharing scheduler does not schedule
* a class whose fit-time exceeds the current time.
*/
/*
* kernel internal service curve representation
@@ -223,7 +272,7 @@ const struct ifq_ops * const ifq_hfsc_ops = &hfsc_ops;
* pf queue glue.
*/
void *hfsc_pf_alloc(struct ifnet *);
void *hfsc_pf_alloc(struct pfk_ifnet *);
int hfsc_pf_addqueue(void *, struct pf_queuespec *);
void hfsc_pf_free(void *);
int hfsc_pf_qstats(struct pf_queuespec *, void *, int *);
@@ -320,7 +369,7 @@ hfsc_initialize(void)
}
void *
hfsc_pf_alloc(struct ifnet *ifp)
hfsc_pf_alloc(struct pfk_ifnet *ifp)
{
struct hfsc_if *hif;
@@ -416,7 +465,7 @@ hfsc_pf_addqueue(void *arg, struct pf_queuespec *q)
int
hfsc_pf_qstats(struct pf_queuespec *q, void *ubuf, int *nbytes)
{
struct ifnet *ifp = q->kif->pfik_ifp;
struct pfk_ifnet *ifp = q->kif->pfik_ifp;
struct hfsc_if *hif;
struct hfsc_class *cl;
struct hfsc_class_stats stats;
@@ -876,7 +925,7 @@ hfsc_update_sc(struct hfsc_if *hif, struct hfsc_class *cl, int len)
void
hfsc_deferred(void *arg)
{
struct ifnet *ifp = arg;
struct pfk_ifnet *ifp = arg;
struct ifqueue *ifq = &ifp->if_snd;
struct hfsc_if *hif;
+58 -10
View File
@@ -1,5 +1,53 @@
/* PFLINUX port of OpenBSD 8.0 net/if_pflog.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: if_pflog.c,v 1.99 2025/07/07 02:28:50 jsg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
* Niels Provos (provos@physnet.uni-hamburg.de).
*
* This code was written by John Ioannidis for BSD/OS in Athens, Greece,
* in November 1995.
*
* Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
* by Angelos D. Keromytis.
*
* Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
* and Niels Provos.
*
* Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
* and Niels Provos.
* Copyright (c) 2001, Angelos D. Keromytis, Niels Provos.
* Copyright (c) 2002 - 2010 Henning Brauer
*
* Permission to use, copy, and modify this software with or without fee
* is hereby granted, provided that this entire notice is included in
* all copies of any software which is or includes a copy or
* modification of this software.
* You may use this code under the GNU public license if you so wish. Please
* contribute changes back to the authors under this freer than GPL license
* so that we may further the use of strong encryption without limitations to
* all.
*
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
* MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
* PURPOSE.
*/
#if NBPFILTER > 0
#endif
#ifdef INET6
#endif /* INET6 */
#define PFLOGMTU (32768 + MHLEN + MLEN)
@@ -10,11 +58,11 @@
#endif
void pflogattach(int);
int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *);
int pflogioctl(struct ifnet *, u_long, caddr_t);
int pflogoutput(struct pfk_ifnet *, struct mbuf *, struct sockaddr *,
struct pf_rtentry *);
int pflogioctl(struct pfk_ifnet *, u_long, caddr_t);
int pflog_clone_create(struct if_clone *, int);
int pflog_clone_destroy(struct ifnet *);
int pflog_clone_destroy(struct pfk_ifnet *);
struct pflog_softc *pflog_getif(int);
struct if_clone pflog_cloner =
@@ -31,7 +79,7 @@ pflogattach(int npflog)
int
pflog_clone_create(struct if_clone *ifc, int unit)
{
struct ifnet *ifp;
struct pfk_ifnet *ifp;
struct pflog_softc *pflogif;
pflogif = malloc(sizeof(*pflogif), M_DEVBUF, M_WAITOK|M_ZERO);
@@ -60,7 +108,7 @@ pflog_clone_create(struct if_clone *ifc, int unit)
}
int
pflog_clone_destroy(struct ifnet *ifp)
pflog_clone_destroy(struct pfk_ifnet *ifp)
{
struct pflog_softc *pflogif = ifp->if_softc;
@@ -75,15 +123,15 @@ pflog_clone_destroy(struct ifnet *ifp)
}
int
pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct rtentry *rt)
pflogoutput(struct pfk_ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct pf_rtentry *rt)
{
m_freem(m); /* drop packet */
return (EAFNOSUPPORT);
}
int
pflogioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
pflogioctl(struct pfk_ifnet *ifp, u_long cmd, caddr_t data)
{
switch (cmd) {
case SIOCSIFFLAGS:
@@ -120,7 +168,7 @@ pflog_packet(struct pf_pdesc *pd, u_int8_t reason, struct pf_rule *rm,
{
#if NBPFILTER > 0
struct pflog_softc *pflogif;
struct ifnet *ifn;
struct pfk_ifnet *ifn;
caddr_t if_bpf;
struct pfloghdr hdr;
+34 -6
View File
@@ -1,5 +1,33 @@
/* PFLINUX port of OpenBSD 8.0 net/ifq.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: ifq.c,v 1.62 2025/07/28 05:25:44 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if NBPFILTER > 0
#endif
#if NKSTAT > 0
#endif
/*
@@ -96,7 +124,7 @@ void
ifq_start_task(void *p)
{
struct ifqueue *ifq = p;
struct ifnet *ifp = ifq->ifq_if;
struct pfk_ifnet *ifp = ifq->ifq_if;
if (!ISSET(ifp->if_flags, PFIFF_RUNNING) ||
ifq_empty(ifq) || ifq_is_oactive(ifq))
@@ -134,7 +162,7 @@ void
ifq_restart_task(void *p)
{
struct ifqueue *ifq = p;
struct ifnet *ifp = ifq->ifq_if;
struct pfk_ifnet *ifp = ifq->ifq_if;
ifq_clr_oactive(ifq);
ifp->if_qstart(ifq);
@@ -218,7 +246,7 @@ ifq_kstat_copy(struct kstat *ks, void *dst)
#endif
void
ifq_init(struct ifqueue *ifq, struct ifnet *ifp, unsigned int idx)
ifq_init(struct ifqueue *ifq, struct pfk_ifnet *ifp, unsigned int idx)
{
ifq->ifq_if = ifp;
ifq->ifq_softnet = net_tq(idx);
@@ -616,7 +644,7 @@ ifiq_kstat_copy(struct kstat *ks, void *dst)
static void ifiq_process(void *);
void
ifiq_init(struct ifiqueue *ifiq, struct ifnet *ifp, unsigned int idx)
ifiq_init(struct ifiqueue *ifiq, struct pfk_ifnet *ifp, unsigned int idx)
{
ifiq->ifiq_if = ifp;
ifiq->ifiq_bpfp = NULL;
@@ -669,7 +697,7 @@ unsigned int ifiq_maxlen_return = 2048 * 3;
int
ifiq_input(struct ifiqueue *ifiq, struct mbuf_list *ml)
{
struct ifnet *ifp = ifiq->ifiq_if;
struct pfk_ifnet *ifp = ifiq->ifiq_if;
struct mbuf *m;
uint64_t packets;
uint64_t bytes = 0;
@@ -763,7 +791,7 @@ ifiq_add_data(struct ifiqueue *ifiq, struct if_data *data)
int
ifiq_enqueue_qlim(struct ifiqueue *ifiq, struct mbuf *m, unsigned int qlim)
{
struct ifnet *ifp = ifiq->ifiq_if;
struct pfk_ifnet *ifp = ifiq->ifiq_if;
unsigned int len;
#if NBPFILTER > 0
caddr_t if_bpf = ifp->if_bpf;
+28 -4
View File
@@ -1,5 +1,29 @@
/* PFLINUX port of OpenBSD 8.0 netinet/ip_divert.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: ip_divert.c,v 1.108 2026/06/24 15:56:17 claudio Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Locks used to protect data:
@@ -91,8 +115,8 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
m->m_pkthdr.pf.flags |= PF_TAG_DIVERTED_PACKET;
if (dir == PF_IN) {
struct rtentry *rt;
struct ifnet *ifp;
struct pf_rtentry *rt;
struct pfk_ifnet *ifp;
rt = rtalloc(sintosa(sin), 0, inp->inp_rtableid);
if (!rtisvalid(rt) || !ISSET(rt->rt_flags, RTF_LOCAL)) {
@@ -168,11 +192,11 @@ divert_packet(struct mbuf *m, int dir, u_int16_t divert_port)
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin./* PFLINUX sin_len */;
;
if (dir == PF_IN) {
struct ifaddr *ifa;
struct ifnet *ifp;
struct pfk_ifnet *ifp;
ifp = if_get(m->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
+95 -42
View File
@@ -1,5 +1,58 @@
/* PFLINUX port of OpenBSD 8.0 net/pf.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf.c,v 1.1242 2026/10/02 09:40:22 sashan Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
* Copyright (c) 2002 - 2013 Henning Brauer <henning@openbsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Effort sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F30602-01-2-0537.
*
*/
#ifdef INET6
#endif /* INET6 */
#if NPFLOW > 0
#endif /* NPFLOW > 0 */
#if NPFSYNC > 0
#endif /* NPFSYNC > 0 */
/*
@@ -2939,7 +2992,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, int *icmp_dir,
case MLD_LISTENER_QUERY:
case MLD_LISTENER_REPORT: {
struct mld_hdr *mld = &pd->hdr.mld;
struct pf_mld_hdr *mld = &pd->hdr.mld;
u_int32_t h;
/*
@@ -2984,7 +3037,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, int *icmp_dir,
*icmp_dir = PF_IN;
/* FALLTHROUGH */
case ND_NEIGHBOR_ADVERT: {
struct nd_neighbor_solicit *nd = &pd->hdr.nd_ns;
struct pf_nd_neighbor_solicit *nd = &pd->hdr.nd_ns;
u_int32_t h;
*virtual_type = ND_NEIGHBOR_SOLICIT;
@@ -3313,7 +3366,7 @@ int
pf_translate_icmp_af(struct pf_pdesc *pd, int af, void *arg)
{
struct pf_icmp *icmp4;
struct icmp6hdr *icmp6;
struct pf_icmp6 *icmp6;
u_int32_t mtu;
int32_t ptr = -1;
u_int8_t type;
@@ -3870,7 +3923,7 @@ pf_match_tag(struct mbuf *m, struct pf_rule *r, int *tag)
int
pf_match_rcvif(struct mbuf *m, struct pf_rule *r)
{
struct ifnet *ifp;
struct pfk_ifnet *ifp;
struct pfi_kif *kif = NULL;
if (m->m_pkthdr.ph_ifidx == 0)
@@ -3882,7 +3935,7 @@ pf_match_rcvif(struct mbuf *m, struct pf_rule *r)
kif = (struct pfi_kif *)ifp->if_pf_kif;
#if NCARP > 0
if (ifp->if_type == IFT_CARP) {
struct ifnet *ifp0 = if_get_smr(ifp->if_carpdevidx);
struct pfk_ifnet *ifp0 = if_get_smr(ifp->if_carpdevidx);
if (ifp0 != NULL)
kif = (struct pfi_kif *)ifp0->if_pf_kif;
}
@@ -4246,12 +4299,12 @@ u_int16_t
pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, uint16_t offer,
uint16_t mssdflt)
{
struct ifnet *ifp;
struct pfk_ifnet *ifp;
struct sockaddr_in *dst;
#ifdef INET6
struct sockaddr_in6 *dst6;
#endif /* INET6 */
struct rtentry *rt = NULL;
struct pf_rtentry *rt = NULL;
struct sockaddr_storage ss;
int hlen, mss;
@@ -4262,7 +4315,7 @@ pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, uint16_t offer,
hlen = sizeof(struct pf_ip);
dst = (struct sockaddr_in *)&ss;
dst->sin_family = AF_INET;
dst->/* PFLINUX sin_len */;
dst->sin_len = sizeof(*dst);
dst->sin_addr = addr->v4;
rt = rtalloc(sintosa(dst), 0, rtableid);
break;
@@ -6338,7 +6391,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
&pd->hdr.icmp6.icmp6_id, nk->port[iidx]);
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr), &pd->hdr.icmp6,
sizeof(struct pf_icmp6), &pd->hdr.icmp6,
M_NOWAIT);
copyback = 1;
break;
@@ -6403,7 +6456,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
break;
#ifdef INET6
case AF_INET6:
ipoff2 = pd->off + sizeof(struct icmp6hdr);
ipoff2 = pd->off + sizeof(struct pf_icmp6);
if (!pf_pull_hdr(pd2.m, ipoff2, &h2_6, sizeof(h2_6),
reason, pd2.af)) {
@@ -6560,7 +6613,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
&pd->hdr.icmp))
return (PF_DROP);
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr),
sizeof(struct pf_icmp6),
&pd->hdr.icmp6, M_NOWAIT);
if (pf_change_icmp_af(pd->m, ipoff2,
pd, &pd2, &nk->addr[sidx],
@@ -6633,7 +6686,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
#ifdef INET6
case AF_INET6:
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr),
sizeof(struct pf_icmp6),
&pd->hdr.icmp6, M_NOWAIT);
m_copyback(pd2.m, ipoff2, sizeof(h2_6),
&h2_6, M_NOWAIT);
@@ -6690,7 +6743,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
&pd->hdr.icmp))
return (PF_DROP);
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr),
sizeof(struct pf_icmp6),
&pd->hdr.icmp6, M_NOWAIT);
if (pf_change_icmp_af(pd->m, ipoff2,
pd, &pd2, &nk->addr[sidx],
@@ -6761,7 +6814,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
#ifdef INET6
case AF_INET6:
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr),
sizeof(struct pf_icmp6),
&pd->hdr.icmp6, M_NOWAIT);
m_copyback(pd2.m, ipoff2, sizeof(h2_6),
&h2_6, M_NOWAIT);
@@ -6825,7 +6878,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
&pd->hdr.icmp))
return (PF_DROP);
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr),
sizeof(struct pf_icmp6),
&pd->hdr.icmp6, M_NOWAIT);
if (pf_change_icmp_af(pd->m, ipoff2,
pd, &pd2, &nk->addr[sidx],
@@ -6893,7 +6946,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
}
#ifdef INET6
case IPPROTO_ICMPV6: {
struct icmp6hdr *iih = &pd2.hdr.icmp6;
struct pf_icmp6 *iih = &pd2.hdr.icmp6;
if (pd2.af != AF_INET6) {
REASON_SET(reason, PFRES_NORM);
@@ -6901,7 +6954,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
}
if (!pf_pull_hdr(pd2.m, pd2.off, iih,
sizeof(struct icmp6hdr), reason, pd2.af)) {
sizeof(struct pf_icmp6), reason, pd2.af)) {
DPFPRINTF(LOG_NOTICE,
"ICMP error message too short (icmp6)");
return (PF_DROP);
@@ -6943,7 +6996,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
&pd->hdr.icmp))
return (PF_DROP);
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr),
sizeof(struct pf_icmp6),
&pd->hdr.icmp6, M_NOWAIT);
if (pf_change_icmp_af(pd->m, ipoff2,
pd, &pd2, &nk->addr[sidx],
@@ -6958,7 +7011,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
pf_patch_16(pd, &iih->icmp6_id,
nk->port[iidx]);
m_copyback(pd2.m, pd2.off,
sizeof(struct icmp6hdr), iih,
sizeof(struct pf_icmp6), iih,
M_NOWAIT);
pd->m->m_pkthdr.ph_rtableid =
nk->rdomain;
@@ -6996,12 +7049,12 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
pd->src, &nk->addr[pd2.didx], 0);
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr), &pd->hdr.icmp6,
sizeof(struct pf_icmp6), &pd->hdr.icmp6,
M_NOWAIT);
m_copyback(pd2.m, ipoff2, sizeof(h2_6), &h2_6,
M_NOWAIT);
m_copyback(pd2.m, pd2.off,
sizeof(struct icmp6hdr), iih, M_NOWAIT);
sizeof(struct pf_icmp6), iih, M_NOWAIT);
copyback = 1;
}
break;
@@ -7054,7 +7107,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
#ifdef INET6
case AF_INET6:
m_copyback(pd->m, pd->off,
sizeof(struct icmp6hdr),
sizeof(struct pf_icmp6),
&pd->hdr.icmp6, M_NOWAIT);
m_copyback(pd2.m, ipoff2, sizeof(h2_6),
&h2_6, M_NOWAIT);
@@ -7124,7 +7177,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif,
#ifdef INET6
struct sockaddr_in6 *dst6;
#endif /* INET6 */
struct rtentry *rt = NULL;
struct pf_rtentry *rt = NULL;
check_mpath = 0;
memset(&ss, 0, sizeof(ss));
@@ -7132,7 +7185,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif,
case AF_INET:
dst = (struct sockaddr_in *)&ss;
dst->sin_family = AF_INET;
dst->/* PFLINUX sin_len */;
dst->sin_len = sizeof(*dst);
dst->sin_addr = addr->v4;
if (atomic_load_int(&ipmultipath))
check_mpath = 1;
@@ -7177,7 +7230,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif,
ret = 1;
#if NCARP > 0
} else {
struct ifnet *ifp;
struct pfk_ifnet *ifp;
smr_read_enter();
ifp = if_get_smr(rt->rt_ifidx);
@@ -7207,7 +7260,7 @@ pf_rtlabel_match(struct pf_addr *addr, sa_family_t af, struct pf_addr_wrap *aw,
#ifdef INET6
struct sockaddr_in6 *dst6;
#endif /* INET6 */
struct rtentry *rt;
struct pf_rtentry *rt;
int ret = 0;
memset(&ss, 0, sizeof(ss));
@@ -7215,7 +7268,7 @@ pf_rtlabel_match(struct pf_addr *addr, sa_family_t af, struct pf_addr_wrap *aw,
case AF_INET:
dst = (struct sockaddr_in *)&ss;
dst->sin_family = AF_INET;
dst->/* PFLINUX sin_len */;
dst->sin_len = sizeof(*dst);
dst->sin_addr = addr->v4;
break;
#ifdef INET6
@@ -7245,9 +7298,9 @@ pf_route(struct pf_pdesc *pd, struct pf_state *st)
struct mbuf *m0;
struct mbuf_list ml;
struct sockaddr_in *dst, sin;
struct rtentry *rt = NULL;
struct pf_rtentry *rt = NULL;
struct pf_ip *ip;
struct ifnet *ifp = NULL;
struct pfk_ifnet *ifp = NULL;
unsigned int rtableid;
if (pd->m->m_pkthdr.pf.routed++ > 3) {
@@ -7289,7 +7342,7 @@ pf_route(struct pf_pdesc *pd, struct pf_state *st)
memset(&sin, 0, sizeof(sin));
dst = &sin;
dst->sin_family = AF_INET;
dst->/* PFLINUX sin_len */;
dst->sin_len = sizeof(*dst);
dst->sin_addr = st->rt_addr.v4;
rtableid = m0->m_pkthdr.ph_rtableid;
@@ -7363,9 +7416,9 @@ pf_route6(struct pf_pdesc *pd, struct pf_state *st)
{
struct mbuf *m0;
struct sockaddr_in6 *dst, sin6;
struct rtentry *rt = NULL;
struct pf_rtentry *rt = NULL;
struct pf_ip6_hdr *ip6;
struct ifnet *ifp = NULL;
struct pfk_ifnet *ifp = NULL;
struct m_tag *mtag;
unsigned int rtableid;
@@ -7751,7 +7804,7 @@ pf_walk_header6(struct pf_pdesc *pd, struct pf_ip6_hdr *h, u_short *reason)
{
struct ip6_frag frag;
struct ip6_ext ext;
struct icmp6hdr icmp6;
struct pf_icmp6 icmp6;
struct ip6_rthdr rthdr;
u_int32_t end;
int hdr_cnt, fraghdr_cnt = 0, rthdr_cnt = 0;
@@ -7919,7 +7972,7 @@ pf_walk_header6(struct pf_pdesc *pd, struct pf_ip6_hdr *h, u_short *reason)
if (pd->fragoff != 0 && end < pd->off +
(pd->proto == IPPROTO_TCP ? sizeof(struct pf_tcphdr) :
pd->proto == IPPROTO_UDP ? sizeof(struct pf_udphdr) :
sizeof(struct icmp6hdr))) {
sizeof(struct pf_icmp6))) {
pd->off = pd->fragoff;
pd->proto = IPPROTO_FRAGMENT;
}
@@ -8104,7 +8157,7 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
}
#ifdef INET6
case IPPROTO_ICMPV6: {
size_t icmp_hlen = sizeof(struct icmp6hdr);
size_t icmp_hlen = sizeof(struct pf_icmp6);
if (!pf_pull_hdr(pd->m, pd->off, &pd->hdr.icmp6, icmp_hlen,
reason, pd->af))
@@ -8113,11 +8166,11 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
switch (pd->hdr.icmp6.icmp6_type) {
case MLD_LISTENER_QUERY:
case MLD_LISTENER_REPORT:
icmp_hlen = sizeof(struct mld_hdr);
icmp_hlen = sizeof(struct pf_mld_hdr);
break;
case ND_NEIGHBOR_SOLICIT:
case ND_NEIGHBOR_ADVERT:
icmp_hlen = sizeof(struct nd_neighbor_solicit);
icmp_hlen = sizeof(struct pf_nd_neighbor_solicit);
/* FALLTHROUGH */
case ND_ROUTER_SOLICIT:
case ND_ROUTER_ADVERT:
@@ -8128,7 +8181,7 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
}
break;
}
if (icmp_hlen > sizeof(struct icmp6hdr) &&
if (icmp_hlen > sizeof(struct pf_icmp6) &&
!pf_pull_hdr(pd->m, pd->off, &pd->hdr.icmp6, icmp_hlen,
reason, pd->af))
return (PF_DROP);
@@ -8216,7 +8269,7 @@ pf_counters_inc(int action, struct pf_pdesc *pd, struct pf_state *st,
}
int
pf_test(sa_family_t af, int fwdir, struct ifnet *ifp, struct mbuf **m0)
pf_test(sa_family_t af, int fwdir, struct pfk_ifnet *ifp, struct mbuf **m0)
{
struct pfi_kif *kif = NULL;
u_short action, reason = 0;
@@ -8234,7 +8287,7 @@ pf_test(sa_family_t af, int fwdir, struct ifnet *ifp, struct mbuf **m0)
#if NCARP > 0
if (ifp->if_type == IFT_CARP) {
struct ifnet *ifp0;
struct pfk_ifnet *ifp0;
smr_read_enter();
ifp0 = if_get_smr(ifp->if_carpdevidx);
@@ -8690,7 +8743,7 @@ done:
action = PF_DROP;
goto out;
}
ip6_forward(pd.m, NULL, flags);
pfk_ip6_forward(pd.m, NULL, flags);
} else
ip6_output(pd.m, NULL, NULL, 0, NULL, NULL);
break;
@@ -9047,7 +9100,7 @@ void
pf_pktenqueue_delayed(void *arg)
{
struct pf_pktdelay *pdy = arg;
struct ifnet *ifp;
struct pfk_ifnet *ifp;
ifp = if_get(pdy->ifidx);
if (ifp != NULL) {
+50 -8
View File
@@ -1,9 +1,51 @@
/* PFLINUX port of OpenBSD 8.0 net/pf_if.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf_if.c,v 1.114 2026/09/08 18:42:14 bluhm Exp $ */
/*
* Copyright 2005 Henning Brauer <henning@openbsd.org>
* Copyright 2005 Ryan McBride <mcbride@openbsd.org>
* Copyright (c) 2001 Daniel Hartmeier
* Copyright (c) 2003 Cedric Berger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef INET6
#endif /* INET6 */
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
#define islower(c) ((c) >= 'a' && (c) <= 'z')
#define isalpha(c) (isupper(c)||islower(c))
struct pfi_kif *pfi_all = NULL;
struct pool pfi_addr_pl;
@@ -18,7 +60,7 @@ void pfi_dynaddr_update(struct pfi_dynaddr *dyn);
void pfi_table_update(struct pfr_ktable *, struct pfi_kif *,
u_int8_t, int);
void pfi_kifaddr_update(void *);
void pfi_instance_add(struct ifnet *, u_int8_t, int);
void pfi_instance_add(struct pfk_ifnet *, u_int8_t, int);
void pfi_address_add(struct sockaddr *, sa_family_t, u_int8_t);
int pfi_if_compare(struct pfi_kif *, struct pfi_kif *);
int pfi_skip_if(const char *, struct pfi_kif *);
@@ -243,7 +285,7 @@ pfi_kif_match(struct pfi_kif *rule_kif, struct pfi_kif *packet_kif)
}
void
pfi_attach_ifnet(struct ifnet *ifp)
pfi_attach_ifnet(struct pfk_ifnet *ifp)
{
struct pfi_kif *kif;
struct task *t;
@@ -267,7 +309,7 @@ pfi_attach_ifnet(struct ifnet *ifp)
}
void
pfi_detach_ifnet(struct ifnet *ifp)
pfi_detach_ifnet(struct pfk_ifnet *ifp)
{
struct pfi_kif *kif;
struct task *t;
@@ -513,7 +555,7 @@ pfi_table_update(struct pfr_ktable *kt, struct pfi_kif *kif, u_int8_t net, int f
}
void
pfi_instance_add(struct ifnet *ifp, u_int8_t net, int flags)
pfi_instance_add(struct pfk_ifnet *ifp, u_int8_t net, int flags)
{
struct ifaddr *ifa;
int got4 = 0, got6 = 0;
@@ -862,7 +904,7 @@ pfi_xcommit(void)
{
struct pfi_kif *p, *gkif;
struct ifg_list *g;
struct ifnet *ifp;
struct pfk_ifnet *ifp;
size_t n;
PF_ASSERT_LOCKED();
File diff suppressed because it is too large. Load diff
+47
View File
@@ -1,5 +1,52 @@
/* PFLINUX port of OpenBSD 8.0 net/pf_lb.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf_lb.c,v 1.78 2026/05/12 09:34:00 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
* Copyright (c) 2002 - 2008 Henning Brauer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Effort sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F30602-01-2-0537.
*
*/
#ifdef INET6
#endif /* INET6 */
u_int64_t pf_hash(struct pf_addr *, struct pf_addr *,
struct pf_poolhashkey *, sa_family_t);
+45 -7
View File
@@ -1,5 +1,43 @@
/* PFLINUX port of OpenBSD 8.0 net/pf_norm.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf_norm.c,v 1.239 2026/08/11 14:28:59 bluhm Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
* Copyright 2009 Henning Brauer <henning@openbsd.org>
* Copyright 2011-2018 Alexander Bluhm <bluhm@openbsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef INET6
#endif /* INET6 */
struct pf_frent {
TAILQ_ENTRY(pf_frent) fr_next;
@@ -886,7 +924,7 @@ fail:
int
pf_refragment6(struct mbuf **m0, struct m_tag *mtag, struct sockaddr_in6 *dst,
struct ifnet *ifp, struct rtentry *rt)
struct pfk_ifnet *ifp, struct pf_rtentry *rt)
{
struct mbuf *m = *m0;
struct mbuf_list ml;
@@ -904,7 +942,7 @@ pf_refragment6(struct mbuf **m0, struct m_tag *mtag, struct sockaddr_in6 *dst,
ftag = NULL;
/* Checksum must be calculated for the whole packet */
in6_proto_cksum_out(m, NULL);
pfk_in6_proto_cksum_out(m, NULL);
if (extoff) {
int off;
@@ -928,12 +966,12 @@ pf_refragment6(struct mbuf **m0, struct m_tag *mtag, struct sockaddr_in6 *dst,
* Maxlen may be less than 8 iff there was only a single
* fragment. As it was fragmented before, add a fragment
* header also for a single fragment. If total or maxlen
* is less than 8, ip6_fragment() will return EMSGSIZE and
* is less than 8, pfk_ip6_fragment() will return EMSGSIZE and
* we drop the packet.
*/
mtu = hdrlen + sizeof(struct ip6_frag) + maxlen;
error = ip6_fragment(m, &ml, hdrlen, proto, mtu);
*m0 = NULL; /* ip6_fragment() has consumed original packet. */
error = pfk_ip6_fragment(m, &ml, hdrlen, proto, mtu);
*m0 = NULL; /* pfk_ip6_fragment() has consumed original packet. */
if (error) {
DPFPRINTF(LOG_NOTICE, "refragment error %d", error);
return (PF_DROP);
@@ -955,9 +993,9 @@ pf_refragment6(struct mbuf **m0, struct m_tag *mtag, struct sockaddr_in6 *dst,
ip6stat_inc(ip6s_cantforward);
return (PF_DROP);
}
ip6_forward(m, NULL, flags);
pfk_ip6_forward(m, NULL, flags);
} else if ((u_long)m->m_pkthdr.len <= ifp->if_mtu) {
ifp->if_output(ifp, m, sin6tosa(dst), rt);
pfk_if_output(ifp, m, (struct sockaddr *)sin6tosa(dst), rt);
} else {
icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, ifp->if_mtu);
}
+49 -2
View File
@@ -1,5 +1,52 @@
/* PFLINUX port of OpenBSD 8.0 net/pf_osfp.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf_osfp.c,v 1.50 2026/09/13 03:27:17 deraadt Exp $ */
/*
* Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#ifdef _KERNEL
#endif /* _KERNEL */
#ifdef INET6
#endif /* INET6 */
#ifdef _KERNEL
typedef struct pool pool_t;
#else /* !_KERNEL */
/* Userland equivalents so we can lend code to tcpdump et al. */
#define pool_t int
#define pool_get(pool, flags) malloc(*(pool))
#define pool_put(pool, item) free(item)
#define pool_init(pool, size, a, ao, f, m, p) (*(pool)) = (size)
#define PF_LOCK()
#define PF_UNLOCK()
#define PF_ASSERT_LOCKED()
#ifdef PFDEBUG
#endif /* PFDEBUG */
#endif /* _KERNEL */
@@ -88,7 +135,7 @@ pf_osfp_fingerprint_hdr(const struct pf_ip *ip, const struct pf_ip6_hdr *ip6,
#else /* !_KERNEL */
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin./* PFLINUX sin_len */;
;
sin.sin_addr = ip->ip_src;
(void)getnameinfo((struct sockaddr *)&sin,
sizeof(struct sockaddr_in), srcname, sizeof(srcname),
@@ -111,7 +158,7 @@ pf_osfp_fingerprint_hdr(const struct pf_ip *ip, const struct pf_ip6_hdr *ip6,
#else /* !_KERNEL */
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
sin6.sin6_len = sizeof(struct sockaddr_in6);
;
sin6.sin6_addr = ip6->ip6_src;
(void)getnameinfo((struct sockaddr *)&sin6,
sizeof(struct sockaddr_in6), srcname, sizeof(srcname),
+62
View File
@@ -1,5 +1,67 @@
/* PFLINUX port of OpenBSD 8.0 net/pf_ruleset.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf_ruleset.c,v 1.22 2025/07/07 02:28:50 jsg Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
* Copyright (c) 2002,2003 Henning Brauer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Effort sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F30602-01-2-0537.
*
*/
#ifdef _KERNEL
#endif /* _KERNEL */
#ifdef _KERNEL
#define rs_malloc(x) malloc(x, M_PF, M_WAITOK|M_CANFAIL|M_ZERO)
#define rs_free(x, siz) free(x, M_PF, siz)
#define rs_pool_get_anchor() pool_get(&pf_anchor_pl, \
PR_WAITOK|PR_LIMITFAIL|PR_ZERO)
#define rs_pool_put_anchor(x) pool_put(&pf_anchor_pl, x)
struct pool pf_anchor_pl;
#else /* !_KERNEL */
/* Userland equivalents so we can lend code to pfctl et al. */
#define rs_malloc(x) calloc(1, x)
#define rs_free(x, siz) freezero(x, siz)
#define rs_pool_get_anchor() calloc(1, sizeof(struct pf_anchor))
#define rs_pool_put_anchor(x) freezero(x, sizeof(struct pf_anchor))
#ifdef PFDEBUG
#endif /* PFDEBUG */
#endif /* _KERNEL */
+68 -1
View File
@@ -1,5 +1,72 @@
/* PFLINUX port of OpenBSD 8.0 net/pf_syncookies.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf_syncookies.c,v 1.10 2025/07/07 02:28:50 jsg Exp $ */
/* Copyright (c) 2016,2017 Henning Brauer <henning@openbsd.org>
* Copyright (c) 2016 Alexandr Nedvedicky <sashan@openbsd.org>
*
* syncookie parts based on FreeBSD sys/netinet/tcp_syncache.c
*
* Copyright (c) 2001 McAfee, Inc.
* Copyright (c) 2006,2013 Andre Oppermann, Internet Business Solutions AG
* All rights reserved.
*
* This software was developed for the FreeBSD Project by Jonathan Lemon
* and McAfee Research, the Security Research Division of McAfee, Inc. under
* DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
* DARPA CHATS research program. [2001 McAfee, Inc.]
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* when we're under synflood, we use syncookies to prevent state table
* exhaustion. Trigger for the synflood mode is the number of half-open
* connections in the state table.
* We leave synflood mode when the number of half-open states - including
* in-flight syncookies - drops far enough again
*/
/*
* syncookie enabled Initial Sequence Number:
* 24 bit MAC
* 3 bit WSCALE index
* 3 bit MSS index
* 1 bit SACK permitted
* 1 bit odd/even secret
*
* References:
* RFC4987 TCP SYN Flooding Attacks and Common Mitigations
* http://cr.yp.to/syncookies.html (overview)
* http://cr.yp.to/syncookies/archive (details)
*/
union pf_syncookie {
uint8_t cookie;
@@ -103,7 +170,7 @@ pf_syncookie_send(struct pf_pdesc *pd, u_short *reason)
uint16_t mss, mssdflt;
uint32_t iss;
mssdflt = atomic_load_int(&tcp_mssdflt);
mssdflt = atomic_load_int(&pfk_tcp_mssdflt);
mss = max(pf_get_mss(pd, mssdflt), mssdflt);
iss = pf_syncookie_generate(pd, mss);
pf_send_tcp(NULL, pd->af, pd->dst, pd->src, *pd->dport, *pd->sport,
+51 -10
View File
@@ -1,5 +1,46 @@
/* PFLINUX port of OpenBSD 8.0 net/pf_table.c — see docs/porting-notes.md */
#include <pfk.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
/* $OpenBSD: pf_table.c,v 1.151 2026/10/02 09:40:22 sashan Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifdef INET6
#endif /* INET6 */
#define ACCEPT_FLAGS(flags, oklist) \
do { \
@@ -26,14 +67,14 @@
#define FILLIN_SIN(sin, addr) \
do { \
(sin)./* PFLINUX sin_len */; \
; \
(sin).sin_family = AF_INET; \
(sin).sin_addr = (addr); \
} while (0)
#define FILLIN_SIN6(sin6, addr) \
do { \
(sin6).sin6_len = sizeof(sin6); \
; \
(sin6).sin6_family = AF_INET6; \
(sin6).sin6_addr = (addr); \
} while (0)
@@ -1215,13 +1256,13 @@ pfr_prepare_network(union sockaddr_union *sa, int af, int net)
bzero(sa, sizeof(*sa));
switch (af) {
case AF_INET:
sa->sin./* PFLINUX sin_len */;
;
sa->sin.sin_family = AF_INET;
sa->sin.sin_addr.s_addr = net ? htonl(-1 << (32-net)) : 0;
break;
#ifdef INET6
case AF_INET6:
sa->sin6.sin6_len = sizeof(sa->sin6);
;
sa->sin6.sin6_family = AF_INET6;
for (i = 0; i < 4; i++) {
if (net <= 32) {
@@ -2416,7 +2457,7 @@ pfr_kentry_byaddr(struct pfr_ktable *kt, struct pf_addr *a, sa_family_t af,
switch (af) {
case AF_INET:
bzero(&tmp4, sizeof(tmp4));
tmp4./* PFLINUX sin_len */;
;
tmp4.sin_family = AF_INET;
tmp4.sin_addr.s_addr = a->addr32[0];
ke = (struct pfr_kentry *)rn_match(&tmp4, kt->pfrkt_ip4);
@@ -2424,7 +2465,7 @@ pfr_kentry_byaddr(struct pfr_ktable *kt, struct pf_addr *a, sa_family_t af,
#ifdef INET6
case AF_INET6:
bzero(&tmp6, sizeof(tmp6));
tmp6.sin6_len = sizeof(tmp6);
;
tmp6.sin6_family = AF_INET6;
bcopy(a, &tmp6.sin6_addr, sizeof(tmp6.sin6_addr));
ke = (struct pfr_kentry *)rn_match(&tmp6, kt->pfrkt_ip6);
@@ -2460,7 +2501,7 @@ pfr_update_stats(struct pfr_ktable *kt, struct pf_addr *a, struct pf_pdesc *pd,
switch (af) {
case AF_INET:
bzero(&tmp4, sizeof(tmp4));
tmp4./* PFLINUX sin_len */;
;
tmp4.sin_family = AF_INET;
tmp4.sin_addr.s_addr = a->addr32[0];
ke = (struct pfr_kentry *)rn_match(&tmp4, kt->pfrkt_ip4);
@@ -2468,7 +2509,7 @@ pfr_update_stats(struct pfr_ktable *kt, struct pf_addr *a, struct pf_pdesc *pd,
#ifdef INET6
case AF_INET6:
bzero(&tmp6, sizeof(tmp6));
tmp6.sin6_len = sizeof(tmp6);
;
tmp6.sin6_family = AF_INET6;
bcopy(a, &tmp6.sin6_addr, sizeof(tmp6.sin6_addr));
ke = (struct pfr_kentry *)rn_match(&tmp6, kt->pfrkt_ip6);
@@ -2597,14 +2638,14 @@ pfr_pool_get(struct pf_pool *rpool, struct pf_addr **raddr,
switch (af) {
case AF_INET:
bzero(&tmp4, sizeof(tmp4));
tmp4./* PFLINUX sin_len */;
;
tmp4.sin_family = AF_INET;
addr = (struct pf_addr *)&tmp4.sin_addr;
break;
#ifdef INET6
case AF_INET6:
bzero(&tmp6, sizeof(tmp6));
tmp6.sin6_len = sizeof(tmp6);
;
tmp6.sin6_family = AF_INET6;
addr = (struct pf_addr *)&tmp6.sin6_addr;
break;
-92
View File
@@ -1,92 +0,0 @@
/*
* PF-on-Linux netfilter hook registration + M1 ioctl skeleton.
* The real verdict logic arrives from staged pf.c (T12); this file owns
* hook lifecycle and /dev/pf dispatch. (ISC 2026)
*/
#include <pfk.h>
#include <pfk_api.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
static int pfk_enabled = 1; /* like pf_defaultwise/pf_enable on boot */
static struct pf_status pfk_stat;
/* --- temporary M1 control surface (replaced by staged pf_ioctl.c, T7b) --- */
static int pfk_ioctl_min(struct file *f, unsigned int cmd, unsigned long addr)
{
struct pf_status s;
switch (cmd) {
case DIOCGETSTATUS:
memset(&s, 0, sizeof(s));
s.running = pfk_enabled;
strscpy(s.ifname, "pf", sizeof(s.ifname));
if (copy_to_user((void __user *)addr, &s, sizeof(s)))
return EFAULT;
return 0;
default:
/* Rule/state/table ioctls arrive with the staged pf_ioctl.c
* (plan T7b); until then they are rejected (not silently
* accepted) so behaviour is explicit. */
return EINVAL;
}
}
long pfk_ioctl(struct file *f, unsigned int cmd, unsigned long addr)
{
return pfk_ioctl_min(f, cmd, addr);
}
void pfk_status(struct pf_status *s)
{
if (s)
*s = pfk_stat;
}
int pfk_enable(int on) { pfk_enabled = on ? 1 : 0; return 0; }
/* --- netfilter hooks: ingress/egress plumbing (real work lands in T12) --- */
static unsigned int
pfk_ipv4_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st)
{
/* PFLINUX M1: accept-everything placeholder; T12 routes to pf_test() */
return NF_ACCEPT;
}
static struct nf_hook_ops pfk_hooks[] = {
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_PRE_ROUTING,
.priority = NF_IP_PRI_FIRST },
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_LOCAL_IN,
.priority = NF_IP_PRI_FIRST + 1 },
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_FORWARD,
.priority = NF_IP_PRI_FIRST },
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_LOCAL_OUT,
.priority = NF_IP_PRI_CONNTRACK + 1 },
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_POST_ROUTING,
.priority = NF_IP_PRI_LAST - 1 },
};
#define PFK_NHOOKS ARRAY_SIZE(pfk_hooks)
int pfk_hooks_register(void)
{
int i, err;
for (i = 0; i < PFK_NHOOKS; i++) {
pfk_hooks[i].priv = NULL;
err = nf_register_net_hook(&init_net, &pfk_hooks[i]);
if (err)
goto fail;
}
return 0;
fail:
while (--i >= 0)
nf_unregister_net_hook(&init_net, &pfk_hooks[i]);
return err;
}
void pfk_hooks_unregister(void)
{
int i;
for (i = 0; i < PFK_NHOOKS; i++)
nf_unregister_net_hook(&init_net, &pfk_hooks[i]);
}
-86
View File
@@ -1,86 +0,0 @@
/*
* PF-on-Linux: pfk module core — load/exit, /dev/pf misc device,
* NET_LOCK bring-up, staged upstream bring-up hooks. (ISC 2026)
*/
#include <pfk.h>
#include <pfk_api.h>
#include <net/pfvar.h>
#include <net/pfvar_priv.h>
extern void pfk_mbuf_exit(void);
extern int pfk_if_init(void);
extern void pfk_if_exit(void);
static int pfk_open(struct inode *inode, struct file *filp)
{
if (filp->f_mode & FMODE_WRITE)
return capable(CAP_NET_ADMIN) ? 0 : -EPERM;
return 0;
}
static long pfk_ioctl_io(struct file *filp, unsigned int cmd,
unsigned long arg)
{
if (!capable(CAP_NET_ADMIN))
return -EPERM;
return pfk_ioctl(filp, cmd, arg);
}
static const struct file_operations pfk_fops = {
.owner = THIS_MODULE,
.open = pfk_open,
.unlocked_ioctl = pfk_ioctl_io,
.compat_ioctl = compat_ptr_ioctl,
};
static struct miscdevice pfk_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "pf",
.fops = &pfk_fops,
.mode = 0600,
};
static int __init pfk_init(void)
{
int err;
pfk_net_lock_init();
err = pfk_mbuf_init();
if (err)
return err;
err = pfk_if_init();
if (err)
goto err_mbuf;
err = pfk_hooks_register();
if (err)
goto err_if;
err = misc_register(&pfk_dev);
if (err)
goto err_hooks;
pr_info("pfk: PF-on-Linux engine loaded (OpenBSD 8.0 base)\n");
return 0;
err_hooks:
pfk_hooks_unregister();
err_if:
pfk_if_exit();
err_mbuf:
pfk_mbuf_exit();
return err;
}
static void __exit pfk_exit(void)
{
misc_deregister(&pfk_dev);
pfk_hooks_unregister();
pfk_if_exit();
pfk_mbuf_exit();
pr_info("pfk: unloaded\n");
}
module_init(pfk_init);
module_exit(pfk_exit);
MODULE_LICENSE("Dual MIT/GPL"); /* ISC/BSD code; Dual MIT/GPL is the kernel-
* recognised tag for permissive BSD-licensed
* modules linking GPL exports (see LICENSE). */
MODULE_DESCRIPTION("PF packet filter (ported from OpenBSD 8.0) for Linux");
MODULE_AUTHOR("PF-on-Linux contributors");
+3 -1
View File
@@ -40,7 +40,7 @@ deb_cmd() { deb "bash -s" <<<"$1"; }
# Run a shell script inside a lab VM (nested ssh from deb with the lab key).
# Guest host keys change every lab rebuild -> pin-noise disabled for this hop.
VMSSH_OPTS="-o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5 -o LogLevel=ERROR"
vm_cmd() { local ip=$1; deb "ssh -i $LAB_KEY_DEB $VMSSH_OPTS root@$ip 'bash -s'" <<<"$2"; }
vm_cmd() { local ip=$1; deb "ssh -i $LAB_KEY_DEB $VMSSH_OPTS root@$ip 'sh -s'" <<<"$2"; }
# --- template rendering: replace @KEY@ tokens from environment + extra K=V ---
RENDER_KEYS=(
@@ -164,6 +164,7 @@ runcmd_extra() {
cat > /etc/local.d/pflab.start <<'EOS'
#!/bin/sh
sysctl -q -p /etc/sysctl.d/00-pflab.conf 2>/dev/null
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > "$f" 2>/dev/null; done
IF=$(ip route show default 2>/dev/null | awk '{print $5; exit}')
[ -n "$IF" ] || exit 0
iptables -t nat -A POSTROUTING -o "$IF" -j MASQUERADE
@@ -222,6 +223,7 @@ packages_fixup() { # safety net if cloud-init ran before pf0 had transit up
for a in $VMS; do
ip=$(vm_ip "$a")
vm_cmd "$ip" 'command -v iperf3 >/dev/null 2>&1 && command -v iptables >/dev/null 2>&1 || {
grep -q nameserver /etc/resolv.conf 2>/dev/null || echo nameserver 192.168.122.1 >> /etc/resolv.conf
. /etc/os-release
grep -qE "^[^#]*/community" /etc/apk/repositories || echo "${HOME}/v${VERSION_ID}/community" >> /etc/apk/repositories
apk update -q >/dev/null 2>&1
+120 -89
View File
@@ -1,112 +1,143 @@
#!/usr/bin/env bash
# Deterministic staging of OpenBSD 8.0 sources into module/ ports.
# Deterministic staging of OpenBSD 8.0 sources into the module/ port.
#
# Every transformation is logged in docs/porting-notes.md ("porting log").
# Re-running refreshes pristine copies while PRESERVING our port edits is
# NOT done here — ported files are committed and edited in-tree thereafter;
# this script is used (a) first-time staging, (b) `--diff <file>` to compare
# our ported copy against pristine upstream for rebase forensics.
# Ported files are committed and edited in-tree afterwards; this script is
# used (a) for first-time staging, (b) with `--diff <file>` to compare our
# ported copy against the pristine upstream file (rebase forensics).
set -euo pipefail
REPO="$(cd "$(dirname "$0")/.." && pwd)"
U="$REPO/_vendor/upstream"
M="$REPO/module"
LOG="$REPO/docs/porting-notes.md"
# --- shared rename program -------------------------------------------------
# BSD type/macro names that collide with Linux uapi or with the kernel's own
# macros are renamed to our pf_* equivalents. Applied to the staged headers
# and to every ported .c file.
pf_sed() {
sed -i -E \
-e 's/\bstruct ip6_hdr\b/struct pf_ip6_hdr/g' \
-e 's/\bstruct ip\b/struct pf_ip/g' \
-e 's/\bstruct tcphdr\b/struct pf_tcphdr/g' \
-e 's/\bstruct udphdr\b/struct pf_udphdr/g' \
-e 's/\bstruct icmp\b/struct pf_icmp/g' \
-e 's/\bstruct icmp6_hdr\b/struct pf_icmp6/g' \
-e 's/\bstruct mld_hdr\b/struct pf_mld_hdr/g' \
-e 's/\bstruct nd_neighbor_solicit\b/struct pf_nd_neighbor_solicit/g' \
-e 's/\bstruct rtentry\b/struct pf_rtentry/g' \
-e 's/\bstruct ifnet\b/struct pfk_ifnet/g' \
-e 's/\bIFF_([A-Z0-9_]+)/PFIFF_\1/g' \
-e 's/\bIP_OPTIONS\b/PF_IP_OPTIONS/g' \
-e 's/\bIP_RECORD_ROUTE\b/PF_IP_RECORD_ROUTE/g' \
-e 's/\bIP_TIMESTAMP\b/PF_IP_TIMESTAMP/g' \
-e 's/ip6_fragment[(]/pfk_ip6_fragment(/g' \
-e 's/in6_proto_cksum_out[(]/pfk_in6_proto_cksum_out(/g' \
-e 's/ip6_forward[(]/pfk_ip6_forward(/g' \
-e 's/ifp->if_output[(]/pfk_if_output(/g' \
-e 's/pfk_if_output[(]ifp, m, sin6tosa[(]dst[)]/pfk_if_output(ifp, m, (struct sockaddr *)sin6tosa(dst)/g' \
-e 's/pfk_if_output[(]ifp, m, sintosa[(]dst[)]/pfk_if_output(ifp, m, (struct sockaddr *)sintosa(dst)/g' \
-e 's/^([ \t]*)[^;]*\.(sa|sin|sin6|six|sun)[0-9]*_len[[:space:]]*=[^;]*;/\1;/' \
-e 's/struct radix_node \[2\], u_int8_t\);/struct radix_node *, u_int8_t);/' \
-e '/^#define[[:space:]]+isupper\(c\)/d' \
-e '/^#define[[:space:]]+islower\(c\)/d' \
-e '/^#define[[:space:]]+isalpha\(c\)/d' \
-e 's/\btcp_mssdflt\b/pfk_tcp_mssdflt/g' \
-e 's/([a-z0-9_]+)->p_ucred->cr_ruid/pfk_pruid(\1)/g' \
-e 's/([a-z0-9_]+)->p_ucred->cr_uid/pfk_pruid(\1)/g' \
-e 's/([a-z0-9_]+)->p_p->ps_pid/pfk_ppid(\1)/g' \
-e 's/^([a-zA-Z_][a-zA-Z0-9_ \t\*]*\b[a-zA-Z_][a-zA-Z0-9_]*)\(\);/\1(void);/' \
"$@"
}
stage_hdrs() {
mkdir -p "$M/include/net" "$M/include/compat/net" "$M/include/compat/sys" "$M/include/compat/crypto"
cp -f "$U/sys/net/pfvar.h" "$M/include/net/pfvar.h"
cp -f "$U/sys/net/pfvar_priv.h" "$M/include/net/pfvar_priv.h"
cp -f "$U/sys/net/if_pflog.h" "$M/include/compat/net/if_pflog.h"
cp -f "$U/sys/net/radix.h" "$M/include/compat/net/radix.h"
cp -f "$U/sys/net/rtable.h" "$M/include/compat/net/rtable.h"
cp -f "$U/sys/net/ifq.h" "$M/include/compat/net/ifq.h"
cp -f "$U/sys/net/toeplitz.h" "$M/include/compat/net/toeplitz.h"
cp -f "$U/sys/sys/queue.h" "$M/include/compat/sys/queue.h"
cp -f "$U/sys/sys/tree.h" "$M/include/compat/sys/tree.h"
# NOTE: radix.h / siphash.h / toeplitz.h are NOT copied verbatim — our
# cleaned PFLINUX versions live in module/include/compat/{net,crypto}/
# (BSD syntax like __bounded / _BYTE_ORDER does not compile in-kernel).
mkdir -p "$M/include/net" "$M/include/compat/net" \
"$M/include/compat/sys" "$M/include/compat/crypto"
cp -f "$U/sys/net/pfvar.h" "$M/include/net/pfvar.h"
cp -f "$U/sys/net/pfvar_priv.h" "$M/include/net/pfvar_priv.h"
pf_sed "$M/include/net/pfvar.h" "$M/include/net/pfvar_priv.h"
cp -f "$U/sys/sys/queue.h" "$M/include/compat/sys/queue.h"
cp -f "$U/sys/sys/tree.h" "$M/include/compat/sys/tree.h"
# GCC requires the attribute AFTER the storage class when 'inline'
# follows (OpenBSD writes '__unused static inline').
sed -i 's/^__unused static inline/static inline/' \
"$M/include/compat/sys/tree.h"
# NOTE: radix.h / rtable.h / ifq.h / toeplitz.h / siphash.h are NOT
# copied verbatim — our cleaned PFLINUX versions live in
# module/include/compat/{net,crypto}/ (BSD syntax such as __bounded
# or _BYTE_ORDER does not compile in-kernel). Never overwrite them.
}
stage_c() { # relpath upstream -> module/compat|pf
local up="$1" dst="$2"
cp -f "$up" "$dst"
}
# port_c <upstream-sys-rel> <module-rel> : first-time staging of an OpenBSD
# .c file with deterministic transformations (all logged to PORT notes):
# 1. all original #include lines -> single '#include <pfk.h>' (+ keep
# none: pfvar is pulled by pfk.h chain when needed via -I)
# 2. BSD wire struct renames (avoid Linux-uapi collisions):
# ip6_hdr→pf_ip6_hdr, struct ip→pf_ip, tcphdr→pf_tcphdr,
# udphdr→pf_udphdr, struct icmp→pf_icmp, icmp6_hdr→icmp6hdr
# 3. BSD IFF_* flag names -> PFIFF_* (Linux owns IFF_*)
# 4. sa_len/sin_len/six_len assignment statements commented out
# 5. '#if NPFLOG > 0'-style option headers were never included (dropped)
# port_c <upstream-sys-rel> <module-rel>
# 1. every '#include' line is removed and replaced by pfk.h + the pfvar
# headers; all '#ifdef _KERNEL' guards stay intact (the module is built
# with -D_KERNEL=1, so the kernel branches are compiled).
# 2. the shared rename program is applied.
port_c() {
local up="$U/sys/$1" dst="$M/$2"
[ -f "$up" ] || { echo "no upstream $1" >&2; return 1; }
mkdir -p "$(dirname "$dst")"
if [ -f "$dst" ]; then echo "EXISTS: $2 (not re-staged; use --diff)"; return 0; fi
{
printf '/* PFLINUX port of OpenBSD 8.0 %s — see docs/porting-notes.md */\n' "$1"
printf '#include <pfk.h>\n'
# keep everything after the last original #include (body)
awk 'BEGIN{last=0} /^#include/{last=NR} END{print last}' "$up" |
{ read n; tail -n +$((n+1)) "$up"; }
} > "$dst.part"
sed -i -E \
-e 's/\bstruct ip6_hdr\b/struct pf_ip6_hdr/g' \
-e 's/\bstruct ip\b/struct pf_ip/g' \
-e 's/\bstruct tcphdr\b/struct pf_tcphdr/g' \
-e 's/\bstruct udphdr\b/struct pf_udphdr/g' \
-e 's/\bstruct icmp\b/struct pf_icmp/g' \
-e 's/\bstruct icmp6_hdr\b/struct icmp6hdr/g' \
-e 's/\bIFF_([A-Z0-9_]+)/PFIFF_\1/g' \
-e 's/\bIP_OPTIONS\b/PF_IP_OPTIONS/g' \
-e 's/\bIP_RECORD_ROUTE\b/PF_IP_RECORD_ROUTE/g' \
-e 's/\bIP_TIMESTAMP\b/PF_IP_TIMESTAMP/g' \
-e 's/->sa_len[[:space:]]*=[^;]*;/\/* PFLINUX sa_len: *\/;/g' \
-e 's/([a-z0-9_]*(sa|sin|six|sun)_len)[[:space:]]*=[^;]*;/\/* PFLINUX \1 *\/;/g' \
"$dst.part"
mv "$dst.part" "$dst"
log "port_c $1 -> $2 (includes→pfk.h; struct renames; sa_len nulled)"
local up="$U/sys/$1" dst="$M/$2"
[ -f "$up" ] || { echo "no upstream $1" >&2; return 1; }
mkdir -p "$(dirname "$dst")"
if [ -f "$dst" ]; then
echo "EXISTS: $2 (not re-staged; use --diff)"
return 0
fi
{
printf '/* PFLINUX port of OpenBSD 8.0 %s — see docs/porting-notes.md */\n' "$1"
printf '#include <pfk.h>\n'
printf '#include <net/pfvar.h>\n'
printf '#include <net/pfvar_priv.h>\n\n'
sed -E '/^[[:space:]]*#include/d' "$up"
} > "$dst.part"
pf_sed "$dst.part"
mv "$dst.part" "$dst"
log "port_c $1 -> $2 (includes dropped -> pfk.h; -D_KERNEL mode; renames)"
}
PORTED_LIST='net/pf.c net/pf_ioctl.c net/pf_norm.c net/pf_if.c net/pf_lb.c
net/pf_ruleset.c net/pf_table.c net/pf_osfp.c net/pf_syncookies.c
net/ifq.c net/hfsc.c net/fq_codel.c net/if_pflog.c netinet/ip_divert.c
crypto/md5.c crypto/sha2.c'
# NOTE: radix.c/rtable.c (ported by hand in T10 against our cleaned
# compat/net/radix.h) and siphash/toeplitz (own PFLINUX impls) are
# deliberately NOT in the auto-port list.
# radix.c/rtable.c (hand-ported against our cleaned compat/net/radix.h) and
# siphash/toeplitz (own PFLinux implementations) are deliberately NOT in the
# automatic list.
log() { mkdir -p "$(dirname "$LOG")"; printf '\n%s\n```sh\n%s\n```\n' "## $(date -Is) staging" "$*" >> "$LOG"; }
log() {
mkdir -p "$(dirname "$LOG")"
printf '\n## %s staging\n\n```sh\n%s\n```\n' "$(date -Is)" "$*" >> "$LOG"
}
cmd="${1:-stage}"
case "$cmd" in
stage)
log "stage: headers + skeletons"
stage_hdrs
echo "headers staged: $(find "$M/include/net" "$M/include/compat" -type f | wc -l)"
;;
port)
shift
for f in ${*:-$PORTED_LIST}; do
case "$f" in
net/pf.c|net/pf_ioctl.c|net/pf_norm.c|net/pf_if.c|net/pf_lb.c|\
net/pf_ruleset.c|net/pf_table.c|net/pf_osfp.c|net/pf_syncookies.c|\
net/ifq.c|net/hfsc.c|net/fq_codel.c|net/if_pflog.c)
port_c "$f" "pfsrc/${f##*/}";;
netinet/ip_divert.c)
port_c "$f" "pfsrc/ip_divert.c";;
crypto/md5.c|crypto/sha2.c)
port_c "$f" "compat/${f##*/}";;
esac
done
;;
--diff)
[ -f "$U/$2" ] || { echo "no pristine $2"; exit 1; }
diff -u "$U/$2" "$M/$2" | head -80
;;
*) echo "usage: stage-port.sh [stage|--diff relpath]"; exit 1;;
stage)
log "stage: headers"
stage_hdrs
echo "headers staged: $(find "$M/include/net" "$M/include/compat" -type f | wc -l)"
;;
port)
shift
for f in ${*:-$PORTED_LIST}; do
case "$f" in
net/pf.c|net/pf_ioctl.c|net/pf_norm.c|net/pf_if.c|net/pf_lb.c|\
net/pf_ruleset.c|net/pf_table.c|net/pf_osfp.c|net/pf_syncookies.c|\
net/ifq.c|net/hfsc.c|net/fq_codel.c|net/if_pflog.c)
port_c "$f" "pfsrc/${f##*/}" ;;
net/radix.c|net/rtable.c)
port_c "$f" "compat/${f##*/}" ;;
netinet/ip_divert.c)
port_c "$f" "pfsrc/ip_divert.c" ;;
crypto/md5.c|crypto/sha2.c)
port_c "$f" "compat/${f##*/}" ;;
esac
done
;;
--diff)
[ -f "$U/$2" ] || { echo "no pristine $2"; exit 1; }
diff -u "$U/$2" "$M/$2" | head -80
;;
*)
echo "usage: stage-port.sh [stage|port [files...]|--diff relpath]"
exit 1
;;
esac
+4 -3
View File
@@ -28,7 +28,6 @@ done
lab_env
command -v rsync >/dev/null || die "rsync missing on laptop"
command -v genisoimage >/dev/null 2>&1 || true # iso is built on deb, not here
host_prereqs
ensure_networks
@@ -55,7 +54,9 @@ if [ -n "$PF0_KERNEL" ]; then
rsync -a -e "ssh ${SSH_OPTS[*]}" "$PF0_INITRD" "$DEB_USER@$DEB:$BOOT_DIR/initrd"
IPATH="$BOOT_DIR/initrd"
fi
PF0_KB=" <kernel>$KPATH</kernel>"$'\n'" <initrd>$IPATH</initrd>"$'\n'" <cmdline>root=/dev/vda2 ro console=ttyS0,115200n8</cmdline>"
# with an initrd, Alpine's initramfs needs its module list on the cmdline;
# the no-initrd (built-in drivers, T6) case keeps the plain contract cmdline
PF0_KB=" <kernel>$KPATH</kernel>"$'\n'" <initrd>$IPATH</initrd>"$'\n'" <cmdline>root=/dev/vda2 ro console=ttyS0,115200n8 modules=sd-mod,usb-storage,ext4,ena,gve</cmdline>"
fi
log "pf0 direct kernel boot override: $KPATH"
fi
@@ -72,6 +73,6 @@ deb_ssh_config
laptop_ssh_config
log "validate: ssh pf0 'ip -br a'"
ssh "${SSH_OPTS[@]}" pf0 'ip -br a' || warn "ssh pf0 failed — check $LAPTOP_SSH_FRAG"
ssh "${SSH_OPTS[@]}" pf0 'ip -br a' || die "ssh pf0 failed — check $LAPTOP_SSH_FRAG"
log "LAB UP: aliases on laptop: ssh pf0|cli|srv|gw2 (ProxyJump $DEB_USER@$DEB)"
deb "virsh list" || true
+4 -3
View File
@@ -13,16 +13,17 @@ lab_env
cd "$REPO"
FILES=()
add() { # add <path...> — files only; dirs expanded
add() { # add <path...> — files only; dirs expanded; warns on explicit misses
local p
for p in "$@"; do
if [ -d "$p" ]; then add "$p"/*
elif [ -f "$p" ]; then FILES+=("$p")
elif [ "$EXPLICIT" = 1 ]; then warn "skip missing: $p"
fi
done
}
if [ $# -gt 0 ]; then
add "$@"
EXPLICIT=0
if [ $# -gt 0 ]; then EXPLICIT=1; add "$@"
else
shopt -s nullglob
add out/linux-*-bzImage out/bzImage out/*.ko module/*.ko tools/out/*