sync with OpenBSD -current

This commit is contained in:
purplerain 2025-01-24 00:53:19 +00:00
parent c170139b8d
commit 614315d09f
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
26 changed files with 269 additions and 138 deletions

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.33 2024/12/04 09:33:41 mpi Exp $
# $OpenBSD: Makefile,v 1.34 2025/01/23 11:19:12 mpi Exp $
BTRACE?= /usr/sbin/btrace
ALLOWDT!= sysctl -n kern.allowdt 2>/dev/null
@ -14,7 +14,8 @@ BT_LANG_SCRIPTS= arithm beginend beginend-argn boolean comments \
BT_ARG_LANG_SCRIPTS= staticv str
# scripts that use kernel probes
BT_KERN_SCRIPTS= argn empty-stmts filters mapoverwrite multiprobe
BT_KERN_SCRIPTS= argn empty-stmts filters interval mapoverwrite \
multiprobe
REGRESS_EXPECTED_FAILURES= run-maxoperand

View file

@ -0,0 +1,8 @@
interval:ms:300 {
@count = @count + 1;
printf("Probe: %d\n", @count);
}
profile:s:1 {
exit();
}

View file

@ -0,0 +1,3 @@
Probe: 1
Probe: 2
Probe: 3

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.36 2023/10/12 16:59:24 anton Exp $
# $OpenBSD: Makefile,v 1.37 2025/01/23 15:23:28 bluhm Exp $
# The following ports must be installed for the regression tests:
# p5-Socket6 Perl defines relating to AF_INET6 sockets
@ -94,7 +94,10 @@ ca.crt fake-ca.crt:
client.req server.req:
openssl req -batch -new -subj /L=OpenBSD/O=syslogd-regress/OU=${@:R}/CN=localhost/ -nodes -newkey rsa -keyout ${@:R}.key -out $@
client.crt server.crt: ca.crt ${@:R}.req
myhost-client.req:
openssl req -batch -new -subj /L=OpenBSD/O=syslogd-regress/OU=${@:R}/CN=myhost/ -nodes -newkey rsa -keyout ${@:R}.key -out $@
client.crt server.crt myhost-client.crt: ca.crt ${@:R}.req
openssl x509 -CAcreateserial -CAkey ca.key -CA ca.crt -req -in ${@:R}.req -out $@
empty:
@ -141,6 +144,7 @@ ${REGRESS_TARGETS:M*multilisten*}: 127.0.0.1.crt
${REGRESS_TARGETS:M*empty*}: empty
${REGRESS_TARGETS:M*toobig*}: toobig
${REGRESS_TARGETS:M*fake*}: fake-ca.crt
${REGRESS_TARGETS:M*myhost*}: myhost-client.crt
${REGRESS_TARGETS:M*sendsyslog*}: sys/syscall.ph
${REGRESS_TARGETS}: ttylog logflush

View file

@ -0,0 +1,31 @@
# The syslogd listens on localhost TLS socket with client verification.
# The client connects with a client certificate and writes a message.
# The syslogd writes it into a file and through a pipe.
# The syslogd passes it via UDP to the loghost.
# The server receives the message on its UDP socket.
# Find the message in client, file, pipe, syslogd, server log.
# Check that the syslogd switches name to common name in certificate.
use strict;
use warnings;
use Socket;
our %args = (
client => {
connect => { domain => AF_INET, proto => "tls", addr => "127.0.0.1",
port => 6514 },
sslcert => "myhost-client.crt",
sslkey => "myhost-client.key",
},
syslogd => {
options => ["-S", "127.0.0.1", "-K", "ca.crt"],
},
file => {
loggrep => [
qr/localhost using hostname "myhost" from certificate/,
qr/ myhost syslogd regress test log message/,
],
},
);
1;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pci_machdep.h,v 1.31 2024/01/19 18:38:16 kettenis Exp $ */
/* $OpenBSD: pci_machdep.h,v 1.32 2025/01/23 11:24:34 kettenis Exp $ */
/* $NetBSD: pci_machdep.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */
/*
@ -103,7 +103,7 @@ pcireg_t pci_min_powerstate(pci_chipset_tag_t, pcitag_t);
void pci_set_powerstate_md(pci_chipset_tag_t, pcitag_t, int, int);
void pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int, int);
pci_chipset_tag_t pci_lookup_segment(int);
pci_chipset_tag_t pci_lookup_segment(int, int);
#define __HAVE_PCI_MSIX

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pci_machdep.c,v 1.80 2024/05/13 10:01:53 kettenis Exp $ */
/* $OpenBSD: pci_machdep.c,v 1.81 2025/01/23 11:24:34 kettenis Exp $ */
/* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */
/*-
@ -160,7 +160,7 @@ pci_mcfg_init(bus_space_tag_t iot, bus_addr_t addr, int segment,
}
pci_chipset_tag_t
pci_lookup_segment(int segment)
pci_lookup_segment(int segment, int bus)
{
KASSERT(segment == 0);
return NULL;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpipci.c,v 1.42 2024/02/03 10:37:25 kettenis Exp $ */
/* $OpenBSD: acpipci.c,v 1.43 2025/01/23 11:24:34 kettenis Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
@ -199,7 +199,7 @@ acpipci_attach(struct device *parent, struct device *self, void *aux)
}
sc->sc_msi_ic = ic;
sc->sc_pc = pci_lookup_segment(seg);
sc->sc_pc = pci_lookup_segment(sc->sc_seg, sc->sc_bus);
KASSERT(sc->sc_pc->pc_intr_v == NULL);
sc->sc_pc->pc_probe_device_hook = acpipci_probe_device_hook;
@ -784,12 +784,13 @@ struct machine_pci_chipset acpipci_dummy_chipset = {
};
pci_chipset_tag_t
pci_lookup_segment(int segment)
pci_lookup_segment(int segment, int bus)
{
struct acpipci_mcfg *am;
SLIST_FOREACH(am, &acpipci_mcfgs, am_list) {
if (am->am_segment == segment)
if (segment == am->am_segment &&
bus >= am->am_min_bus && bus <= am->am_max_bus)
return &am->am_pc;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pci_machdep.h,v 1.12 2024/02/03 10:37:26 kettenis Exp $ */
/* $OpenBSD: pci_machdep.h,v 1.13 2025/01/23 11:24:34 kettenis Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@ -125,7 +125,7 @@ struct machine_pci_chipset {
#define pci_dev_postattach(a, b)
void pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int, int);
pci_chipset_tag_t pci_lookup_segment(int);
pci_chipset_tag_t pci_lookup_segment(int, int);
int pci_intr_enable_msivec(struct pci_attach_args *, int);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pci_machdep.c,v 1.88 2024/10/10 06:00:42 jsg Exp $ */
/* $OpenBSD: pci_machdep.c,v 1.89 2025/01/23 11:24:34 kettenis Exp $ */
/* $NetBSD: pci_machdep.c,v 1.28 1997/06/06 23:29:17 thorpej Exp $ */
/*-
@ -204,7 +204,7 @@ pci_mcfg_init(bus_space_tag_t iot, bus_addr_t addr, int segment,
}
pci_chipset_tag_t
pci_lookup_segment(int segment)
pci_lookup_segment(int segment, int bus)
{
KASSERT(segment == 0);
return NULL;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pci_machdep.h,v 1.32 2020/06/17 06:17:19 dlg Exp $ */
/* $OpenBSD: pci_machdep.h,v 1.33 2025/01/23 11:24:34 kettenis Exp $ */
/* $NetBSD: pci_machdep.h,v 1.7 1997/06/06 23:29:18 thorpej Exp $ */
/*
@ -114,7 +114,7 @@ pcireg_t pci_min_powerstate(pci_chipset_tag_t, pcitag_t);
void pci_set_powerstate_md(pci_chipset_tag_t, pcitag_t, int, int);
void pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int, int);
pci_chipset_tag_t pci_lookup_segment(int);
pci_chipset_tag_t pci_lookup_segment(int, int);
static inline int
pci_intr_map_msix(struct pci_attach_args *pa, int vec, pci_intr_handle_t *ihp)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: abl.c,v 1.5 2022/04/06 18:59:27 naddy Exp $ */
/* $OpenBSD: abl.c,v 1.6 2025/01/23 11:24:34 kettenis Exp $ */
/*
* Copyright (c) 2020 Marcus Glocker <mglocker@openbsd.org>
@ -126,7 +126,7 @@ abl_attach(struct device *parent, struct device *self, void *aux)
* We need to check on what type of PCI controller we're running on to
* access the right I/O space.
*/
pc = pci_lookup_segment(0);
pc = pci_lookup_segment(0, 0);
tag = pci_make_tag(pc, 0, 0, 0);
reg = pci_conf_read(pc, tag, PCI_ID_REG);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpi.c,v 1.439 2024/09/04 21:39:18 hastings Exp $ */
/* $OpenBSD: acpi.c,v 1.440 2025/01/23 11:24:34 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@ -324,7 +324,8 @@ acpi_gasio(struct acpi_softc *sc, int iodir, int iospace, uint64_t address,
return (0);
}
pc = pci_lookup_segment(ACPI_PCI_SEG(address));
pc = pci_lookup_segment(ACPI_PCI_SEG(address),
ACPI_PCI_BUS(address));
tag = pci_make_tag(pc,
ACPI_PCI_BUS(address), ACPI_PCI_DEV(address),
ACPI_PCI_FN(address));
@ -642,7 +643,7 @@ acpi_getpci(struct aml_node *node, void *arg)
free(pci, M_DEVBUF, sizeof(*pci));
return (1);
}
pc = pci_lookup_segment(pci->seg);
pc = pci_lookup_segment(pci->seg, pci->bus);
tag = pci_make_tag(pc, pci->bus, pci->dev, pci->fun);
reg = pci_conf_read(pc, tag, PCI_ID_REG);
if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID) {
@ -839,7 +840,7 @@ acpi_pci_notify(struct aml_node *node, int ntype, void *arg)
if (ntype != 2)
return (0);
pc = pci_lookup_segment(pdev->seg);
pc = pci_lookup_segment(pdev->seg, pdev->bus);
tag = pci_make_tag(pc, pdev->bus, pdev->dev, pdev->fun);
if (pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &offset, 0)) {
/* Clear the PME Status bit if it is set. */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dsdt.c,v 1.272 2024/12/24 12:06:34 mglocker Exp $ */
/* $OpenBSD: dsdt.c,v 1.273 2025/01/23 13:40:26 kettenis Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@ -2574,7 +2574,16 @@ aml_rwgsb(struct aml_value *conn, int len, int bpos, int blen,
buflen = len;
break;
case 0x0e: /* AttribRawBytes */
cmdlen = 0;
buflen = len;
break;
case 0x0f: /* AttribRawProcessBytes */
/*
* XXX Not implemented yet but used by various
* WoA laptops. Force an error status instead
* of a panic for now.
*/
node = NULL;
cmdlen = 0;
buflen = len;
break;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dt_prov_profile.c,v 1.9 2024/11/26 10:28:27 mpi Exp $ */
/* $OpenBSD: dt_prov_profile.c,v 1.10 2025/01/23 11:17:32 mpi Exp $ */
/*
* Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org>
@ -67,16 +67,17 @@ int
dt_prov_profile_alloc(struct dt_probe *dtp, struct dt_softc *sc,
struct dt_pcb_list *plist, struct dtioc_req *dtrq)
{
uint64_t nsecs;
struct dt_pcb *dp;
struct cpu_info *ci;
CPU_INFO_ITERATOR cii;
extern int hz;
KASSERT(TAILQ_EMPTY(plist));
KASSERT(dtp == dtpp_profile || dtp == dtpp_interval);
if (dtrq->dtrq_rate <= 0 || dtrq->dtrq_rate > hz)
return EOPNOTSUPP;
nsecs = dtrq->dtrq_nsecs;
if (nsecs < USEC_TO_NSEC(200) || nsecs > SEC_TO_NSEC(UINT32_MAX))
return EINVAL;
CPU_INFO_FOREACH(cii, ci) {
if (!CPU_IS_PRIMARY(ci) && (dtp == dtpp_interval))
@ -88,7 +89,7 @@ dt_prov_profile_alloc(struct dt_probe *dtp, struct dt_softc *sc,
return ENOMEM;
}
dp->dp_nsecs = SEC_TO_NSEC(1) / dtrq->dtrq_rate;
dp->dp_nsecs = nsecs;
dp->dp_cpu = ci;
dp->dp_evtflags = dtrq->dtrq_evtflags & DTEVT_PROV_PROFILE;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dtvar.h,v 1.21 2024/11/26 10:28:27 mpi Exp $ */
/* $OpenBSD: dtvar.h,v 1.22 2025/01/23 11:17:32 mpi Exp $ */
/*
* Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org>
@ -109,8 +109,9 @@ struct dtioc_arg {
struct dtioc_req {
uint32_t dtrq_pbn; /* probe number */
uint32_t dtrq_rate; /* number of ticks */
uint32_t __unused1;
uint64_t dtrq_evtflags; /* states to record */
uint64_t dtrq_nsecs; /* execution period */
};
struct dtioc_stat {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.363 2025/01/22 15:05:49 mvs Exp $ */
/* $OpenBSD: uipc_socket.c,v 1.364 2025/01/23 10:44:13 bluhm Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@ -1754,17 +1754,6 @@ somove(struct socket *so, int wait)
m->m_pkthdr.len = len;
}
/* Send window update to source peer as receive buffer has changed. */
if (so->so_proto->pr_flags & PR_WANTRCVD) {
mtx_leave(&sosp->so_snd.sb_mtx);
mtx_leave(&so->so_rcv.sb_mtx);
solock_shared(so);
pru_rcvd(so);
sounlock_shared(so);
mtx_enter(&so->so_rcv.sb_mtx);
mtx_enter(&sosp->so_snd.sb_mtx);
}
/* Receive buffer did shrink by len bytes, adjust oob. */
rcvstate = so->so_rcv.sb_state;
so->so_rcv.sb_state &= ~SS_RCVATMARK;
@ -1777,6 +1766,17 @@ somove(struct socket *so, int wait)
oobmark = 0;
}
/* Send window update to source peer as receive buffer has changed. */
if (so->so_proto->pr_flags & PR_WANTRCVD) {
mtx_leave(&sosp->so_snd.sb_mtx);
mtx_leave(&so->so_rcv.sb_mtx);
solock_shared(so);
pru_rcvd(so);
sounlock_shared(so);
mtx_enter(&so->so_rcv.sb_mtx);
mtx_enter(&sosp->so_snd.sb_mtx);
}
/*
* Handle oob data. If any malloc fails, ignore error.
* TCP urgent data is not very reliable anyway.

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_divert.c,v 1.98 2025/01/01 13:44:22 bluhm Exp $ */
/* $OpenBSD: ip_divert.c,v 1.99 2025/01/23 12:51:51 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@ -272,14 +272,13 @@ divert_attach(struct socket *so, int proto, int wait)
if ((so->so_state & SS_PRIV) == 0)
return EACCES;
error = in_pcballoc(so, &divbtable, wait);
if (error)
return error;
error = soreserve(so, atomic_load_int(&divert_sendspace),
atomic_load_int(&divert_recvspace));
if (error)
return error;
error = in_pcballoc(so, &divbtable, wait);
if (error)
return error;
sotoinpcb(so)->inp_flags |= INP_HDRINCL;
return (0);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */
/* $OpenBSD: ip6_divert.c,v 1.98 2025/01/23 12:51:51 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@ -280,14 +280,13 @@ divert6_attach(struct socket *so, int proto, int wait)
if ((so->so_state & SS_PRIV) == 0)
return EACCES;
error = in_pcballoc(so, &divb6table, wait);
if (error)
return (error);
error = soreserve(so, atomic_load_int(&divert6_sendspace),
atomic_load_int(&divert6_recvspace));
if (error)
return (error);
error = in_pcballoc(so, &divb6table, wait);
if (error)
return (error);
return (0);
}

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: systat.1,v 1.123 2024/09/25 06:13:01 jmc Exp $
.\" $OpenBSD: systat.1,v 1.124 2025/01/23 11:05:26 mpi Exp $
.\" $NetBSD: systat.1,v 1.6 1996/05/10 23:16:39 thorpej Exp $
.\"
.\" Copyright (c) 1985, 1990, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)systat.1 8.2 (Berkeley) 12/30/93
.\"
.Dd $Mdocdate: September 25 2024 $
.Dd $Mdocdate: January 23 2025 $
.Dt SYSTAT 1
.Os
.Sh NAME
@ -687,18 +687,12 @@ target number of free pages
target number of inactive pages
.It wiredmax
maximum number of wired pages
.It anonmin
minimum threshold for anon pages
.It vtextmin
minimum threshold for vtext pages
.It vnodemin
minimum threshold for vnode pages
.It anonminpct
minimum percent anon pages
.It vtextminpct
minimum percent vtext pages
.It vnodeminpct
minimum percent vnode pages
.Pp
.It Per-CPU Counters:
.It pcphit
pages allocated from a per-CPU cache since boot
.It pcpmiss
times a per-CPU cache was empty when allocating a page
.Pp
.It Swap Counters:
.It nswapdev

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uvm.c,v 1.10 2024/05/18 09:02:34 jsg Exp $ */
/* $OpenBSD: uvm.c,v 1.11 2025/01/23 11:05:26 mpi Exp $ */
/*
* Copyright (c) 2008 Can Erkin Acar <canacar@openbsd.org>
* Copyright (c) 2018 Kenneth R Westerback <krw@openbsd.org>
@ -103,51 +103,51 @@ struct uvmline uvmline[] = {
{ &uvmexp.wiredmax, &last_uvmexp.wiredmax, "wiredmax",
NULL, NULL, NULL,
&uvmexp.flt_anon, &last_uvmexp.flt_anon, "flt_anon" },
{ &uvmexp.anonmin, &last_uvmexp.anonmin, "anonmin",
NULL, NULL, "Daemon Counters",
{ NULL, NULL, NULL,
NULL, NULL, NULL,
&uvmexp.flt_acow, &last_uvmexp.flt_acow, "flt_acow" },
{ &uvmexp.vtextmin, &last_uvmexp.vtextmin, "vtextmin",
&uvmexp.pdwoke, &last_uvmexp.pdwoke, "pdwoke",
{ NULL, NULL, NULL,
NULL, NULL, "Daemon Counters",
&uvmexp.flt_obj, &last_uvmexp.flt_obj, "flt_obj" },
{ &uvmexp.vnodemin, &last_uvmexp.vnodemin, "vnodemin",
&uvmexp.pdrevs, &last_uvmexp.pdrevs, "pdrevs",
{ NULL, NULL, "Per-CPU Counters",
&uvmexp.pdwoke, &last_uvmexp.pdwoke, "pdwoke",
&uvmexp.flt_prcopy, &last_uvmexp.flt_prcopy, "flt_prcopy" },
{ &uvmexp.anonminpct, &last_uvmexp.anonminpct, "anonminpct",
&uvmexp.pdswout, &last_uvmexp.pdswout, "pdswout",
{ &uvmexp.pcphit, &last_uvmexp.pcphit, "pcphit",
&uvmexp.pdrevs, &last_uvmexp.pdrevs, "pdrevs",
&uvmexp.flt_przero, &last_uvmexp.flt_przero, "flt_przero" },
{ &uvmexp.vtextminpct, &last_uvmexp.vtextminpct, "vtextminpct",
&uvmexp.swpgonly, &last_uvmexp.swpgonly, "swpgonly",
{ &uvmexp.pcpmiss, &last_uvmexp.pcpmiss, "pcpmiss",
&uvmexp.pdswout, &last_uvmexp.pdswout, "pdswout",
NULL, NULL, NULL },
{ &uvmexp.vnodeminpct, &last_uvmexp.vnodeminpct, "vnodeminpct",
{ NULL, NULL, NULL,
&uvmexp.pdfreed, &last_uvmexp.pdfreed, "pdfreed",
NULL, NULL, "Swap Counters" },
NULL, NULL, NULL },
{ NULL, NULL, NULL,
&uvmexp.pdscans, &last_uvmexp.pdscans, "pdscans",
&uvmexp.nswapdev, &last_uvmexp.nswapdev, "nswapdev" },
NULL, NULL, NULL },
{ NULL, NULL, "Misc Counters",
&uvmexp.pdanscan, &last_uvmexp.pdanscan, "pdanscan",
&uvmexp.swpages, &last_uvmexp.swpages, "swpages" },
NULL, NULL, NULL },
{ &uvmexp.fpswtch, &last_uvmexp.fpswtch, "fpswtch",
&uvmexp.pdobscan, &last_uvmexp.pdobscan, "pdobscan",
&uvmexp.swpginuse, &last_uvmexp.swpginuse, "swpginuse" },
NULL, NULL, NULL },
{ &uvmexp.kmapent, &last_uvmexp.kmapent, "kmapent",
&uvmexp.pdreact, &last_uvmexp.pdreact, "pdreact",
&uvmexp.swpgonly, &last_uvmexp.swpgonly, "swpgonly" },
NULL, NULL, "Swap Counters" },
{ NULL, NULL, NULL,
&uvmexp.pdbusy, &last_uvmexp.pdbusy, "pdbusy",
&uvmexp.nswget, &last_uvmexp.nswget, "nswget" },
&uvmexp.nswapdev, &last_uvmexp.nswapdev, "nswapdev" },
{ NULL, NULL, "Constants",
&uvmexp.pdpageouts, &last_uvmexp.pdpageouts, "pdpageouts",
NULL, NULL, NULL },
&uvmexp.swpages, &last_uvmexp.swpages, "swpages" },
{ &uvmexp.pagesize, &last_uvmexp.pagesize, "pagesize",
&uvmexp.pdpending, &last_uvmexp.pdpending, "pdpending",
NULL, NULL, "Per-CPU Counters" },
&uvmexp.swpginuse, &last_uvmexp.swpginuse, "swpginuse" },
{ &uvmexp.pagemask, &last_uvmexp.pagemask, "pagemask",
&uvmexp.pddeact, &last_uvmexp.pddeact, "pddeact",
&uvmexp.pcphit, &last_uvmexp.pcphit, "pcphit" },
&uvmexp.swpgonly, &last_uvmexp.swpgonly, "swpgonly" },
{ &uvmexp.pageshift, &last_uvmexp.pageshift, "pageshift",
NULL, NULL, NULL,
&uvmexp.pcpmiss, &last_uvmexp.pcpmiss, "pcpmiss" }
&uvmexp.nswget, &last_uvmexp.nswget, "nswget" }
};
field_def fields_uvm[] = {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: bt_parse.y,v 1.61 2024/11/07 09:20:09 mpi Exp $ */
/* $OpenBSD: bt_parse.y,v 1.62 2025/01/23 11:17:32 mpi Exp $ */
/*
* Copyright (c) 2019-2023 Martin Pieuchot <mpi@openbsd.org>
@ -62,7 +62,7 @@ struct bt_arg g_maxba = BA_INITIALIZER(LONG_MAX, B_AT_LONG);
struct bt_rule *br_new(struct bt_probe *, struct bt_filter *,
struct bt_stmt *);
struct bt_probe *bp_new(const char *, const char *, const char *, int32_t);
struct bt_probe *bp_new(const char *, const char *, const char *, long);
struct bt_arg *ba_append(struct bt_arg *, struct bt_arg *);
struct bt_arg *ba_op(enum bt_argtype, struct bt_arg *, struct bt_arg *);
struct bt_stmt *bs_new(enum bt_action, struct bt_arg *, struct bt_var *);
@ -119,7 +119,7 @@ static int beflag = 0; /* BEGIN/END parsing context flag */
%token <v.i> ERROR ENDFILT
%token <v.i> OP_EQ OP_NE OP_LE OP_LT OP_GE OP_GT OP_LAND OP_LOR
/* Builtins */
%token <v.i> BUILTIN BEGIN ELSE END HZ IF STR
%token <v.i> BUILTIN BEGIN ELSE END IF STR
/* Functions and Map operators */
%token <v.i> F_DELETE F_PRINT
%token <v.i> MFUNC FUNC0 FUNC1 FUNCN OP1 OP2 OP4 MOP0 MOP1
@ -155,7 +155,7 @@ probe : { pflag = 1; } pname { $$ = $2; pflag = 0; }
;
pname : STRING ':' STRING ':' STRING { $$ = bp_new($1, $3, $5, 0); }
| STRING ':' HZ ':' NUMBER { $$ = bp_new($1, "hz", NULL, $5); }
| STRING ':' STRING ':' NUMBER { $$ = bp_new($1, $3, NULL, $5); }
;
mentry : GVAR '[' vargs ']' { $$ = bm_find($1, $3); }
@ -358,18 +358,55 @@ bt_new(struct bt_arg *ba, struct bt_stmt *condbs, struct bt_stmt *elsebs)
return bs_new(B_AC_TEST, bop, (struct bt_var *)bc);
}
/*
* interval and profile support the same units.
*/
static uint64_t
bp_unit_to_nsec(const char *unit, long value)
{
static const struct {
const char *name;
enum { UNIT_HZ, UNIT_US, UNIT_MS, UNIT_S } id;
long long max;
} units[] = {
{ .name = "hz", .id = UNIT_HZ, .max = 1000000LL },
{ .name = "us", .id = UNIT_US, .max = LLONG_MAX / 1000 },
{ .name = "ms", .id = UNIT_MS, .max = LLONG_MAX / 1000000 },
{ .name = "s", .id = UNIT_S, .max = LLONG_MAX / 1000000000 },
};
size_t i;
for (i = 0; i < nitems(units); i++) {
if (strcmp(units[i].name, unit) == 0) {
if (value < 1)
yyerror("Number is invalid: %ld", value);
if (value > units[i].max)
yyerror("Number is too large: %ld", value);
switch (units[i].id) {
case UNIT_HZ:
return (1000000000LLU / value);
case UNIT_US:
return (value * 1000LLU);
case UNIT_MS:
return (value * 1000000LLU);
case UNIT_S:
return (value * 1000000000LLU);
}
}
}
yyerror("Invalid unit: %s", unit);
return 0;
}
/* Create a new probe */
struct bt_probe *
bp_new(const char *prov, const char *func, const char *name, int32_t rate)
bp_new(const char *prov, const char *func, const char *name, long number)
{
struct bt_probe *bp;
enum bt_ptype ptype;
if (rate < 0 || rate > INT32_MAX)
errx(1, "only positive values permitted");
if (prov == NULL && func == NULL && name == NULL)
ptype = rate; /* BEGIN or END */
ptype = number; /* BEGIN or END */
else
ptype = B_PT_PROBE;
@ -379,7 +416,8 @@ bp_new(const char *prov, const char *func, const char *name, int32_t rate)
bp->bp_prov = prov;
bp->bp_func = func;
bp->bp_name = name;
bp->bp_rate = rate;
if (ptype == B_PT_PROBE && name == NULL)
bp->bp_nsecs = bp_unit_to_nsec(func, number);
bp->bp_type = ptype;
return bp;
@ -726,7 +764,6 @@ lookup(char *s)
{ "else", ELSE, 0 },
{ "exit", FUNC0, B_AC_EXIT },
{ "hist", OP1, 0 },
{ "hz", HZ, 0 },
{ "if", IF, 0 },
{ "kstack", BUILTIN, B_AT_BI_KSTACK },
{ "lhist", OP4, 0 },
@ -1077,14 +1114,10 @@ again:
/*
* Probe lexer backdoor, interpret the token as a string
* rather than a keyword. Otherwise, reserved keywords
* would conflict with syscall names. The exception to
* this is 'hz', which hopefully will never be a
* syscall.
* would conflict with syscall names.
*/
if (kwp->token != HZ) {
yylval.v.string = kwp->word;
return STRING;
}
} else if (beflag) {
/* Interpret tokens in a BEGIN/END context. */
if (kwp->type >= B_AT_BI_ARG0 &&

View file

@ -1,4 +1,4 @@
/* $OpenBSD: bt_parser.h,v 1.26 2024/03/30 07:41:45 mpi Exp $ */
/* $OpenBSD: bt_parser.h,v 1.27 2025/01/23 11:17:32 mpi Exp $ */
/*
* Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
@ -31,7 +31,7 @@
*
* "provider:function:name"
* or
* "provider:time_unit:rate"
* "provider:time_unit:number"
*
* Multiple probes can be associated to the same action.
*/
@ -40,7 +40,7 @@ struct bt_probe {
const char *bp_prov; /* provider */
const char *bp_func; /* function or time unit */
const char *bp_name;
uint32_t bp_rate;
uint64_t bp_nsecs;
#define bp_unit bp_func
enum bt_ptype {
B_PT_BEGIN = 1,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: btrace.c,v 1.94 2024/12/04 09:33:41 mpi Exp $ */
/* $OpenBSD: btrace.c,v 1.95 2025/01/23 11:17:32 mpi Exp $ */
/*
* Copyright (c) 2019 - 2023 Martin Pieuchot <mpi@openbsd.org>
@ -363,12 +363,6 @@ dtpi_func(struct dtioc_probe_info *dtpi)
return syscallnames[idx];
}
int
dtpi_is_unit(const char *unit)
{
return !strncmp("hz", unit, sizeof("hz"));
}
struct dtioc_probe_info *
dtpi_get_by_value(const char *prov, const char *func, const char *name)
{
@ -377,20 +371,16 @@ dtpi_get_by_value(const char *prov, const char *func, const char *name)
dtpi = dt_dtpis;
for (i = 0; i < dt_ndtpi; i++, dtpi++) {
if (prov != NULL &&
strncmp(prov, dtpi->dtpi_prov, DTNAMESIZE))
continue;
if (func != NULL) {
if (dtpi_is_unit(func))
return dtpi;
if (strncmp(func, dtpi_func(dtpi), DTNAMESIZE))
if (prov != NULL) {
if (strncmp(prov, dtpi->dtpi_prov, DTNAMESIZE))
continue;
}
if (func != NULL && name != NULL) {
if (strncmp(func, dtpi_func(dtpi), DTNAMESIZE))
continue;
if (strncmp(name, dtpi->dtpi_name, DTNAMESIZE))
continue;
}
debug("matched probe %s:%s:%s\n", dtpi->dtpi_prov,
dtpi_func(dtpi), dtpi->dtpi_name);
@ -400,6 +390,37 @@ dtpi_get_by_value(const char *prov, const char *func, const char *name)
return NULL;
}
static uint64_t
bp_nsecs_to_unit(struct bt_probe *bp)
{
static const struct {
const char *name;
enum { UNIT_HZ, UNIT_US, UNIT_MS, UNIT_S } id;
} units[] = {
{ .name = "hz", .id = UNIT_HZ },
{ .name = "us", .id = UNIT_US },
{ .name = "ms", .id = UNIT_MS },
{ .name = "s", .id = UNIT_S },
};
size_t i;
for (i = 0; i < nitems(units); i++) {
if (strcmp(units[i].name, bp->bp_unit) == 0) {
switch (units[i].id) {
case UNIT_HZ:
return (1000000000LLU / bp->bp_nsecs);
case UNIT_US:
return (bp->bp_nsecs / 1000LLU);
case UNIT_MS:
return (bp->bp_nsecs / 1000000LLU);
case UNIT_S:
return (bp->bp_nsecs / 1000000000LLU);
}
}
}
return 0;
}
void
probe_bail(struct bt_probe *bp)
{
@ -420,9 +441,9 @@ probe_name(struct bt_probe *bp)
assert(bp->bp_type == B_PT_PROBE);
if (bp->bp_rate) {
snprintf(buf, sizeof(buf), "%s:%s:%u", bp->bp_prov,
bp->bp_unit, bp->bp_rate);
if (bp->bp_nsecs) {
snprintf(buf, sizeof(buf), "%s:%s:%llu", bp->bp_prov,
bp->bp_unit, bp_nsecs_to_unit(bp));
} else {
snprintf(buf, sizeof(buf), "%s:%s:%s", bp->bp_prov,
bp->bp_unit, bp->bp_name);
@ -582,7 +603,7 @@ rules_setup(int fd)
bp->bp_pbn = dtpi->dtpi_pbn;
dtrq->dtrq_pbn = dtpi->dtpi_pbn;
dtrq->dtrq_rate = bp->bp_rate;
dtrq->dtrq_nsecs = bp->bp_nsecs;
dtrq->dtrq_evtflags = evtflags;
if (dtrq->dtrq_evtflags & DTEVT_KSTACK)
dokstack = 1;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pdu.c,v 1.14 2025/01/22 10:14:54 claudio Exp $ */
/* $OpenBSD: pdu.c,v 1.15 2025/01/23 12:17:48 claudio Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@ -191,14 +191,19 @@ text_to_num(const char *numstr, u_int64_t minval, u_int64_t maxval,
int
text_to_bool(const char *buf, const char **errstrp)
{
int val = 0;
int val;
if (strcmp(buf, "Yes") == 0)
val = 1;
else if (strcmp(buf, "No") != 0) {
else if (strcmp(buf, "No") == 0)
val = 0;
else {
if (errstrp != NULL)
*errstrp = "invalid";
return 0;
}
if (errstrp != NULL)
*errstrp = NULL;
return val;
}
@ -227,6 +232,8 @@ text_to_digest(const char *buf, const char **errstrp)
}
buf = p;
}
if (errstrp != NULL)
*errstrp = NULL;
return val;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: syslogd.c,v 1.283 2024/11/07 10:12:18 bluhm Exp $ */
/* $OpenBSD: syslogd.c,v 1.284 2025/01/23 12:27:42 henning Exp $ */
/*
* Copyright (c) 2014-2021 Alexander Bluhm <bluhm@genua.de>
@ -1214,9 +1214,27 @@ void
tls_handshakecb(struct bufferevent *bufev, void *arg)
{
struct peer *p = arg;
const char *cn;
char *cntmp;
log_debug("Completed tls handshake");
if (tls_peer_cert_provided(p->p_ctx)) {
if ((cn = tls_peer_cert_common_name(p->p_ctx)) != NULL &&
strlen(cn) > 0) {
if (stravis(&cntmp, cn, VIS_WHITE) == -1)
log_warn("tls_handshakecb stravis");
else {
log_info(LOG_INFO, "%s using hostname \"%s\" "
"from certificate", p->p_hostname, cntmp);
free(p->p_hostname);
p->p_hostname = cntmp;
}
} else
log_info(LOG_NOTICE,
"cannot get hostname from peer certificate");
}
bufferevent_setcb(bufev, tcp_readcb, NULL, tcp_closecb, p);
}