sync with OpenBSD -current
This commit is contained in:
parent
362e3feade
commit
337ce169cc
24 changed files with 337 additions and 132 deletions
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: arin.constraints,v 1.5 2024/04/17 14:31:59 job Exp $
|
# $OpenBSD: arin.constraints,v 1.6 2025/01/28 19:43:10 job Exp $
|
||||||
|
|
||||||
# From https://www.iana.org/assignments/ipv6-unicast-address-assignments
|
# From https://www.iana.org/assignments/ipv6-unicast-address-assignments
|
||||||
allow 2001:400::/23
|
allow 2001:400::/23
|
||||||
|
@ -9,6 +9,9 @@ allow 2610::/23
|
||||||
allow 2620::/23
|
allow 2620::/23
|
||||||
allow 2630::/12
|
allow 2630::/12
|
||||||
|
|
||||||
|
# AS112 Project
|
||||||
|
allow 2001:4:112::/48
|
||||||
|
|
||||||
# LACNIC ASNs cannot be transferred to ARIN
|
# LACNIC ASNs cannot be transferred to ARIN
|
||||||
# From https://www.iana.org/assignments/as-numbers/as-numbers.xhtml
|
# From https://www.iana.org/assignments/as-numbers/as-numbers.xhtml
|
||||||
deny 27648 - 28671
|
deny 27648 - 28671
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.5 2023/07/09 13:30:03 bluhm Exp $
|
# $OpenBSD: Makefile,v 1.6 2025/01/28 13:12:48 anton Exp $
|
||||||
|
|
||||||
.if ! (make(clean) || make(cleandir) || make(obj))
|
.if ! (make(clean) || make(cleandir) || make(obj))
|
||||||
NCPU != /sbin/sysctl -n hw.ncpuonline
|
NCPU != /sbin/sysctl -n hw.ncpuonline
|
||||||
|
@ -16,14 +16,13 @@ permissions:
|
||||||
# Match expectations of cpan/Test-Harness/t/source_handler.t for
|
# Match expectations of cpan/Test-Harness/t/source_handler.t for
|
||||||
# cpan/Test-Harness/t/source_tests/source*.sh executalbe bits.
|
# cpan/Test-Harness/t/source_tests/source*.sh executalbe bits.
|
||||||
# Remove symlink and fix permissions of copy in obj directory.
|
# Remove symlink and fix permissions of copy in obj directory.
|
||||||
# cpan/autodie/t/chmod.t and cpan/autodie/t/chown.t modify themself,
|
# cpan/autodie/t/chmod.t and cpan/autodie/t/chown.t modify themself.
|
||||||
# and cpan/autodie/t/utime.t touches touch_me. Replace symlink.
|
# Replace symlink.
|
||||||
.for f in \
|
.for f in \
|
||||||
cpan/Test-Harness/t/source_tests/source.sh \
|
cpan/Test-Harness/t/source_tests/source.sh \
|
||||||
cpan/Test-Harness/t/source_tests/source_args.sh \
|
cpan/Test-Harness/t/source_tests/source_args.sh \
|
||||||
cpan/autodie/t/chmod.t \
|
cpan/autodie/t/chmod.t \
|
||||||
cpan/autodie/t/chown.t \
|
cpan/autodie/t/chown.t
|
||||||
cpan/autodie/t/touch_me
|
|
||||||
rm -f ${BSDOBJDIR}/gnu/usr.bin/perl/$f
|
rm -f ${BSDOBJDIR}/gnu/usr.bin/perl/$f
|
||||||
cp ${BSDSRCDIR}/gnu/usr.bin/perl/$f ${BSDOBJDIR}/gnu/usr.bin/perl/$f
|
cp ${BSDSRCDIR}/gnu/usr.bin/perl/$f ${BSDOBJDIR}/gnu/usr.bin/perl/$f
|
||||||
chmod +x ${BSDOBJDIR}/gnu/usr.bin/perl/$f
|
chmod +x ${BSDOBJDIR}/gnu/usr.bin/perl/$f
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $OpenBSD: virtio.4,v 1.17 2023/04/26 22:34:30 jmc Exp $
|
.\" $OpenBSD: virtio.4,v 1.18 2025/01/29 14:03:18 sf Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2012 Stefan Fritsch <sf@sfritsch.de>
|
.\" Copyright (c) 2012 Stefan Fritsch <sf@sfritsch.de>
|
||||||
.\"
|
.\"
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: April 26 2023 $
|
.Dd $Mdocdate: January 29 2025 $
|
||||||
.Dt VIRTIO 4
|
.Dt VIRTIO 4
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -60,9 +60,8 @@ The
|
||||||
driver conforms to the virtio 0.9.5 specification.
|
driver conforms to the virtio 0.9.5 specification.
|
||||||
The virtio 1.0 standard is only supported for PCI devices.
|
The virtio 1.0 standard is only supported for PCI devices.
|
||||||
.Pp
|
.Pp
|
||||||
By default 0.9 is preferred over 1.0.
|
By default 1.x is preferred over 0.9.
|
||||||
This can be changed by setting the bit 0x4 in the flags.
|
This can be changed by setting the bit 0x8 in the flags.
|
||||||
Setting the bit 0x8 in the flags disables 1.0 support completely.
|
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr intro 4
|
.Xr intro 4
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $OpenBSD: rwlock.9,v 1.26 2021/01/16 15:02:40 mvs Exp $
|
.\" $OpenBSD: rwlock.9,v 1.27 2025/01/29 15:10:35 mpi Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2006 Pedro Martelletto <pedro@ambientworks.net>
|
.\" Copyright (c) 2006 Pedro Martelletto <pedro@ambientworks.net>
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: January 16 2021 $
|
.Dd $Mdocdate: January 29 2025 $
|
||||||
.Dt RWLOCK 9
|
.Dt RWLOCK 9
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -139,6 +139,10 @@ Acquire an exclusive lock.
|
||||||
.It Dv RW_DOWNGRADE
|
.It Dv RW_DOWNGRADE
|
||||||
Safely release an exclusive lock and acquire a shared lock without
|
Safely release an exclusive lock and acquire a shared lock without
|
||||||
letting other exclusive locks in between.
|
letting other exclusive locks in between.
|
||||||
|
.It Dv RW_UPGRADE
|
||||||
|
Upgrade a shared lock into an exclusive one.
|
||||||
|
Must be combined with
|
||||||
|
.Dv RW_NOSLEEP .
|
||||||
.It Dv RW_INTR
|
.It Dv RW_INTR
|
||||||
When waiting for a lock, allow signals to interrupt the sleep.
|
When waiting for a lock, allow signals to interrupt the sleep.
|
||||||
.It Dv RW_NOSLEEP
|
.It Dv RW_NOSLEEP
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: virtio_pci.c,v 1.50 2025/01/14 14:28:38 sf Exp $ */
|
/* $OpenBSD: virtio_pci.c,v 1.51 2025/01/29 14:03:18 sf Exp $ */
|
||||||
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
|
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -362,8 +362,7 @@ virtio_pci_match(struct device *parent, void *match, void *aux)
|
||||||
return 1;
|
return 1;
|
||||||
/* virtio 1.0 */
|
/* virtio 1.0 */
|
||||||
if (PCI_PRODUCT(pa->pa_id) >= 0x1040 &&
|
if (PCI_PRODUCT(pa->pa_id) >= 0x1040 &&
|
||||||
PCI_PRODUCT(pa->pa_id) <= 0x107f &&
|
PCI_PRODUCT(pa->pa_id) <= 0x107f)
|
||||||
PCI_REVISION(pa->pa_class) == 1)
|
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -595,21 +594,24 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||||
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
|
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
|
||||||
pci_chipset_tag_t pc = pa->pa_pc;
|
pci_chipset_tag_t pc = pa->pa_pc;
|
||||||
pcitag_t tag = pa->pa_tag;
|
pcitag_t tag = pa->pa_tag;
|
||||||
int revision, ret = ENODEV;
|
int revision, product, vendor, ret = ENODEV, flags;
|
||||||
pcireg_t id;
|
pcireg_t id;
|
||||||
struct virtio_pci_attach_args vpa = { { 0 }, pa };
|
struct virtio_pci_attach_args vpa = { { 0 }, pa };
|
||||||
|
|
||||||
revision = PCI_REVISION(pa->pa_class);
|
revision = PCI_REVISION(pa->pa_class);
|
||||||
switch (revision) {
|
product = PCI_PRODUCT(pa->pa_id);
|
||||||
case 0:
|
vendor = PCI_VENDOR(pa->pa_id);
|
||||||
/* subsystem ID shows what I am */
|
if (vendor == PCI_VENDOR_OPENBSD ||
|
||||||
|
(product >= 0x1000 && product <= 0x103f && revision == 0)) {
|
||||||
|
/* OpenBSD VMMCI and virtio 0.9 */
|
||||||
id = PCI_PRODUCT(pci_conf_read(pc, tag, PCI_SUBSYS_ID_REG));
|
id = PCI_PRODUCT(pci_conf_read(pc, tag, PCI_SUBSYS_ID_REG));
|
||||||
break;
|
} else if (product >= 0x1040 && product <= 0x107f) {
|
||||||
case 1:
|
/* virtio 1.0 */
|
||||||
id = PCI_PRODUCT(pa->pa_id) - 0x1040;
|
id = product - 0x1040;
|
||||||
break;
|
revision = 1;
|
||||||
default:
|
} else {
|
||||||
printf("unknown revision 0x%02x; giving up\n", revision);
|
printf("unknown device prod 0x%04x rev 0x%02x; giving up\n",
|
||||||
|
product, revision);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,15 +639,15 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||||
M_DEVBUF, M_WAITOK | M_ZERO);
|
M_DEVBUF, M_WAITOK | M_ZERO);
|
||||||
|
|
||||||
vsc->sc_ops = &virtio_pci_ops;
|
vsc->sc_ops = &virtio_pci_ops;
|
||||||
if ((vsc->sc_dev.dv_cfdata->cf_flags & VIRTIO_CF_NO_VERSION_1) == 0 &&
|
flags = vsc->sc_dev.dv_cfdata->cf_flags;
|
||||||
(revision == 1 ||
|
if ((flags & VIRTIO_CF_PREFER_VERSION_09) == 0)
|
||||||
(vsc->sc_dev.dv_cfdata->cf_flags & VIRTIO_CF_PREFER_VERSION_1))) {
|
|
||||||
ret = virtio_pci_attach_10(sc, pa);
|
ret = virtio_pci_attach_10(sc, pa);
|
||||||
}
|
|
||||||
if (ret != 0 && revision == 0) {
|
if (ret != 0 && revision == 0) {
|
||||||
/* revision 0 means 0.9 only or both 0.9 and 1.0 */
|
/* revision 0 means 0.9 only or both 0.9 and 1.0 */
|
||||||
ret = virtio_pci_attach_09(sc, pa);
|
ret = virtio_pci_attach_09(sc, pa);
|
||||||
}
|
}
|
||||||
|
if (ret != 0 && (flags & VIRTIO_CF_PREFER_VERSION_09))
|
||||||
|
ret = virtio_pci_attach_10(sc, pa);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf(": Cannot attach (%d)\n", ret);
|
printf(": Cannot attach (%d)\n", ret);
|
||||||
goto free;
|
goto free;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: if_vio.c,v 1.67 2025/01/17 08:58:38 jan Exp $ */
|
/* $OpenBSD: if_vio.c,v 1.68 2025/01/28 19:53:06 sf Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
|
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
|
||||||
|
@ -1514,6 +1514,11 @@ vio_rxeof(struct vio_queue *vioq)
|
||||||
hdr = mtod(m, struct virtio_net_hdr *);
|
hdr = mtod(m, struct virtio_net_hdr *);
|
||||||
m_adj(m, sc->sc_hdr_size);
|
m_adj(m, sc->sc_hdr_size);
|
||||||
m0 = mlast = m;
|
m0 = mlast = m;
|
||||||
|
if (virtio_has_feature(vsc, VIRTIO_NET_F_MQ)) {
|
||||||
|
m->m_pkthdr.ph_flowid =
|
||||||
|
vioq->viq_ifiq->ifiq_idx;
|
||||||
|
SET(m->m_pkthdr.csum_flags, M_FLOWID);
|
||||||
|
}
|
||||||
if (VIO_HAVE_MRG_RXBUF(sc))
|
if (VIO_HAVE_MRG_RXBUF(sc))
|
||||||
bufs_left = hdr->num_buffers - 1;
|
bufs_left = hdr->num_buffers - 1;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: virtiovar.h,v 1.28 2025/01/14 12:30:57 sf Exp $ */
|
/* $OpenBSD: virtiovar.h,v 1.29 2025/01/29 14:03:19 sf Exp $ */
|
||||||
/* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
|
/* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -82,8 +82,7 @@
|
||||||
/* flags for config(8) */
|
/* flags for config(8) */
|
||||||
#define VIRTIO_CF_NO_INDIRECT 1
|
#define VIRTIO_CF_NO_INDIRECT 1
|
||||||
#define VIRTIO_CF_NO_EVENT_IDX 2
|
#define VIRTIO_CF_NO_EVENT_IDX 2
|
||||||
#define VIRTIO_CF_PREFER_VERSION_1 4
|
#define VIRTIO_CF_PREFER_VERSION_09 8
|
||||||
#define VIRTIO_CF_NO_VERSION_1 8
|
|
||||||
|
|
||||||
struct virtio_attach_args {
|
struct virtio_attach_args {
|
||||||
int va_devid; /* virtio device id */
|
int va_devid; /* virtio device id */
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* $OpenBSD: init_sysent.c,v 1.284 2025/01/20 09:03:24 mpi Exp $ */
|
/* $OpenBSD: init_sysent.c,v 1.285 2025/01/29 14:59:30 mpi Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System call switch table.
|
* System call switch table.
|
||||||
*
|
*
|
||||||
* DO NOT EDIT-- this file is automatically generated.
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
* created from; OpenBSD: syscalls.master,v 1.267 2025/01/20 09:02:17 mpi Exp
|
* created from; OpenBSD: syscalls.master,v 1.268 2025/01/29 14:58:28 mpi Exp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -27,7 +27,7 @@ const struct sysent sysent[] = {
|
||||||
sys_read }, /* 3 = read */
|
sys_read }, /* 3 = read */
|
||||||
{ 3, s(struct sys_write_args), SY_NOLOCK | 0,
|
{ 3, s(struct sys_write_args), SY_NOLOCK | 0,
|
||||||
sys_write }, /* 4 = write */
|
sys_write }, /* 4 = write */
|
||||||
{ 3, s(struct sys_open_args), 0,
|
{ 3, s(struct sys_open_args), SY_NOLOCK | 0,
|
||||||
sys_open }, /* 5 = open */
|
sys_open }, /* 5 = open */
|
||||||
{ 1, s(struct sys_close_args), SY_NOLOCK | 0,
|
{ 1, s(struct sys_close_args), SY_NOLOCK | 0,
|
||||||
sys_close }, /* 6 = close */
|
sys_close }, /* 6 = close */
|
||||||
|
@ -731,7 +731,7 @@ const struct sysent sysent[] = {
|
||||||
sys_mkfifoat }, /* 319 = mkfifoat */
|
sys_mkfifoat }, /* 319 = mkfifoat */
|
||||||
{ 4, s(struct sys_mknodat_args), 0,
|
{ 4, s(struct sys_mknodat_args), 0,
|
||||||
sys_mknodat }, /* 320 = mknodat */
|
sys_mknodat }, /* 320 = mknodat */
|
||||||
{ 4, s(struct sys_openat_args), 0,
|
{ 4, s(struct sys_openat_args), SY_NOLOCK | 0,
|
||||||
sys_openat }, /* 321 = openat */
|
sys_openat }, /* 321 = openat */
|
||||||
{ 4, s(struct sys_readlinkat_args), 0,
|
{ 4, s(struct sys_readlinkat_args), 0,
|
||||||
sys_readlinkat }, /* 322 = readlinkat */
|
sys_readlinkat }, /* 322 = readlinkat */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: kern_rwlock.c,v 1.53 2025/01/04 02:34:11 dlg Exp $ */
|
/* $OpenBSD: kern_rwlock.c,v 1.55 2025/01/29 15:10:09 mpi Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org>
|
* Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org>
|
||||||
|
@ -74,6 +74,7 @@ static int rw_do_enter_read(struct rwlock *, int);
|
||||||
static void rw_do_exit_read(struct rwlock *, unsigned long);
|
static void rw_do_exit_read(struct rwlock *, unsigned long);
|
||||||
static int rw_do_enter_write(struct rwlock *, int);
|
static int rw_do_enter_write(struct rwlock *, int);
|
||||||
static int rw_downgrade(struct rwlock *, int);
|
static int rw_downgrade(struct rwlock *, int);
|
||||||
|
static int rw_upgrade(struct rwlock *, int);
|
||||||
|
|
||||||
static void rw_exited(struct rwlock *);
|
static void rw_exited(struct rwlock *);
|
||||||
|
|
||||||
|
@ -203,6 +204,9 @@ rw_enter(struct rwlock *rwl, int flags)
|
||||||
case RW_DOWNGRADE:
|
case RW_DOWNGRADE:
|
||||||
error = rw_downgrade(rwl, flags);
|
error = rw_downgrade(rwl, flags);
|
||||||
break;
|
break;
|
||||||
|
case RW_UPGRADE:
|
||||||
|
error = rw_upgrade(rwl, flags);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
panic("%s rwlock %p: %s unexpected op 0x%x",
|
panic("%s rwlock %p: %s unexpected op 0x%x",
|
||||||
rwl->rwl_name, rwl, __func__, op);
|
rwl->rwl_name, rwl, __func__, op);
|
||||||
|
@ -246,6 +250,7 @@ rw_do_enter_write(struct rwlock *rwl, int flags)
|
||||||
* can progress. Hence no spinning if we hold the kernel lock.
|
* can progress. Hence no spinning if we hold the kernel lock.
|
||||||
*/
|
*/
|
||||||
if (!_kernel_lock_held()) {
|
if (!_kernel_lock_held()) {
|
||||||
|
struct schedstate_percpu *spc = &curcpu()->ci_schedstate;
|
||||||
int spins;
|
int spins;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -253,6 +258,7 @@ rw_do_enter_write(struct rwlock *rwl, int flags)
|
||||||
* is acquired by writer.
|
* is acquired by writer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
spc->spc_spinning++;
|
||||||
for (spins = 0; spins < RW_SPINS; spins++) {
|
for (spins = 0; spins < RW_SPINS; spins++) {
|
||||||
CPU_BUSY_CYCLE();
|
CPU_BUSY_CYCLE();
|
||||||
owner = atomic_load_long(&rwl->rwl_owner);
|
owner = atomic_load_long(&rwl->rwl_owner);
|
||||||
|
@ -261,10 +267,12 @@ rw_do_enter_write(struct rwlock *rwl, int flags)
|
||||||
|
|
||||||
owner = rw_cas(&rwl->rwl_owner, 0, self);
|
owner = rw_cas(&rwl->rwl_owner, 0, self);
|
||||||
if (owner == 0) {
|
if (owner == 0) {
|
||||||
|
spc->spc_spinning--;
|
||||||
/* ok, we won now. */
|
/* ok, we won now. */
|
||||||
goto locked;
|
goto locked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
spc->spc_spinning--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -434,6 +442,41 @@ rw_downgrade(struct rwlock *rwl, int flags)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
rw_upgrade(struct rwlock *rwl, int flags)
|
||||||
|
{
|
||||||
|
unsigned long self = rw_self();
|
||||||
|
unsigned long owner;
|
||||||
|
|
||||||
|
KASSERTMSG(ISSET(flags, RW_NOSLEEP), "RW_UPGRADE without RW_NOSLEEP");
|
||||||
|
|
||||||
|
owner = atomic_cas_ulong(&rwl->rwl_owner, RWLOCK_READ_INCR, self);
|
||||||
|
if (owner != RWLOCK_READ_INCR) {
|
||||||
|
if (__predict_false(owner == 0)) {
|
||||||
|
panic("%s rwlock %p: upgrade on unowned lock",
|
||||||
|
rwl->rwl_name, rwl);
|
||||||
|
}
|
||||||
|
if (__predict_false(ISSET(owner, RWLOCK_WRLOCK))) {
|
||||||
|
panic("%s rwlock %p: upgrade on write locked lock"
|
||||||
|
"(owner 0x%lx, self 0x%lx)", rwl->rwl_name, rwl,
|
||||||
|
owner, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (EBUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WITNESS
|
||||||
|
{
|
||||||
|
int lop_flags = LOP_NEWORDER;
|
||||||
|
if (ISSET(flags, RW_DUPOK))
|
||||||
|
lop_flags |= LOP_DUPOK;
|
||||||
|
WITNESS_UPGRADE(&rwl->rwl_lock_obj, lop_flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rw_exit(struct rwlock *rwl)
|
rw_exit(struct rwlock *rwl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* $OpenBSD: syscalls.c,v 1.282 2025/01/20 09:03:24 mpi Exp $ */
|
/* $OpenBSD: syscalls.c,v 1.283 2025/01/29 14:59:30 mpi Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System call names.
|
* System call names.
|
||||||
*
|
*
|
||||||
* DO NOT EDIT-- this file is automatically generated.
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
* created from; OpenBSD: syscalls.master,v 1.267 2025/01/20 09:02:17 mpi Exp
|
* created from; OpenBSD: syscalls.master,v 1.268 2025/01/29 14:58:28 mpi Exp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *const syscallnames[] = {
|
const char *const syscallnames[] = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $OpenBSD: syscalls.master,v 1.267 2025/01/20 09:02:17 mpi Exp $
|
; $OpenBSD: syscalls.master,v 1.268 2025/01/29 14:58:28 mpi Exp $
|
||||||
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
|
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
|
||||||
|
|
||||||
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
|
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
3 STD NOLOCK { ssize_t sys_read(int fd, void *buf, size_t nbyte); }
|
3 STD NOLOCK { ssize_t sys_read(int fd, void *buf, size_t nbyte); }
|
||||||
4 STD NOLOCK { ssize_t sys_write(int fd, const void *buf, \
|
4 STD NOLOCK { ssize_t sys_write(int fd, const void *buf, \
|
||||||
size_t nbyte); }
|
size_t nbyte); }
|
||||||
5 STD { int sys_open(const char *path, \
|
5 STD NOLOCK { int sys_open(const char *path, \
|
||||||
int flags, ... mode_t mode); }
|
int flags, ... mode_t mode); }
|
||||||
6 STD NOLOCK { int sys_close(int fd); }
|
6 STD NOLOCK { int sys_close(int fd); }
|
||||||
7 STD NOLOCK { int sys_getentropy(void *buf, size_t nbyte); }
|
7 STD NOLOCK { int sys_getentropy(void *buf, size_t nbyte); }
|
||||||
|
@ -553,7 +553,7 @@
|
||||||
mode_t mode); }
|
mode_t mode); }
|
||||||
320 STD { int sys_mknodat(int fd, const char *path, \
|
320 STD { int sys_mknodat(int fd, const char *path, \
|
||||||
mode_t mode, dev_t dev); }
|
mode_t mode, dev_t dev); }
|
||||||
321 STD { int sys_openat(int fd, const char *path, int flags, \
|
321 STD NOLOCK { int sys_openat(int fd, const char *path, int flags, \
|
||||||
... mode_t mode); }
|
... mode_t mode); }
|
||||||
322 STD { ssize_t sys_readlinkat(int fd, const char *path, \
|
322 STD { ssize_t sys_readlinkat(int fd, const char *path, \
|
||||||
char *buf, size_t count); }
|
char *buf, size_t count); }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: vfs_syscalls.c,v 1.371 2025/01/20 09:02:17 mpi Exp $ */
|
/* $OpenBSD: vfs_syscalls.c,v 1.372 2025/01/29 14:57:19 mpi Exp $ */
|
||||||
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
|
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1120,23 +1120,20 @@ doopenat(struct proc *p, int fd, const char *path, int oflags, mode_t mode,
|
||||||
localtrunc = 1;
|
localtrunc = 1;
|
||||||
flags &= ~O_TRUNC; /* Must do truncate ourselves */
|
flags &= ~O_TRUNC; /* Must do truncate ourselves */
|
||||||
}
|
}
|
||||||
|
KERNEL_LOCK();
|
||||||
if ((error = vn_open(&nd, flags, cmode)) != 0) {
|
if ((error = vn_open(&nd, flags, cmode)) != 0) {
|
||||||
fdplock(fdp);
|
fdplock(fdp);
|
||||||
if (error == ENODEV &&
|
if (error == ENODEV &&
|
||||||
p->p_dupfd >= 0 && /* XXX from fdopen */
|
p->p_dupfd >= 0 && /* XXX from fdopen */
|
||||||
(error =
|
(error =
|
||||||
dupfdopen(p, indx, flags)) == 0) {
|
dupfdopen(p, indx, flags)) == 0) {
|
||||||
fdpunlock(fdp);
|
|
||||||
closef(fp, p);
|
|
||||||
*retval = indx;
|
*retval = indx;
|
||||||
return (error);
|
goto error;
|
||||||
}
|
}
|
||||||
if (error == ERESTART)
|
if (error == ERESTART)
|
||||||
error = EINTR;
|
error = EINTR;
|
||||||
fdremove(fdp, indx);
|
fdremove(fdp, indx);
|
||||||
fdpunlock(fdp);
|
goto error;
|
||||||
closef(fp, p);
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
p->p_dupfd = 0;
|
p->p_dupfd = 0;
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
|
@ -1161,9 +1158,7 @@ doopenat(struct proc *p, int fd, const char *path, int oflags, mode_t mode,
|
||||||
fdplock(fdp);
|
fdplock(fdp);
|
||||||
/* closef will vn_close the file for us. */
|
/* closef will vn_close the file for us. */
|
||||||
fdremove(fdp, indx);
|
fdremove(fdp, indx);
|
||||||
fdpunlock(fdp);
|
goto error;
|
||||||
closef(fp, p);
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||||
atomic_setbits_int(&fp->f_iflags, FIF_HASLOCK);
|
atomic_setbits_int(&fp->f_iflags, FIF_HASLOCK);
|
||||||
|
@ -1185,18 +1180,22 @@ doopenat(struct proc *p, int fd, const char *path, int oflags, mode_t mode,
|
||||||
fdplock(fdp);
|
fdplock(fdp);
|
||||||
/* closef will close the file for us. */
|
/* closef will close the file for us. */
|
||||||
fdremove(fdp, indx);
|
fdremove(fdp, indx);
|
||||||
fdpunlock(fdp);
|
goto error;
|
||||||
closef(fp, p);
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VOP_UNLOCK(vp);
|
VOP_UNLOCK(vp);
|
||||||
|
KERNEL_UNLOCK();
|
||||||
*retval = indx;
|
*retval = indx;
|
||||||
fdplock(fdp);
|
fdplock(fdp);
|
||||||
fdinsert(fdp, indx, cloexec, fp);
|
fdinsert(fdp, indx, cloexec, fp);
|
||||||
fdpunlock(fdp);
|
fdpunlock(fdp);
|
||||||
FRELE(fp, p);
|
FRELE(fp, p);
|
||||||
return (error);
|
return (error);
|
||||||
|
error:
|
||||||
|
KERNEL_UNLOCK();
|
||||||
|
fdpunlock(fdp);
|
||||||
|
closef(fp, p);
|
||||||
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: rwlock.h,v 1.31 2025/01/04 02:34:11 dlg Exp $ */
|
/* $OpenBSD: rwlock.h,v 1.32 2025/01/29 15:10:09 mpi Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
|
* Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
|
||||||
*
|
*
|
||||||
|
@ -110,6 +110,7 @@ struct rwlock {
|
||||||
#define RW_WRITE 0x0001UL /* exclusive lock */
|
#define RW_WRITE 0x0001UL /* exclusive lock */
|
||||||
#define RW_READ 0x0002UL /* shared lock */
|
#define RW_READ 0x0002UL /* shared lock */
|
||||||
#define RW_DOWNGRADE 0x0004UL /* downgrade exclusive to shared */
|
#define RW_DOWNGRADE 0x0004UL /* downgrade exclusive to shared */
|
||||||
|
#define RW_UPGRADE 0x0005UL
|
||||||
#define RW_OPMASK 0x0007UL
|
#define RW_OPMASK 0x0007UL
|
||||||
|
|
||||||
#define RW_INTR 0x0010UL /* interruptible sleep */
|
#define RW_INTR 0x0010UL /* interruptible sleep */
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* $OpenBSD: syscall.h,v 1.280 2025/01/20 09:03:24 mpi Exp $ */
|
/* $OpenBSD: syscall.h,v 1.281 2025/01/29 14:59:31 mpi Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System call numbers.
|
* System call numbers.
|
||||||
*
|
*
|
||||||
* DO NOT EDIT-- this file is automatically generated.
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
* created from; OpenBSD: syscalls.master,v 1.267 2025/01/20 09:02:17 mpi Exp
|
* created from; OpenBSD: syscalls.master,v 1.268 2025/01/29 14:58:28 mpi Exp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* syscall: "exit" ret: "void" args: "int" */
|
/* syscall: "exit" ret: "void" args: "int" */
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* $OpenBSD: syscallargs.h,v 1.283 2025/01/20 09:03:24 mpi Exp $ */
|
/* $OpenBSD: syscallargs.h,v 1.284 2025/01/29 14:59:31 mpi Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System call argument lists.
|
* System call argument lists.
|
||||||
*
|
*
|
||||||
* DO NOT EDIT-- this file is automatically generated.
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
* created from; OpenBSD: syscalls.master,v 1.267 2025/01/20 09:02:17 mpi Exp
|
* created from; OpenBSD: syscalls.master,v 1.268 2025/01/29 14:58:28 mpi Exp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef syscallarg
|
#ifdef syscallarg
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: uvm_fault.c,v 1.162 2025/01/22 10:52:09 mpi Exp $ */
|
/* $OpenBSD: uvm_fault.c,v 1.163 2025/01/29 15:22:33 mpi Exp $ */
|
||||||
/* $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $ */
|
/* $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -655,7 +655,11 @@ uvm_fault(vm_map_t orig_map, vaddr_t vaddr, vm_fault_t fault_type,
|
||||||
flt.access_type = access_type;
|
flt.access_type = access_type;
|
||||||
flt.narrow = FALSE; /* assume normal fault for now */
|
flt.narrow = FALSE; /* assume normal fault for now */
|
||||||
flt.wired = FALSE; /* assume non-wired fault for now */
|
flt.wired = FALSE; /* assume non-wired fault for now */
|
||||||
|
#if notyet
|
||||||
|
flt.lower_lock_type = RW_READ; /* shared lock for now */
|
||||||
|
#else
|
||||||
flt.lower_lock_type = RW_WRITE; /* exclusive lock for now */
|
flt.lower_lock_type = RW_WRITE; /* exclusive lock for now */
|
||||||
|
#endif
|
||||||
|
|
||||||
error = ERESTART;
|
error = ERESTART;
|
||||||
while (error == ERESTART) { /* ReFault: */
|
while (error == ERESTART) { /* ReFault: */
|
||||||
|
@ -757,6 +761,8 @@ uvm_fault_check(struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
|
||||||
flt->access_type = flt->enter_prot; /* full access for wired */
|
flt->access_type = flt->enter_prot; /* full access for wired */
|
||||||
/* don't look for neighborhood * pages on "wire" fault */
|
/* don't look for neighborhood * pages on "wire" fault */
|
||||||
flt->narrow = TRUE;
|
flt->narrow = TRUE;
|
||||||
|
/* wiring pages requires a write lock. */
|
||||||
|
flt->lower_lock_type = RW_WRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle "needs_copy" case. */
|
/* handle "needs_copy" case. */
|
||||||
|
@ -843,6 +849,14 @@ uvm_fault_check(struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
|
||||||
*ranons = NULL; /* to be safe */
|
*ranons = NULL; /* to be safe */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flt->access_type & PROT_WRITE) != 0) {
|
||||||
|
/*
|
||||||
|
* we are about to dirty the object and that
|
||||||
|
* requires a write lock.
|
||||||
|
*/
|
||||||
|
flt->lower_lock_type = RW_WRITE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for MADV_SEQUENTIAL mappings we want to deactivate the back pages
|
* for MADV_SEQUENTIAL mappings we want to deactivate the back pages
|
||||||
* now and then forget about them (for the rest of the fault).
|
* now and then forget about them (for the rest of the fault).
|
||||||
|
@ -853,12 +867,15 @@ uvm_fault_check(struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
|
||||||
uvmfault_anonflush(*ranons, nback);
|
uvmfault_anonflush(*ranons, nback);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* flush object?
|
* flush object? change lock type to RW_WRITE, to avoid
|
||||||
|
* excessive competition between read/write locks if many
|
||||||
|
* threads doing "sequential access".
|
||||||
*/
|
*/
|
||||||
if (uobj) {
|
if (uobj) {
|
||||||
voff_t uoff;
|
voff_t uoff;
|
||||||
|
|
||||||
uoff = (flt->startva - ufi->entry->start) + ufi->entry->offset;
|
uoff = (flt->startva - ufi->entry->start) + ufi->entry->offset;
|
||||||
|
flt->lower_lock_type = RW_WRITE;
|
||||||
rw_enter(uobj->vmobjlock, RW_WRITE);
|
rw_enter(uobj->vmobjlock, RW_WRITE);
|
||||||
(void) uobj->pgops->pgo_flush(uobj, uoff, uoff +
|
(void) uobj->pgops->pgo_flush(uobj, uoff, uoff +
|
||||||
((vsize_t)nback << PAGE_SHIFT), PGO_DEACTIVATE);
|
((vsize_t)nback << PAGE_SHIFT), PGO_DEACTIVATE);
|
||||||
|
@ -1227,6 +1244,35 @@ uvm_fault_lower_lookup(
|
||||||
return uobjpage;
|
return uobjpage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* uvm_fault_lower_upgrade: upgrade lower lock, reader -> writer
|
||||||
|
*/
|
||||||
|
static inline int
|
||||||
|
uvm_fault_lower_upgrade(struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
|
||||||
|
struct vm_amap *amap, struct uvm_object *uobj)
|
||||||
|
{
|
||||||
|
KASSERT(uobj != NULL);
|
||||||
|
KASSERT(flt->lower_lock_type == rw_status(uobj->vmobjlock));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* fast path.
|
||||||
|
*/
|
||||||
|
if (flt->lower_lock_type == RW_WRITE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* otherwise try for the upgrade. if we don't get it, unlock
|
||||||
|
* everything, restart the fault and next time around get a writer
|
||||||
|
* lock.
|
||||||
|
*/
|
||||||
|
flt->lower_lock_type = RW_WRITE;
|
||||||
|
if (rw_enter(uobj->vmobjlock, RW_UPGRADE|RW_NOSLEEP)) {
|
||||||
|
uvmfault_unlockall(ufi, amap, uobj);
|
||||||
|
return ERESTART;
|
||||||
|
}
|
||||||
|
KASSERT(flt->lower_lock_type == rw_status(uobj->vmobjlock));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* uvm_fault_lower: handle lower fault.
|
* uvm_fault_lower: handle lower fault.
|
||||||
*
|
*
|
||||||
|
@ -1516,7 +1562,7 @@ uvm_fault_lower_io(
|
||||||
struct vm_page *pg;
|
struct vm_page *pg;
|
||||||
boolean_t locked;
|
boolean_t locked;
|
||||||
int gotpages, advice;
|
int gotpages, advice;
|
||||||
int result;
|
int error, result;
|
||||||
voff_t uoff;
|
voff_t uoff;
|
||||||
vm_prot_t access_type;
|
vm_prot_t access_type;
|
||||||
|
|
||||||
|
@ -1525,6 +1571,10 @@ uvm_fault_lower_io(
|
||||||
access_type = flt->access_type & MASK(ufi->entry);
|
access_type = flt->access_type & MASK(ufi->entry);
|
||||||
advice = ufi->entry->advice;
|
advice = ufi->entry->advice;
|
||||||
|
|
||||||
|
/* Upgrade to a write lock if needed. */
|
||||||
|
error = uvm_fault_lower_upgrade(ufi, flt, amap, uobj);
|
||||||
|
if (error != 0)
|
||||||
|
return error;
|
||||||
uvmfault_unlockall(ufi, amap, NULL);
|
uvmfault_unlockall(ufi, amap, NULL);
|
||||||
|
|
||||||
/* update rusage counters */
|
/* update rusage counters */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: uvm_map.c,v 1.337 2024/12/27 12:04:40 mpi Exp $ */
|
/* $OpenBSD: uvm_map.c,v 1.338 2025/01/29 15:25:31 mpi Exp $ */
|
||||||
/* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
|
/* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2954,7 +2954,7 @@ uvm_page_printit(struct vm_page *pg, boolean_t full,
|
||||||
(*pr)("PAGE %p:\n", pg);
|
(*pr)("PAGE %p:\n", pg);
|
||||||
(*pr)(" flags=%b, vers=%d, wire_count=%d, pa=0x%llx\n",
|
(*pr)(" flags=%b, vers=%d, wire_count=%d, pa=0x%llx\n",
|
||||||
pg->pg_flags, page_flagbits, pg->pg_version, pg->wire_count,
|
pg->pg_flags, page_flagbits, pg->pg_version, pg->wire_count,
|
||||||
(long long)pg->phys_addr);
|
(long long)VM_PAGE_TO_PHYS(pg));
|
||||||
(*pr)(" uobject=%p, uanon=%p, offset=0x%llx\n",
|
(*pr)(" uobject=%p, uanon=%p, offset=0x%llx\n",
|
||||||
pg->uobject, pg->uanon, (long long)pg->offset);
|
pg->uobject, pg->uanon, (long long)pg->offset);
|
||||||
#if defined(UVM_PAGE_TRKOWN)
|
#if defined(UVM_PAGE_TRKOWN)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: output.c,v 1.58 2024/12/13 19:22:01 claudio Exp $ */
|
/* $OpenBSD: output.c,v 1.59 2025/01/29 13:14:41 claudio Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
|
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
|
||||||
|
@ -66,7 +66,7 @@ show_head(struct parse_result *res)
|
||||||
break;
|
break;
|
||||||
printf("flags: "
|
printf("flags: "
|
||||||
"* = Valid, > = Selected, I = via IBGP, A = Announced,\n"
|
"* = Valid, > = Selected, I = via IBGP, A = Announced,\n"
|
||||||
" S = Stale, E = Error, F = Filtered\n");
|
" S = Stale, E = Error, F = Filtered, L = Leaked\n");
|
||||||
printf("origin validation state: "
|
printf("origin validation state: "
|
||||||
"N = not-found, V = valid, ! = invalid\n");
|
"N = not-found, V = valid, ! = invalid\n");
|
||||||
printf("aspa validation state: "
|
printf("aspa validation state: "
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: connection.c,v 1.24 2025/01/22 10:14:54 claudio Exp $ */
|
/* $OpenBSD: connection.c,v 1.25 2025/01/28 20:41:44 claudio Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
|
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
|
||||||
|
@ -335,42 +335,108 @@ log_debug("conn_parse_kvp: %s = %s", k->key, k->value);
|
||||||
#undef SET_BOOL
|
#undef SET_BOOL
|
||||||
#undef SET_DIGEST
|
#undef SET_DIGEST
|
||||||
|
|
||||||
|
#define GET_BOOL_P(dst, req, k, src, f) \
|
||||||
|
do { \
|
||||||
|
if (f == 0 && !strcmp(req, #k)) { \
|
||||||
|
(dst)->key = #k; \
|
||||||
|
(dst)->value = ((src)->mine.k) ? "Yes" : "No"; \
|
||||||
|
f++; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define GET_DIGEST_P(dst, req, k, src, f) \
|
||||||
|
do { \
|
||||||
|
if (f == 0 && !strcmp(req, #k)) { \
|
||||||
|
(dst)->key = #k; \
|
||||||
|
(dst)->value = \
|
||||||
|
((src)->mine.k == DIGEST_NONE) ? "None" : "CRC32C,None";\
|
||||||
|
f++; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define GET_NUM_P(dst, req, k, src, f, e) \
|
||||||
|
do { \
|
||||||
|
if (f == 0 && !strcmp(req, #k)) { \
|
||||||
|
(dst)->key = #k; \
|
||||||
|
if (asprintf(&((dst)->value), "%u", (src)->mine.k) == -1)\
|
||||||
|
e++; \
|
||||||
|
else \
|
||||||
|
(dst)->flags |= KVP_VALUE_ALLOCED; \
|
||||||
|
f++; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define GET_STR_C(dst, req, k, src, f) \
|
||||||
|
do { \
|
||||||
|
if (f == 0 && !strcmp(req, #k)) { \
|
||||||
|
(dst)->key = #k; \
|
||||||
|
(dst)->value = (src)->config.k; \
|
||||||
|
f++; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define GET_STYPE_C(dst, req, k, src, f) \
|
||||||
|
do { \
|
||||||
|
if (f == 0 && !strcmp(req, #k)) { \
|
||||||
|
(dst)->key = #k; \
|
||||||
|
(dst)->value = ((src)->config.k == SESSION_TYPE_DISCOVERY)\
|
||||||
|
? "Discovery" : "Normal"; \
|
||||||
|
f++; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
int
|
int
|
||||||
conn_gen_kvp(struct connection *c, struct kvp *kvp, size_t *nkvp)
|
kvp_set_from_mine(struct kvp *kvp, const char *key, struct connection *c)
|
||||||
{
|
{
|
||||||
struct session *s = c->session;
|
int e = 0, f = 0;
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
if (s->mine.MaxConnections != iscsi_sess_defaults.MaxConnections) {
|
if (kvp->flags & KVP_KEY_ALLOCED)
|
||||||
if (kvp && i < *nkvp) {
|
free(kvp->key);
|
||||||
kvp[i].key = "MaxConnections";
|
kvp->key = NULL;
|
||||||
if (asprintf(&kvp[i].value, "%hu",
|
if (kvp->flags & KVP_VALUE_ALLOCED)
|
||||||
s->mine.MaxConnections) == -1) {
|
free(kvp->value);
|
||||||
kvp[i].value = NULL;
|
kvp->value = NULL;
|
||||||
return -1;
|
kvp->flags = 0;
|
||||||
}
|
|
||||||
kvp[i].flags |= KVP_VALUE_ALLOCED;
|
/* XXX handle at least CHAP */
|
||||||
}
|
if (!strcmp(key, "AuthMethod")) {
|
||||||
i++;
|
kvp->key = "AuthMethod";
|
||||||
|
kvp->value = "None";
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
if (c->mine.MaxRecvDataSegmentLength !=
|
GET_DIGEST_P(kvp, key, HeaderDigest, c, f);
|
||||||
iscsi_conn_defaults.MaxRecvDataSegmentLength) {
|
GET_DIGEST_P(kvp, key, DataDigest, c, f);
|
||||||
if (kvp && i < *nkvp) {
|
GET_NUM_P(kvp, key, MaxConnections, c->session, f, e);
|
||||||
kvp[i].key = "MaxRecvDataSegmentLength";
|
GET_STR_C(kvp, key, TargetName, c->session, f);
|
||||||
if (asprintf(&kvp[i].value, "%u",
|
GET_STR_C(kvp, key, InitiatorName, c->session, f);
|
||||||
c->mine.MaxRecvDataSegmentLength) == -1) {
|
GET_BOOL_P(kvp, key, InitialR2T, c->session, f);
|
||||||
kvp[i].value = NULL;
|
GET_BOOL_P(kvp, key, ImmediateData, c->session, f);
|
||||||
return -1;
|
GET_NUM_P(kvp, key, MaxRecvDataSegmentLength, c, f, e);
|
||||||
}
|
GET_NUM_P(kvp, key, MaxBurstLength, c->session, f, e);
|
||||||
kvp[i].flags |= KVP_VALUE_ALLOCED;
|
GET_NUM_P(kvp, key, FirstBurstLength, c->session, f, e);
|
||||||
}
|
GET_NUM_P(kvp, key, DefaultTime2Wait, c->session, f, e);
|
||||||
i++;
|
GET_NUM_P(kvp, key, DefaultTime2Retain, c->session, f, e);
|
||||||
|
GET_NUM_P(kvp, key, MaxOutstandingR2T, c->session, f, e);
|
||||||
|
GET_BOOL_P(kvp, key, DataPDUInOrder, c->session, f);
|
||||||
|
GET_BOOL_P(kvp, key, DataSequenceInOrder, c->session, f);
|
||||||
|
GET_NUM_P(kvp, key, ErrorRecoveryLevel, c->session, f, e);
|
||||||
|
GET_STYPE_C(kvp, key, SessionType, c->session, f);
|
||||||
|
/* XXX handle TaskReporting */
|
||||||
|
|
||||||
|
if (f == 0) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*nkvp = i;
|
return e;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef GET_BOOL_P
|
||||||
|
#undef GET_DIGEST_P
|
||||||
|
#undef GET_NUM_P
|
||||||
|
#undef GET_STR_C
|
||||||
|
#undef GET_STYPE_C
|
||||||
|
|
||||||
void
|
void
|
||||||
conn_pdu_write(struct connection *c, struct pdu *p)
|
conn_pdu_write(struct connection *c, struct pdu *p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: initiator.c,v 1.20 2025/01/22 16:06:36 claudio Exp $ */
|
/* $OpenBSD: initiator.c,v 1.21 2025/01/28 20:41:44 claudio Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
|
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
|
||||||
|
@ -48,6 +48,7 @@ struct task_logout {
|
||||||
u_int8_t reason;
|
u_int8_t reason;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int conn_is_leading(struct connection *);
|
||||||
struct kvp *initiator_login_kvp(struct connection *, u_int8_t);
|
struct kvp *initiator_login_kvp(struct connection *, u_int8_t);
|
||||||
struct pdu *initiator_login_build(struct connection *,
|
struct pdu *initiator_login_build(struct connection *,
|
||||||
struct task_login *);
|
struct task_login *);
|
||||||
|
@ -308,49 +309,76 @@ initiator_nop_in_imm(struct connection *c, struct pdu *p)
|
||||||
conn_task_issue(c, t);
|
conn_task_issue(c, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
conn_is_leading(struct connection *c)
|
||||||
|
{
|
||||||
|
return c == TAILQ_FIRST(&c->session->connections);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MINE_NOT_DEFAULT(c, k) ((c)->mine.k != iscsi_conn_defaults.k)
|
||||||
|
|
||||||
struct kvp *
|
struct kvp *
|
||||||
initiator_login_kvp(struct connection *c, u_int8_t stage)
|
initiator_login_kvp(struct connection *c, u_int8_t stage)
|
||||||
{
|
{
|
||||||
struct kvp *kvp;
|
struct kvp *kvp = NULL;
|
||||||
size_t nkvp;
|
size_t i = 0, len;
|
||||||
|
const char *discovery[] = {"SessionType", "InitiatorName",
|
||||||
|
"AuthMethod", NULL};
|
||||||
|
const char *leading_only[] = {"MaxConnections", "InitialR2T",
|
||||||
|
"ImmediateData", "MaxBurstLength", "FirstBurstLength",
|
||||||
|
"DefaultTime2Wait", "DefaultTime2Retain", "MaxOutstandingR2T",
|
||||||
|
"DataPDUInOrder", "DataSequenceInOrder", "ErrorRecoveryLevel",
|
||||||
|
NULL};
|
||||||
|
const char *opneg_always[] = {"HeaderDigest", "DataDigest", NULL};
|
||||||
|
const char *secneg[] = {"SessionType", "InitiatorName", "TargetName",
|
||||||
|
"AuthMethod", NULL};
|
||||||
|
const char **p, **q;
|
||||||
|
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case ISCSI_LOGIN_STG_SECNEG:
|
case ISCSI_LOGIN_STG_SECNEG:
|
||||||
if (!(kvp = calloc(5, sizeof(*kvp))))
|
|
||||||
return NULL;
|
|
||||||
kvp[0].key = "AuthMethod";
|
|
||||||
kvp[0].value = "None";
|
|
||||||
kvp[1].key = "InitiatorName";
|
|
||||||
kvp[1].value = c->session->config.InitiatorName;
|
|
||||||
|
|
||||||
if (c->session->config.SessionType == SESSION_TYPE_DISCOVERY) {
|
if (c->session->config.SessionType == SESSION_TYPE_DISCOVERY) {
|
||||||
kvp[2].key = "SessionType";
|
len = sizeof(discovery) / sizeof(*discovery);
|
||||||
kvp[2].value = "Discovery";
|
q = discovery;
|
||||||
} else {
|
} else {
|
||||||
kvp[2].key = "SessionType";
|
len = sizeof(secneg) / sizeof(*secneg);
|
||||||
kvp[2].value = "Normal";
|
q = secneg;
|
||||||
kvp[3].key = "TargetName";
|
|
||||||
kvp[3].value = c->session->config.TargetName;
|
|
||||||
}
|
}
|
||||||
|
if (!(kvp = calloc(len + 1, sizeof(*kvp))))
|
||||||
|
return NULL;
|
||||||
|
for (p = q; *p != NULL; i++, p++)
|
||||||
|
if (kvp_set_from_mine(&kvp[i], *p, c))
|
||||||
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case ISCSI_LOGIN_STG_OPNEG:
|
case ISCSI_LOGIN_STG_OPNEG:
|
||||||
if (conn_gen_kvp(c, NULL, &nkvp) == -1)
|
len = sizeof(opneg_always) / sizeof(*opneg_always);
|
||||||
|
if (conn_is_leading(c))
|
||||||
|
len += sizeof(leading_only) / sizeof(*leading_only);
|
||||||
|
if (MINE_NOT_DEFAULT(c, MaxRecvDataSegmentLength))
|
||||||
|
len++;
|
||||||
|
if (!(kvp = calloc(len + 1, sizeof(*kvp))))
|
||||||
return NULL;
|
return NULL;
|
||||||
nkvp += 1; /* add slot for terminator */
|
for (p = opneg_always; *p != NULL; i++, p++)
|
||||||
if (!(kvp = calloc(nkvp, sizeof(*kvp))))
|
if (kvp_set_from_mine(&kvp[i], *p, c))
|
||||||
return NULL;
|
goto fail;
|
||||||
if (conn_gen_kvp(c, kvp, &nkvp) == -1) {
|
if (conn_is_leading(c))
|
||||||
kvp_free(kvp);
|
for (p = leading_only; *p != NULL; i++, p++)
|
||||||
return NULL;
|
if (kvp_set_from_mine(&kvp[i], *p, c))
|
||||||
}
|
goto fail;
|
||||||
|
if (MINE_NOT_DEFAULT(c, MaxRecvDataSegmentLength) &&
|
||||||
|
kvp_set_from_mine(&kvp[i], "MaxRecvDataSegmentLength", c))
|
||||||
|
goto fail;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_warnx("initiator_login_kvp: exit stage left");
|
log_warnx("initiator_login_kvp: exit stage left");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return kvp;
|
return kvp;
|
||||||
|
fail:
|
||||||
|
kvp_free(kvp);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef MINE_NOT_DEFAULT
|
||||||
struct pdu *
|
struct pdu *
|
||||||
initiator_login_build(struct connection *c, struct task_login *tl)
|
initiator_login_build(struct connection *c, struct task_login *tl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: iscsid.h,v 1.23 2025/01/22 16:06:36 claudio Exp $ */
|
/* $OpenBSD: iscsid.h,v 1.24 2025/01/28 20:41:44 claudio Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
|
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
|
||||||
|
@ -367,7 +367,7 @@ void conn_task_issue(struct connection *, struct task *);
|
||||||
void conn_task_schedule(struct connection *);
|
void conn_task_schedule(struct connection *);
|
||||||
void conn_task_cleanup(struct connection *, struct task *);
|
void conn_task_cleanup(struct connection *, struct task *);
|
||||||
int conn_parse_kvp(struct connection *, struct kvp *);
|
int conn_parse_kvp(struct connection *, struct kvp *);
|
||||||
int conn_gen_kvp(struct connection *, struct kvp *, size_t *);
|
int kvp_set_from_mine(struct kvp *, const char *, struct connection *);
|
||||||
void conn_pdu_write(struct connection *, struct pdu *);
|
void conn_pdu_write(struct connection *, struct pdu *);
|
||||||
void conn_fail(struct connection *);
|
void conn_fail(struct connection *);
|
||||||
void conn_fsm(struct connection *, enum c_event);
|
void conn_fsm(struct connection *, enum c_event);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: radius_req.c,v 1.12 2024/02/26 08:47:28 yasuoka Exp $ */
|
/* $OpenBSD: radius_req.c,v 1.13 2025/01/29 10:21:03 yasuoka Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2009 Internet Initiative Japan Inc.
|
* Copyright (c) 2009 Internet Initiative Japan Inc.
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
/**@file
|
/**@file
|
||||||
* This file provides functions for RADIUS request using radius(3) and event(3).
|
* This file provides functions for RADIUS request using radius(3) and event(3).
|
||||||
* @author Yasuoka Masahiko
|
* @author Yasuoka Masahiko
|
||||||
* $Id: radius_req.c,v 1.12 2024/02/26 08:47:28 yasuoka Exp $
|
* $Id: radius_req.c,v 1.13 2025/01/29 10:21:03 yasuoka Exp $
|
||||||
*/
|
*/
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -329,7 +329,7 @@ radius_cancel_request(RADIUS_REQUEST_CTX ctx)
|
||||||
}
|
}
|
||||||
radius_req_setting_unref(lap->setting);
|
radius_req_setting_unref(lap->setting);
|
||||||
|
|
||||||
memset(lap->secret, 0x41, sizeof(lap->secret));
|
explicit_bzero(lap->secret, sizeof(lap->secret));
|
||||||
|
|
||||||
free(lap);
|
free(lap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: radiusd.c,v 1.61 2024/11/21 13:43:10 claudio Exp $ */
|
/* $OpenBSD: radiusd.c,v 1.62 2025/01/29 10:12:22 yasuoka Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2023 Internet Initiative Japan Inc.
|
* Copyright (c) 2013, 2023 Internet Initiative Japan Inc.
|
||||||
|
@ -946,11 +946,11 @@ radiusd_on_sigchld(int fd, short evmask, void *ctx)
|
||||||
}
|
}
|
||||||
if (!module) {
|
if (!module) {
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
log_warnx("unkown child process pid=%d exited "
|
log_warnx("unknown child process pid=%d exited "
|
||||||
"with status %d", (int)pid,
|
"with status %d", (int)pid,
|
||||||
WEXITSTATUS(status));
|
WEXITSTATUS(status));
|
||||||
else
|
else
|
||||||
log_warnx("unkown child process pid=%d exited "
|
log_warnx("unknown child process pid=%d exited "
|
||||||
"by signal %d", (int)pid,
|
"by signal %d", (int)pid,
|
||||||
WTERMSIG(status));
|
WTERMSIG(status));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: radiusd_ipcp.c,v 1.21 2024/11/28 11:51:45 yasuoka Exp $ */
|
/* $OpenBSD: radiusd_ipcp.c,v 1.23 2025/01/29 10:16:05 yasuoka Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024 Internet Initiative Japan Inc.
|
* Copyright (c) 2024 Internet Initiative Japan Inc.
|
||||||
|
@ -897,6 +897,13 @@ ipcp_resdeco(void *ctx, u_int q_id, const u_char *req, size_t reqlen,
|
||||||
else if (radius_has_attr(radreq, RADIUS_TYPE_EAP_MESSAGE))
|
else if (radius_has_attr(radreq, RADIUS_TYPE_EAP_MESSAGE))
|
||||||
strlcpy(assigned->auth_method, "EAP",
|
strlcpy(assigned->auth_method, "EAP",
|
||||||
sizeof(assigned->auth_method));
|
sizeof(assigned->auth_method));
|
||||||
|
|
||||||
|
radius_get_ipv4_attr(radreq, RADIUS_TYPE_NAS_IP_ADDRESS,
|
||||||
|
&assigned->nas_ipv4);
|
||||||
|
radius_get_ipv6_attr(radreq, RADIUS_TYPE_NAS_IPV6_ADDRESS,
|
||||||
|
&assigned->nas_ipv6);
|
||||||
|
radius_get_string_attr(radreq, RADIUS_TYPE_NAS_IDENTIFIER,
|
||||||
|
assigned->nas_id, sizeof(assigned->nas_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->name_server[0].s_addr != 0) {
|
if (self->name_server[0].s_addr != 0) {
|
||||||
|
@ -937,7 +944,7 @@ ipcp_resdeco(void *ctx, u_int q_id, const u_char *req, size_t reqlen,
|
||||||
RADIUS_VTYPE_MS_SECONDARY_NBNS_SERVER,
|
RADIUS_VTYPE_MS_SECONDARY_NBNS_SERVER,
|
||||||
self->netbios_server[1]);
|
self->netbios_server[1]);
|
||||||
}
|
}
|
||||||
if (!self->no_session_timeout &&
|
if (!self->no_session_timeout && assigned != NULL &&
|
||||||
radius_has_attr(radres, RADIUS_TYPE_SESSION_TIMEOUT)) {
|
radius_has_attr(radres, RADIUS_TYPE_SESSION_TIMEOUT)) {
|
||||||
radius_get_uint32_attr(radres, RADIUS_TYPE_SESSION_TIMEOUT,
|
radius_get_uint32_attr(radres, RADIUS_TYPE_SESSION_TIMEOUT,
|
||||||
&assigned->session_timeout);
|
&assigned->session_timeout);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue