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

+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;