@zigc/lib 0.17.0-dev.332 → 0.17.0-dev.340

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/libc/include/aarch64-openbsd-none/arm64/cpu.h +7 -1
  2. package/libc/include/aarch64-openbsd-none/arm64/intr.h +9 -1
  3. package/libc/include/aarch64-openbsd-none/machine/cpu.h +7 -1
  4. package/libc/include/aarch64-openbsd-none/machine/intr.h +9 -1
  5. package/libc/include/generic-openbsd/db.h +1 -7
  6. package/libc/include/generic-openbsd/ddb/db_interface.h +2 -1
  7. package/libc/include/generic-openbsd/fnmatch.h +6 -2
  8. package/libc/include/generic-openbsd/login_cap.h +3 -1
  9. package/libc/include/generic-openbsd/miscfs/fuse/fusefs_node.h +2 -1
  10. package/libc/include/generic-openbsd/net/bpf.h +3 -1
  11. package/libc/include/generic-openbsd/net/hfsc.h +4 -4
  12. package/libc/include/generic-openbsd/net/if.h +5 -1
  13. package/libc/include/generic-openbsd/net/if_bridge.h +48 -1
  14. package/libc/include/generic-openbsd/net/if_etherbridge.h +20 -7
  15. package/libc/include/generic-openbsd/net/if_media.h +26 -1
  16. package/libc/include/generic-openbsd/net/if_pflow.h +71 -20
  17. package/libc/include/generic-openbsd/net/if_pfsync.h +2 -2
  18. package/libc/include/generic-openbsd/net/if_sppp.h +2 -1
  19. package/libc/include/generic-openbsd/net/if_trunk.h +3 -2
  20. package/libc/include/generic-openbsd/net/if_types.h +2 -2
  21. package/libc/include/generic-openbsd/net/if_var.h +34 -12
  22. package/libc/include/generic-openbsd/net/netisr.h +1 -3
  23. package/libc/include/generic-openbsd/net/pfvar.h +154 -1
  24. package/libc/include/generic-openbsd/net/pfvar_priv.h +256 -1
  25. package/libc/include/generic-openbsd/net80211/ieee80211.h +76 -4
  26. package/libc/include/generic-openbsd/net80211/ieee80211_ioctl.h +3 -2
  27. package/libc/include/generic-openbsd/net80211/ieee80211_node.h +48 -2
  28. package/libc/include/generic-openbsd/net80211/ieee80211_proto.h +4 -1
  29. package/libc/include/generic-openbsd/net80211/ieee80211_var.h +18 -2
  30. package/libc/include/generic-openbsd/netinet/if_ether.h +12 -11
  31. package/libc/include/generic-openbsd/netinet/igmp_var.h +17 -3
  32. package/libc/include/generic-openbsd/netinet/in_pcb.h +2 -1
  33. package/libc/include/generic-openbsd/netinet/in_var.h +17 -59
  34. package/libc/include/generic-openbsd/netinet/ip.h +3 -2
  35. package/libc/include/generic-openbsd/netinet/tcp_timer.h +1 -2
  36. package/libc/include/generic-openbsd/netinet6/in6_var.h +15 -29
  37. package/libc/include/generic-openbsd/netinet6/ip6_var.h +1 -2
  38. package/libc/include/generic-openbsd/netinet6/mld6_var.h +17 -4
  39. package/libc/include/generic-openbsd/netinet6/nd6.h +2 -2
  40. package/libc/include/generic-openbsd/pthread.h +2 -2
  41. package/libc/include/generic-openbsd/signal.h +2 -2
  42. package/libc/include/generic-openbsd/sndio.h +6 -12
  43. package/libc/include/generic-openbsd/strings.h +5 -1
  44. package/libc/include/generic-openbsd/sys/device.h +4 -3
  45. package/libc/include/generic-openbsd/sys/disklabel.h +17 -5
  46. package/libc/include/generic-openbsd/sys/dkio.h +3 -5
  47. package/libc/include/generic-openbsd/sys/filedesc.h +3 -2
  48. package/libc/include/generic-openbsd/sys/mbuf.h +1 -1
  49. package/libc/include/generic-openbsd/sys/mman.h +7 -2
  50. package/libc/include/generic-openbsd/sys/mutex.h +10 -7
  51. package/libc/include/generic-openbsd/sys/namei.h +8 -7
  52. package/libc/include/generic-openbsd/sys/param.h +1 -1
  53. package/libc/include/generic-openbsd/sys/pledge.h +1 -3
  54. package/libc/include/generic-openbsd/sys/protosw.h +8 -1
  55. package/libc/include/generic-openbsd/sys/ptrace.h +4 -1
  56. package/libc/include/generic-openbsd/sys/sched.h +8 -1
  57. package/libc/include/generic-openbsd/sys/signal.h +4 -2
  58. package/libc/include/generic-openbsd/sys/socketvar.h +2 -1
  59. package/libc/include/generic-openbsd/sys/sockio.h +11 -1
  60. package/libc/include/generic-openbsd/sys/syscall.h +5 -3
  61. package/libc/include/generic-openbsd/sys/syscallargs.h +9 -2
  62. package/libc/include/generic-openbsd/sys/sysctl.h +7 -4
  63. package/libc/include/generic-openbsd/sys/types.h +6 -2
  64. package/libc/include/generic-openbsd/sys/videoio.h +143 -68
  65. package/libc/include/generic-openbsd/sys/xcall.h +2 -2
  66. package/libc/include/generic-openbsd/time.h +2 -2
  67. package/libc/include/generic-openbsd/unistd.h +2 -2
  68. package/libc/include/generic-openbsd/uvm/uvm_anon.h +2 -3
  69. package/libc/include/generic-openbsd/uvm/uvm_extern.h +1 -19
  70. package/libc/include/generic-openbsd/uvm/uvm_pager.h +3 -4
  71. package/libc/include/generic-openbsd/uvm/uvm_pmemrange.h +1 -2
  72. package/libc/include/generic-openbsd/uvm/uvm_swap.h +4 -1
  73. package/libc/include/generic-openbsd/uvm/uvm_vnode.h +3 -4
  74. package/libc/include/generic-openbsd/uvm/uvmexp.h +41 -35
  75. package/libc/include/mips64-openbsd-none/machine/octeonvar.h +1 -27
  76. package/libc/include/mips64-openbsd-none/octeon/octeonvar.h +1 -27
  77. package/libc/include/mips64el-openbsd-none/loongson/apmvar.h +1 -1
  78. package/libc/include/mips64el-openbsd-none/loongson/param.h +1 -5
  79. package/libc/include/mips64el-openbsd-none/machine/apmvar.h +1 -1
  80. package/libc/include/mips64el-openbsd-none/machine/param.h +1 -5
  81. package/libc/include/powerpc-openbsd-eabihf/powerpc/intr.h +1 -4
  82. package/libc/include/powerpc64-openbsd-none/machine/atomic.h +3 -3
  83. package/libc/include/powerpc64-openbsd-none/powerpc64/atomic.h +3 -3
  84. package/libc/include/riscv64-openbsd-none/machine/cpu.h +4 -8
  85. package/libc/include/riscv64-openbsd-none/machine/cpufunc.h +4 -4
  86. package/libc/include/riscv64-openbsd-none/machine/pmap.h +5 -1
  87. package/libc/include/riscv64-openbsd-none/machine/pte.h +9 -1
  88. package/libc/include/riscv64-openbsd-none/riscv64/cpu.h +4 -8
  89. package/libc/include/riscv64-openbsd-none/riscv64/cpufunc.h +4 -4
  90. package/libc/include/riscv64-openbsd-none/riscv64/pmap.h +5 -1
  91. package/libc/include/riscv64-openbsd-none/riscv64/pte.h +9 -1
  92. package/libc/include/x86-openbsd-none/i386/specialreg.h +3 -1
  93. package/libc/include/x86-openbsd-none/machine/specialreg.h +3 -1
  94. package/libc/include/x86_64-openbsd-none/amd64/conf.h +11 -2
  95. package/libc/include/x86_64-openbsd-none/amd64/cpu.h +14 -4
  96. package/libc/include/x86_64-openbsd-none/amd64/cpufunc.h +2 -3
  97. package/libc/include/x86_64-openbsd-none/amd64/ghcb.h +2 -1
  98. package/libc/include/x86_64-openbsd-none/amd64/i82489var.h +2 -4
  99. package/libc/include/x86_64-openbsd-none/amd64/i8259.h +1 -53
  100. package/libc/include/x86_64-openbsd-none/amd64/intr.h +5 -2
  101. package/libc/include/x86_64-openbsd-none/amd64/intrdefs.h +9 -7
  102. package/libc/include/x86_64-openbsd-none/amd64/kexec.h +48 -0
  103. package/libc/include/x86_64-openbsd-none/amd64/specialreg.h +4 -1
  104. package/libc/include/x86_64-openbsd-none/machine/conf.h +11 -2
  105. package/libc/include/x86_64-openbsd-none/machine/cpu.h +14 -4
  106. package/libc/include/x86_64-openbsd-none/machine/cpufunc.h +2 -3
  107. package/libc/include/x86_64-openbsd-none/machine/ghcb.h +2 -1
  108. package/libc/include/x86_64-openbsd-none/machine/i82489var.h +2 -4
  109. package/libc/include/x86_64-openbsd-none/machine/i8259.h +1 -53
  110. package/libc/include/x86_64-openbsd-none/machine/intr.h +5 -2
  111. package/libc/include/x86_64-openbsd-none/machine/intrdefs.h +9 -7
  112. package/libc/include/x86_64-openbsd-none/machine/kexec.h +48 -0
  113. package/libc/include/x86_64-openbsd-none/machine/specialreg.h +4 -1
  114. package/libc/openbsd/abilists +0 -0
  115. package/package.json +1 -1
  116. package/std/Io/File.zig +6 -0
  117. package/std/Target.zig +2 -7
  118. package/std/bit_set.zig +0 -1
  119. package/std/crypto/ascon.zig +0 -2
  120. package/std/crypto/salsa20.zig +0 -6
  121. package/std/crypto/sha3.zig +0 -2
  122. package/std/debug/cpu_context.zig +0 -21
  123. package/libc/include/mips64el-openbsd-none/loongson/hibernate.h +0 -33
  124. package/libc/include/mips64el-openbsd-none/loongson/hibernate_var.h +0 -39
  125. package/libc/include/mips64el-openbsd-none/machine/hibernate.h +0 -33
  126. package/libc/include/mips64el-openbsd-none/machine/hibernate_var.h +0 -39
@@ -1,4 +1,4 @@
1
- /* $OpenBSD: if_sppp.h,v 1.31 2025/01/15 06:15:44 dlg Exp $ */
1
+ /* $OpenBSD: if_sppp.h,v 1.32 2025/11/02 08:04:04 dlg Exp $ */
2
2
  /* $NetBSD: if_sppp.h,v 1.2.2.1 1999/04/04 06:57:39 explorer Exp $ */
3
3
 
4
4
  /*
@@ -174,6 +174,7 @@ struct sppp {
174
174
  time_t pp_last_receive; /* peer's last "sign of life" */
175
175
  time_t pp_last_activity; /* second of last payload data s/r */
176
176
  enum ppp_phase pp_phase; /* phase we're currently in */
177
+ struct task pp_autodial;
177
178
  int state[IDX_COUNT]; /* state machine */
178
179
  u_char confid[IDX_COUNT]; /* id of last configuration request */
179
180
  int rst_counter[IDX_COUNT]; /* restart counter */
@@ -1,4 +1,4 @@
1
- /* $OpenBSD: if_trunk.h,v 1.32 2025/03/02 21:28:32 bluhm Exp $ */
1
+ /* $OpenBSD: if_trunk.h,v 1.33 2025/11/24 23:40:00 dlg Exp $ */
2
2
 
3
3
  /*
4
4
  * Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -159,6 +159,8 @@ struct trunk_softc;
159
159
  struct trunk_port {
160
160
  struct ifnet *tp_if; /* physical interface */
161
161
  struct trunk_softc *tp_trunk; /* parent trunk */
162
+ struct refcnt tp_refs;
163
+ struct ether_port tp_ether_port;
162
164
  u_int8_t tp_lladdr[ETHER_ADDR_LEN];
163
165
  caddr_t tp_psc; /* protocol data */
164
166
 
@@ -172,7 +174,6 @@ struct trunk_port {
172
174
  int (*tp_ioctl)(struct ifnet *, u_long, caddr_t);
173
175
  int (*tp_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
174
176
  struct rtentry *);
175
- void (*tp_input)(struct ifnet *, struct mbuf *, struct netstack *);
176
177
 
177
178
  SLIST_ENTRY(trunk_port) tp_entries;
178
179
  };
@@ -1,4 +1,4 @@
1
- /* $OpenBSD: if_types.h,v 1.24 2022/01/02 22:36:04 jsg Exp $ */
1
+ /* $OpenBSD: if_types.h,v 1.25 2026/03/23 08:42:22 jsg Exp $ */
2
2
  /* $NetBSD: if_types.h,v 1.17 2000/10/26 06:51:31 onoe Exp $ */
3
3
 
4
4
  /*
@@ -175,7 +175,7 @@
175
175
  #define IFT_A12MPPSWITCH 0x82 /* Avalon Parallel Processor */
176
176
  #define IFT_TUNNEL 0x83 /* Encapsulation interface */
177
177
  #define IFT_COFFEE 0x84 /* coffee pot */
178
- #define IFT_CES 0x85 /* Circiut Emulation Service */
178
+ #define IFT_CES 0x85 /* Circuit Emulation Service */
179
179
  #define IFT_ATMSUBINTERFACE 0x86 /* (x) ATM Sub Interface */
180
180
  #define IFT_L2VLAN 0x87 /* Layer 2 Virtual LAN using 802.1Q */
181
181
  #define IFT_L3IPVLAN 0x88 /* Layer 3 Virtual LAN - IP Protocol */
@@ -1,4 +1,4 @@
1
- /* $OpenBSD: if_var.h,v 1.139 2025/07/19 16:40:40 mvs Exp $ */
1
+ /* $OpenBSD: if_var.h,v 1.148 2026/03/22 23:14:00 bluhm Exp $ */
2
2
  /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
3
3
 
4
4
  /*
@@ -40,7 +40,7 @@
40
40
 
41
41
  #include <sys/queue.h>
42
42
  #include <sys/mbuf.h>
43
- #include <sys/srp.h>
43
+ #include <sys/smr.h>
44
44
  #include <sys/refcnt.h>
45
45
  #include <sys/task.h>
46
46
  #include <sys/timeout.h>
@@ -81,6 +81,7 @@
81
81
  * K kernel lock
82
82
  * N net lock
83
83
  * T if_tmplist_lock
84
+ * m interface multicast rwlock if_maddrlock
84
85
  *
85
86
  * For SRP related structures that allow lock-free reads, the write lock
86
87
  * is indicated below.
@@ -92,9 +93,12 @@ struct task;
92
93
  struct cpumem;
93
94
 
94
95
  struct netstack {
95
- struct route ns_route;
96
- struct mbuf_list ns_tcp_ml;
97
- struct mbuf_list ns_tcp6_ml;
96
+ struct mbuf_list ns_input;
97
+ struct mbuf_list ns_proto;
98
+
99
+ struct route ns_route;
100
+ struct mbuf_list ns_tcp_ml;
101
+ struct mbuf_list ns_tcp6_ml;
98
102
  };
99
103
 
100
104
  /*
@@ -141,6 +145,8 @@ enum if_counters {
141
145
  * (Would like to call this struct ``if'', but C isn't PL/1.)
142
146
  */
143
147
  TAILQ_HEAD(ifnet_head, ifnet); /* the actual queue head */
148
+ struct carp_softc;
149
+ SMR_LIST_HEAD(carp_iflist, carp_softc);
144
150
 
145
151
  struct ifnet { /* and the entries */
146
152
  void *if_softc; /* [I] lower-level data for this if */
@@ -148,8 +154,9 @@ struct ifnet { /* and the entries */
148
154
  TAILQ_ENTRY(ifnet) if_list; /* [NK] all struct ifnets are chained */
149
155
  TAILQ_ENTRY(ifnet) if_tmplist; /* [T] temporary list */
150
156
  TAILQ_HEAD(, ifaddr) if_addrlist; /* [N] list of addresses per if */
151
- TAILQ_HEAD(, ifmaddr) if_maddrlist; /* [N] list of multicast records */
157
+ TAILQ_HEAD(, ifmaddr) if_maddrlist; /* [m] list of multicast records */
152
158
  TAILQ_HEAD(, ifg_list) if_groups; /* [N] list of groups per if */
159
+ struct rwlock if_maddrlock;
153
160
  struct task_list if_addrhooks; /* [I] address change callbacks */
154
161
  struct task_list if_linkstatehooks; /* [I] link change callbacks*/
155
162
  struct task_list if_detachhooks; /* [I] detach callbacks */
@@ -163,9 +170,11 @@ struct ifnet { /* and the entries */
163
170
  caddr_t if_mcast6; /* used by IPv6 multicast code */
164
171
  caddr_t if_pf_kif; /* pf interface abstraction */
165
172
  union {
166
- struct srpl carp_s; /* carp if list (used by !carp ifs) */
167
- unsigned int carp_idx; /* index of carpdev (used by carp
168
- ifs) */
173
+ /* carp if list (used by IFT_ETHER) */
174
+ struct carp_iflist carp_s;
175
+
176
+ /* index of carpdev (used by IFT_CARP) */
177
+ unsigned int carp_idx;
169
178
  } if_carp_ptr;
170
179
  #define if_carp if_carp_ptr.carp_s
171
180
  #define if_carpdevidx if_carp_ptr.carp_idx
@@ -254,6 +263,7 @@ struct ifaddr {
254
263
  struct ifnet *ifa_ifp; /* back-pointer to interface */
255
264
  TAILQ_ENTRY(ifaddr) ifa_list; /* [N] list of addresses for
256
265
  interface */
266
+ TAILQ_ENTRY(ifaddr) ifa_tmplist;/* [T] temporary list */
257
267
  u_int ifa_flags; /* interface flags, see below */
258
268
  struct refcnt ifa_refcnt; /* number of `rt_ifa` references */
259
269
  int ifa_metric; /* cost of going out this interface */
@@ -265,10 +275,10 @@ struct ifaddr {
265
275
  * Interface multicast address.
266
276
  */
267
277
  struct ifmaddr {
268
- struct sockaddr *ifma_addr; /* Protocol address */
269
- unsigned int ifma_ifidx; /* Index of the interface */
278
+ TAILQ_ENTRY(ifmaddr) ifma_list; /* [m] Per-interface list */
279
+ struct sockaddr *ifma_addr; /* [I] Protocol address */
270
280
  struct refcnt ifma_refcnt; /* Count of references */
271
- TAILQ_ENTRY(ifmaddr) ifma_list; /* Per-interface list */
281
+ unsigned int ifma_ifidx; /* [I] Index of the interface */
272
282
  };
273
283
 
274
284
  /*
@@ -337,6 +347,9 @@ int if_enqueue_ifq(struct ifnet *, struct mbuf *);
337
347
  void if_input(struct ifnet *, struct mbuf_list *);
338
348
  void if_vinput(struct ifnet *, struct mbuf *, struct netstack *);
339
349
  void if_input_process(struct ifnet *, struct mbuf_list *, unsigned int);
350
+ void if_input_proto(struct ifnet *, struct mbuf *,
351
+ void (*)(struct ifnet *, struct mbuf *, struct netstack *),
352
+ struct netstack *);
340
353
  int if_input_local(struct ifnet *, struct mbuf *, sa_family_t,
341
354
  struct netstack *);
342
355
  int if_output_ml(struct ifnet *, struct mbuf_list *,
@@ -351,6 +364,15 @@ void p2p_rtrequest(struct ifnet *, int, struct rtentry *);
351
364
  void p2p_input(struct ifnet *, struct mbuf *, struct netstack *);
352
365
  int p2p_bpf_mtap(caddr_t, const struct mbuf *, u_int);
353
366
 
367
+ /* this is a helper for if_input_process and similar functions */
368
+ static inline void
369
+ if_input_process_proto(struct ifnet *ifp, struct mbuf *m, struct netstack *ns)
370
+ {
371
+ void (*input)(struct ifnet *, struct mbuf *, struct netstack *);
372
+ input = m->m_pkthdr.ph_cookie;
373
+ (*input)(ifp, m, ns);
374
+ }
375
+
354
376
  struct ifaddr *ifa_ifwithaddr(const struct sockaddr *, u_int);
355
377
  struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *, u_int);
356
378
  struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *);
@@ -1,4 +1,4 @@
1
- /* $OpenBSD: netisr.h,v 1.61 2023/07/06 04:55:05 dlg Exp $ */
1
+ /* $OpenBSD: netisr.h,v 1.62 2025/10/30 17:30:46 mvs Exp $ */
2
2
  /* $NetBSD: netisr.h,v 1.12 1995/08/12 23:59:24 mycroft Exp $ */
3
3
 
4
4
  /*
@@ -44,7 +44,6 @@
44
44
  #define NETISR_IP 2 /* same as AF_INET */
45
45
  #define NETISR_ARP 18 /* same as AF_LINK */
46
46
  #define NETISR_IPV6 24 /* same as AF_INET6 */
47
- #define NETISR_PIPEX 27 /* for pipex processing */
48
47
  #define NETISR_PPP 28 /* for PPP processing */
49
48
  #define NETISR_BRIDGE 29 /* for bridge processing */
50
49
  #define NETISR_PPPOE 30 /* for pppoe processing */
@@ -63,7 +62,6 @@ void ipintr(void);
63
62
  void ip6intr(void);
64
63
  void pppintr(void);
65
64
  void bridgeintr(void);
66
- void pipexintr(void);
67
65
  void pppoeintr(void);
68
66
 
69
67
  #define schednetisr(anisr) \
@@ -1,4 +1,4 @@
1
- /* $OpenBSD: pfvar.h,v 1.543 2025/04/14 20:02:34 sf Exp $ */
1
+ /* $OpenBSD: pfvar.h,v 1.548 2026/02/05 03:26:00 dlg Exp $ */
2
2
 
3
3
  /*
4
4
  * Copyright (c) 2001 Daniel Hartmeier
@@ -479,6 +479,13 @@ union pf_rule_ptr {
479
479
  #define PF_ANCHOR_HIWAT 512
480
480
  #define PF_OPTIMIZER_TABLE_PFX "__automatic_"
481
481
 
482
+ enum {
483
+ PF_LIMITER_NOMATCH,
484
+ PF_LIMITER_BLOCK
485
+ };
486
+
487
+ #define PF_LIMITER_DEFAULT PF_LIMITER_BLOCK
488
+
482
489
  struct pf_rule {
483
490
  struct pf_rule_addr src;
484
491
  struct pf_rule_addr dst;
@@ -591,6 +598,14 @@ struct pf_rule {
591
598
  u_int8_t set_prio[2];
592
599
  sa_family_t naf;
593
600
  u_int8_t rcvifnot;
601
+ struct {
602
+ u_int8_t id;
603
+ int limiter_action;
604
+ } statelim;
605
+ struct {
606
+ u_int8_t id;
607
+ int limiter_action;
608
+ } sourcelim;
594
609
 
595
610
  struct {
596
611
  struct pf_addr addr;
@@ -1502,6 +1517,133 @@ struct pfioc_synflwats {
1502
1517
  u_int32_t lowat;
1503
1518
  };
1504
1519
 
1520
+ #define PF_STATELIM_NAME_LEN 16 /* kstat istr */
1521
+ #define PF_STATELIM_DESCR_LEN 64
1522
+
1523
+ struct pfioc_statelim {
1524
+ u_int32_t ticket;
1525
+
1526
+ char name[PF_STATELIM_NAME_LEN];
1527
+ uint32_t id;
1528
+ #define PF_STATELIM_ID_NONE 0
1529
+ #define PF_STATELIM_ID_MIN 1
1530
+ #define PF_STATELIM_ID_MAX 255 /* fits in pf_state uint8_t */
1531
+
1532
+ /* limit on the total number of states */
1533
+ unsigned int limit;
1534
+ #define PF_STATELIM_LIMIT_MIN 1
1535
+ #define PF_STATELIM_LIMIT_MAX (1 << 24) /* pf is pretty scalable */
1536
+
1537
+ /* rate limit on the creation of states */
1538
+ struct {
1539
+ unsigned int limit;
1540
+ unsigned int seconds;
1541
+ } rate;
1542
+
1543
+ char description[PF_STATELIM_DESCR_LEN];
1544
+
1545
+ /* kernel state for GET ioctls */
1546
+ unsigned int inuse; /* gauge */
1547
+ uint64_t admitted; /* counter */
1548
+ uint64_t hardlimited; /* counter */
1549
+ uint64_t ratelimited; /* counter */
1550
+ };
1551
+
1552
+ #define PF_SOURCELIM_NAME_LEN 16 /* kstat istr */
1553
+ #define PF_SOURCELIM_DESCR_LEN 64
1554
+
1555
+ struct pfioc_sourcelim {
1556
+ u_int32_t ticket;
1557
+
1558
+ char name[PF_SOURCELIM_NAME_LEN];
1559
+ uint32_t id;
1560
+ #define PF_SOURCELIM_ID_NONE 0
1561
+ #define PF_SOURCELIM_ID_MIN 1
1562
+ #define PF_SOURCELIM_ID_MAX 255 /* fits in pf_state uint8_t */
1563
+
1564
+ /* limit on the total number of address entries */
1565
+ unsigned int entries;
1566
+
1567
+ /* limit on the number of states per address entry */
1568
+ unsigned int limit;
1569
+
1570
+ /* rate limit on the creation of states by an address entry */
1571
+ struct {
1572
+ unsigned int limit;
1573
+ unsigned int seconds;
1574
+ } rate;
1575
+
1576
+ /*
1577
+ * when the number of states on an entry exceeds hwm, add
1578
+ * the address to the specified table. when the number of
1579
+ * states goes below lwm, remove it from the table.
1580
+ */
1581
+ char overload_tblname[PF_TABLE_NAME_SIZE];
1582
+ unsigned int overload_hwm;
1583
+ unsigned int overload_lwm;
1584
+
1585
+ /*
1586
+ * mask addresses before they're used for entries. /64s
1587
+ * everywhere for inet6 makes it easy to use too much memory.
1588
+ */
1589
+ unsigned int inet_prefix;
1590
+ unsigned int inet6_prefix;
1591
+
1592
+ char description[PF_SOURCELIM_DESCR_LEN];
1593
+
1594
+ /* kernel state for GET ioctls */
1595
+ unsigned int nentries; /* gauge */
1596
+ unsigned int inuse; /* gauge */
1597
+
1598
+ uint64_t addrallocs; /* counter */
1599
+ uint64_t addrnomem; /* counter */
1600
+ uint64_t admitted; /* counter */
1601
+ uint64_t addrlimited; /* counter */
1602
+ uint64_t hardlimited; /* counter */
1603
+ uint64_t ratelimited; /* counter */
1604
+ };
1605
+
1606
+ struct pfioc_source_entry {
1607
+ sa_family_t af;
1608
+ unsigned int rdomain;
1609
+ struct pf_addr addr;
1610
+
1611
+ /* stats */
1612
+
1613
+ unsigned int inuse; /* gauge */
1614
+ uint64_t admitted; /* counter */
1615
+ uint64_t hardlimited; /* counter */
1616
+ uint64_t ratelimited; /* counter */
1617
+ };
1618
+
1619
+ struct pfioc_source {
1620
+ char name[PF_SOURCELIM_NAME_LEN];
1621
+ uint32_t id;
1622
+
1623
+ /* copied from the parent source limiter */
1624
+
1625
+ unsigned int inet_prefix;
1626
+ unsigned int inet6_prefix;
1627
+ unsigned int limit;
1628
+
1629
+ /* source entries */
1630
+ size_t entry_size; /* sizeof(struct pfioc_source_entry) */
1631
+
1632
+ struct pfioc_source_entry *key;
1633
+ struct pfioc_source_entry *entries;
1634
+ size_t entrieslen; /* bytes */
1635
+ };
1636
+
1637
+ struct pfioc_source_kill {
1638
+ char name[PF_SOURCELIM_NAME_LEN];
1639
+ uint32_t id;
1640
+ unsigned int rdomain;
1641
+ sa_family_t af;
1642
+ struct pf_addr addr;
1643
+
1644
+ unsigned int rmstates; /* kill the states too? */
1645
+ };
1646
+
1505
1647
  /*
1506
1648
  * ioctl operations
1507
1649
  */
@@ -1570,6 +1712,15 @@ struct pfioc_synflwats {
1570
1712
  #define DIOCSETSYNCOOKIES _IOWR('D', 98, u_int8_t)
1571
1713
  #define DIOCGETSYNFLWATS _IOWR('D', 99, struct pfioc_synflwats)
1572
1714
  #define DIOCXEND _IOWR('D', 100, u_int32_t)
1715
+ #define DIOCADDSTATELIM _IOW('D', 101, struct pfioc_statelim)
1716
+ #define DIOCADDSOURCELIM _IOW('D', 102, struct pfioc_sourcelim)
1717
+ #define DIOCGETSTATELIM _IOWR('D', 103, struct pfioc_statelim)
1718
+ #define DIOCGETSOURCELIM _IOWR('D', 104, struct pfioc_sourcelim)
1719
+ #define DIOCGETSOURCE _IOWR('D', 105, struct pfioc_source)
1720
+ #define DIOCGETNSTATELIM _IOWR('D', 106, struct pfioc_statelim)
1721
+ #define DIOCGETNSOURCELIM _IOWR('D', 107, struct pfioc_sourcelim)
1722
+ #define DIOCGETNSOURCE _IOWR('D', 108, struct pfioc_source)
1723
+ #define DIOCCLRSOURCE _IOWR('D', 109, struct pfioc_source_kill)
1573
1724
 
1574
1725
  #ifdef _KERNEL
1575
1726
 
@@ -1723,6 +1874,8 @@ int pfr_clr_tstats(struct pfr_table *, int, int *, int);
1723
1874
  int pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int);
1724
1875
  int pfr_clr_addrs(struct pfr_table *, int *, int);
1725
1876
  int pfr_insert_kentry(struct pfr_ktable *, struct pfr_addr *, time_t);
1877
+ int pfr_remove_kentry(struct pfr_ktable *, struct pfr_addr *);
1878
+
1726
1879
  int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
1727
1880
  int);
1728
1881
  int pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
@@ -1,4 +1,4 @@
1
- /* $OpenBSD: pfvar_priv.h,v 1.38 2024/09/07 22:41:55 aisha Exp $ */
1
+ /* $OpenBSD: pfvar_priv.h,v 1.42 2026/02/05 03:26:00 dlg Exp $ */
2
2
 
3
3
  /*
4
4
  * Copyright (c) 2001 Daniel Hartmeier
@@ -39,6 +39,7 @@
39
39
 
40
40
  #include <sys/rwlock.h>
41
41
  #include <sys/mutex.h>
42
+ #include <sys/pclock.h>
42
43
  #include <sys/percpu.h>
43
44
 
44
45
  /*
@@ -47,6 +48,45 @@
47
48
  */
48
49
 
49
50
  struct pfsync_deferral;
51
+ struct kstat;
52
+
53
+ /*
54
+ * PF state links
55
+ *
56
+ * This is used to augment a struct pf_state so it can be
57
+ * tracked/referenced by the state and source address limiter things.
58
+ * Each limiter maintains a list of the states they "own", and these
59
+ * state links are what the limiters use to wire a state into their
60
+ * lists.
61
+ *
62
+ * Without PF state links, the pf_state struct would have to grow
63
+ * a lot to support a feature that may not be used.
64
+ *
65
+ * pfl_entry is used by the pools to add states to their list.
66
+ * pfl_state allows the pools to get from their list of states to
67
+ * the states themselves.
68
+ *
69
+ * pfl_link allows operations on states (well, delete) to be able
70
+ * to quickly locate the pf_state_link struct so they can be unwired
71
+ * from the pools.
72
+ */
73
+
74
+ #define PF_STATE_LINK_TYPE_STATELIM 1
75
+ #define PF_STATE_LINK_TYPE_SOURCELIM 2
76
+
77
+ struct pf_state_link {
78
+ /* used by source/state pools to get to states */
79
+ TAILQ_ENTRY(pf_state_link) pfl_link;
80
+
81
+ /* used by pf_state to get to source/state pools */
82
+ SLIST_ENTRY(pf_state_link) pfl_linkage;
83
+
84
+ struct pf_state *pfl_state;
85
+ unsigned int pfl_type;
86
+ };
87
+
88
+ TAILQ_HEAD(pf_state_link_list, pf_state_link);
89
+ SLIST_HEAD(pf_state_linkage, pf_state_link);
50
90
 
51
91
  /*
52
92
  * pf state items - links from pf_state_key to pf_states
@@ -144,6 +184,9 @@ struct pf_state {
144
184
  u_int16_t if_index_out; /* [I] */
145
185
  u_int16_t delay; /* [I] */
146
186
  u_int8_t rt; /* [I] */
187
+ uint8_t statelim;
188
+ uint8_t sourcelim;
189
+ struct pf_state_linkage linkage;
147
190
  };
148
191
 
149
192
  RBT_HEAD(pf_state_tree_id, pf_state);
@@ -256,6 +299,214 @@ struct pf_state_list {
256
299
  .pfs_rwl = RWLOCK_INITIALIZER("pfstates"), \
257
300
  }
258
301
 
302
+ /*
303
+ * State limiter
304
+ */
305
+
306
+ struct pf_statelim {
307
+ RBT_ENTRY(pf_statelim) pfstlim_id_tree;
308
+ RBT_ENTRY(pf_statelim) pfstlim_nm_tree;
309
+ TAILQ_ENTRY(pf_statelim) pfstlim_list;
310
+ struct kstat *pfstlim_ks;
311
+
312
+ uint32_t pfstlim_id;
313
+ char pfstlim_nm[PF_STATELIM_NAME_LEN];
314
+
315
+ /* config */
316
+
317
+ unsigned int pfstlim_limit;
318
+ struct {
319
+ unsigned int limit;
320
+ unsigned int seconds;
321
+ } pfstlim_rate;
322
+
323
+ /* run state */
324
+ struct pc_lock pfstlim_lock;
325
+
326
+ /* rate limiter */
327
+ uint64_t pfstlim_rate_ts;
328
+ uint64_t pfstlim_rate_token;
329
+ uint64_t pfstlim_rate_bucket;
330
+
331
+ unsigned int pfstlim_inuse;
332
+ struct pf_state_link_list pfstlim_states;
333
+
334
+ /* counters */
335
+
336
+ struct {
337
+ uint64_t admitted;
338
+ uint64_t hardlimited;
339
+ uint64_t ratelimited;
340
+ } pfstlim_counters;
341
+
342
+ struct {
343
+ time_t created;
344
+ time_t updated;
345
+ time_t cleared;
346
+ } pfstlim_timestamps;
347
+ };
348
+
349
+ RBT_HEAD(pf_statelim_id_tree, pf_statelim);
350
+ RBT_PROTOTYPE(pf_statelim_id_tree, pf_statelim, pfstlim_id_tree, cmp);
351
+
352
+ RBT_HEAD(pf_statelim_nm_tree, pf_statelim);
353
+ RBT_PROTOTYPE(pf_statelim_nm_tree, pf_statelim, pfstlim_nm_tree, cmp);
354
+
355
+ TAILQ_HEAD(pf_statelim_list, pf_statelim);
356
+
357
+ extern struct pf_statelim_id_tree pf_statelim_id_tree_active;
358
+ extern struct pf_statelim_list pf_statelim_list_active;
359
+
360
+ extern struct pf_statelim_id_tree pf_statelim_id_tree_inactive;
361
+ extern struct pf_statelim_nm_tree pf_statelim_nm_tree_inactive;
362
+ extern struct pf_statelim_list pf_statelim_list_inactive;
363
+
364
+ static inline unsigned int
365
+ pf_statelim_enter(struct pf_statelim *pfstlim)
366
+ {
367
+ return (pc_sprod_enter(&pfstlim->pfstlim_lock));
368
+ }
369
+
370
+ static inline void
371
+ pf_statelim_leave(struct pf_statelim *pfstlim, unsigned int gen)
372
+ {
373
+ pc_sprod_leave(&pfstlim->pfstlim_lock, gen);
374
+ }
375
+
376
+ /*
377
+ * Source address pools
378
+ */
379
+
380
+ struct pf_sourcelim;
381
+
382
+ struct pf_source {
383
+ RBT_ENTRY(pf_source) pfsr_tree;
384
+ RBT_ENTRY(pf_source) pfsr_ioc_tree;
385
+ struct pf_sourcelim *pfsr_parent;
386
+
387
+ sa_family_t pfsr_af;
388
+ u_int16_t pfsr_rdomain;
389
+ struct pf_addr pfsr_addr;
390
+
391
+ /* run state */
392
+
393
+ unsigned int pfsr_inuse;
394
+ unsigned int pfsr_intable;
395
+ struct pf_state_link_list pfsr_states;
396
+ time_t pfsr_empty_ts;
397
+ TAILQ_ENTRY(pf_source) pfsr_empty_gc;
398
+
399
+ /* rate limiter */
400
+ uint64_t pfsr_rate_ts;
401
+
402
+ struct {
403
+ uint64_t admitted;
404
+ uint64_t hardlimited;
405
+ uint64_t ratelimited;
406
+ } pfsr_counters;
407
+ };
408
+
409
+ RBT_HEAD(pf_source_tree, pf_source);
410
+ RBT_PROTOTYPE(pf_source_tree, pf_source, pfsr_tree, cmp);
411
+
412
+ RBT_HEAD(pf_source_ioc_tree, pf_source);
413
+ RBT_PROTOTYPE(pf_source_ioc_tree, pf_source, pfsr_ioc_tree, cmp);
414
+
415
+ TAILQ_HEAD(pf_source_list, pf_source);
416
+
417
+ struct pf_sourcelim {
418
+ RBT_ENTRY(pf_sourcelim) pfsrlim_id_tree;
419
+ RBT_ENTRY(pf_sourcelim) pfsrlim_nm_tree;
420
+ TAILQ_ENTRY(pf_sourcelim) pfsrlim_list;
421
+ struct kstat *pfsrlim_ks;
422
+
423
+ uint32_t pfsrlim_id;
424
+ char pfsrlim_nm[PF_SOURCELIM_NAME_LEN];
425
+ unsigned int pfsrlim_disabled;
426
+
427
+ /* config */
428
+
429
+ unsigned int pfsrlim_entries;
430
+ unsigned int pfsrlim_limit;
431
+ unsigned int pfsrlim_ipv4_prefix;
432
+ unsigned int pfsrlim_ipv6_prefix;
433
+
434
+ struct {
435
+ unsigned int limit;
436
+ unsigned int seconds;
437
+ } pfsrlim_rate;
438
+
439
+ struct {
440
+ char name[PF_TABLE_NAME_SIZE];
441
+ unsigned int hwm;
442
+ unsigned int lwm;
443
+ struct pfr_ktable *table;
444
+ } pfsrlim_overload;
445
+
446
+ /* run state */
447
+ struct pc_lock pfsrlim_lock;
448
+
449
+ struct pf_addr pfsrlim_ipv4_mask;
450
+ struct pf_addr pfsrlim_ipv6_mask;
451
+
452
+ uint64_t pfsrlim_rate_token;
453
+ uint64_t pfsrlim_rate_bucket;
454
+
455
+ /* number of pf_sources */
456
+ unsigned int pfsrlim_nsources;
457
+ struct pf_source_tree pfsrlim_sources;
458
+ struct pf_source_ioc_tree pfsrlim_ioc_sources;
459
+
460
+ struct {
461
+ /* number of times pf_source was allocated */
462
+ uint64_t addrallocs;
463
+ /* state was rejected because the address limit was hit */
464
+ uint64_t addrlimited;
465
+ /* no memory to create address thing */
466
+ uint64_t addrnomem;
467
+
468
+ /* sum of pf_source inuse gauges */
469
+ uint64_t inuse;
470
+ /* sum of pf_source admitted counters */
471
+ uint64_t admitted;
472
+ /* sum of pf_source hardlimited counters */
473
+ uint64_t hardlimited;
474
+ /* sum of pf_source ratelimited counters */
475
+ uint64_t ratelimited;
476
+ } pfsrlim_counters;
477
+ };
478
+
479
+ RBT_HEAD(pf_sourcelim_id_tree, pf_sourcelim);
480
+ RBT_PROTOTYPE(pf_sourcelim_id_tree, pf_sourcelim, pfsrlim_id_tree, cmp);
481
+
482
+ RBT_HEAD(pf_sourcelim_nm_tree, pf_sourcelim);
483
+ RBT_PROTOTYPE(pf_sourcelim_nm_tree, pf_sourcelim, pfsrlim_nm_tree, cmp);
484
+
485
+ TAILQ_HEAD(pf_sourcelim_list, pf_sourcelim);
486
+
487
+ extern struct pf_sourcelim_id_tree pf_sourcelim_id_tree_active;
488
+ extern struct pf_sourcelim_list pf_sourcelim_list_active;
489
+
490
+ extern struct pf_sourcelim_id_tree pf_sourcelim_id_tree_inactive;
491
+ extern struct pf_sourcelim_nm_tree pf_sourcelim_nm_tree_inactive;
492
+ extern struct pf_sourcelim_list pf_sourcelim_list_inactive;
493
+
494
+ static inline unsigned int
495
+ pf_sourcelim_enter(struct pf_sourcelim *pfsrlim)
496
+ {
497
+ return (pc_sprod_enter(&pfsrlim->pfsrlim_lock));
498
+ }
499
+
500
+ static inline void
501
+ pf_sourcelim_leave(struct pf_sourcelim *pfsrlim, unsigned int gen)
502
+ {
503
+ pc_sprod_leave(&pfsrlim->pfsrlim_lock, gen);
504
+ }
505
+
506
+ /*
507
+ * pf internals
508
+ */
509
+
259
510
  extern struct rwlock pf_lock;
260
511
 
261
512
  struct pf_pdesc {
@@ -429,6 +680,10 @@ u_int16_t pf_pkt_hash(sa_family_t, uint8_t,
429
680
  const struct pf_addr *, const struct pf_addr *,
430
681
  uint16_t, uint16_t);
431
682
 
683
+ void pf_status_init(void);
684
+ void pf_status_clear(void);
685
+ void pf_status_read(struct pf_status *);
686
+
432
687
  #endif /* _KERNEL */
433
688
 
434
689
  #endif /* _NET_PFVAR_PRIV_H_ */