sync with OpenBSD -current

This commit is contained in:
purplerain 2024-03-31 19:11:21 +00:00
parent 38a9ea224a
commit 61b0c3d2c1
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
27 changed files with 196 additions and 125 deletions

View File

@ -4,3 +4,4 @@ DATA_PLT=
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
. ${srcdir}/emulparams/elf_obsd.sh
TRAP=0xf400fc01 # illop1

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crypto_namespace.h,v 1.2 2023/02/16 08:38:17 tb Exp $ */
/* $OpenBSD: crypto_namespace.h,v 1.3 2024/03/30 10:09:43 tb Exp $ */
/*
* Copyright (c) 2016 Philip Guenther <guenther@openbsd.org>
*
@ -25,14 +25,17 @@
*/
#ifdef LIBRESSL_NAMESPACE
# define LCRYPTO_UNUSED(x) typeof(x) x __attribute__((deprecated))
#ifdef LIBRESSL_CRYPTO_NAMESPACE
# define LCRYPTO_USED(x) __attribute__((visibility("hidden"))) \
# define LCRYPTO_UNUSED(x) __attribute__((deprecated)) \
__attribute__((visibility("hidden"))) \
typeof(x) x asm("_lcry_"#x)
# define LCRYPTO_USED(x) __attribute__((visibility("hidden"))) \
typeof(x) x asm("_lcry_"#x)
# define LCRYPTO_ALIAS1(pre,x) asm(".global "#pre#x"; "#pre#x" = _lcry_"#x)
# define LCRYPTO_ALIAS(x) LCRYPTO_ALIAS1(,x); LCRYPTO_ALIAS1(_libre_,x)
#else
# define LCRYPTO_USED(x) typeof(x) x asm("_libre_"#x)
# define LCRYPTO_UNUSED(x) typeof(x) x __attribute__((deprecated))
# define LCRYPTO_USED(x) typeof(x) x asm("_libre_"#x)
#endif
#else
# define LCRYPTO_UNUSED(x)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hmac.c,v 1.33 2024/03/26 12:10:50 joshua Exp $ */
/* $OpenBSD: hmac.c,v 1.34 2024/03/30 10:10:58 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -143,6 +143,7 @@ HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
HMAC_CTX_init(ctx);
return HMAC_Init_ex(ctx, key, len, md, NULL);
}
LCRYPTO_ALIAS(HMAC_Init);
int
HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len)
@ -203,6 +204,7 @@ HMAC_CTX_reset(HMAC_CTX *ctx)
HMAC_CTX_init(ctx);
return 1;
}
LCRYPTO_ALIAS(HMAC_CTX_reset);
void
HMAC_CTX_init(HMAC_CTX *ctx)

View File

@ -29,9 +29,9 @@ SECTIONS
. = ALIGN(0x1000);
*(.boot.text)
boot_text_end = .;
} :btext =0xf4005800
} :btext =0xf400fc01
. = ALIGN(0x1000);
.text : { *(.text .text.*) } :text =0xf4005800
.text : { *(.text .text.*) } :text =0xf400fc01
/* RELRO DATA */
. = DATA_SEGMENT_ALIGN (0x10000, 0x1000);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: evptest.c,v 1.14 2024/02/29 20:04:43 tb Exp $ */
/* $OpenBSD: evptest.c,v 1.15 2024/03/30 09:49:59 tb Exp $ */
/* Written by Ben Laurie, 2001 */
/*
* Copyright (c) 2001 The OpenSSL Project. All rights reserved.
@ -49,6 +49,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/opensslconf.h>
@ -129,13 +130,6 @@ ustrsep(char **p, const char *sep)
return (unsigned char *)sstrsep(p, sep);
}
static int
test1_exit(int ec)
{
exit(ec);
return(0); /* To keep some compilers quiet */
}
static void
test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
const unsigned char *iv, int in, const unsigned char *plaintext, int pn,
@ -159,12 +153,12 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
if (kn != EVP_CIPHER_key_length(c)) {
fprintf(stderr, "Key length doesn't match, got %d expected %lu\n",kn,
(unsigned long)EVP_CIPHER_key_length(c));
test1_exit(5);
exit(5);
}
if ((ctx = EVP_CIPHER_CTX_new()) == NULL) {
fprintf(stderr, "EVP_CIPHER_CTX_new failed\n");
ERR_print_errors_fp(stderr);
test1_exit(12);
exit(12);
}
EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
if (encdec != 0) {
@ -174,32 +168,32 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
if (!EVP_EncryptInit_ex(ctx, c, NULL, key, eiv)) {
fprintf(stderr, "EncryptInit failed\n");
ERR_print_errors_fp(stderr);
test1_exit(10);
exit(10);
}
EVP_CIPHER_CTX_set_padding(ctx, 0);
if (!EVP_EncryptUpdate(ctx, out, &outl, plaintext, pn)) {
fprintf(stderr, "Encrypt failed\n");
ERR_print_errors_fp(stderr);
test1_exit(6);
exit(6);
}
if (!EVP_EncryptFinal_ex(ctx, out + outl, &outl2)) {
fprintf(stderr, "EncryptFinal failed\n");
ERR_print_errors_fp(stderr);
test1_exit(7);
exit(7);
}
if (outl + outl2 != cn) {
fprintf(stderr, "Ciphertext length mismatch got %d expected %d\n",
outl + outl2, cn);
test1_exit(8);
exit(8);
}
if (memcmp(out, ciphertext, cn)) {
fprintf(stderr, "Ciphertext mismatch\n");
hexdump(stderr, "Got",out,cn);
hexdump(stderr, "Expected",ciphertext,cn);
test1_exit(9);
exit(9);
}
}
@ -210,32 +204,32 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
if (!EVP_DecryptInit_ex(ctx, c,NULL, key, eiv)) {
fprintf(stderr, "DecryptInit failed\n");
ERR_print_errors_fp(stderr);
test1_exit(11);
exit(11);
}
EVP_CIPHER_CTX_set_padding(ctx, 0);
if (!EVP_DecryptUpdate(ctx, out, &outl, ciphertext, cn)) {
fprintf(stderr, "Decrypt failed\n");
ERR_print_errors_fp(stderr);
test1_exit(6);
exit(6);
}
if (!EVP_DecryptFinal_ex(ctx, out + outl, &outl2)) {
fprintf(stderr, "DecryptFinal failed\n");
ERR_print_errors_fp(stderr);
test1_exit(7);
exit(7);
}
if (outl + outl2 != pn) {
fprintf(stderr, "Plaintext length mismatch got %d expected %d\n",
outl + outl2, pn);
test1_exit(8);
exit(8);
}
if (memcmp(out, plaintext, pn)) {
fprintf(stderr, "Plaintext mismatch\n");
hexdump(stderr, "Got",out,pn);
hexdump(stderr, "Expected",plaintext,pn);
test1_exit(9);
exit(9);
}
}
@ -283,7 +277,7 @@ test_digest(const char *digest, const unsigned char *plaintext, int pn,
if ((ctx = EVP_MD_CTX_new()) == NULL) {
fprintf(stderr, "EVP_CIPHER_CTX_new failed\n");
ERR_print_errors_fp(stderr);
test1_exit(104);
exit(104);
}
if (!EVP_DigestInit_ex(ctx, d, NULL)) {
fprintf(stderr, "DigestInit failed\n");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tlsexttest.c,v 1.89 2024/03/28 01:45:18 beck Exp $ */
/* $OpenBSD: tlsexttest.c,v 1.90 2024/03/30 09:53:41 tb Exp $ */
/*
* Copyright (c) 2017 Joel Sing <jsing@openbsd.org>
* Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@ -2040,7 +2040,7 @@ static const unsigned char tlsext_quic_transport_data[] = {
static int
test_tlsext_quic_transport_parameters_client(void)
{
const SSL_QUIC_METHOD quic_method;
const SSL_QUIC_METHOD quic_method = {0};
unsigned char *data = NULL;
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
@ -2171,7 +2171,7 @@ test_tlsext_quic_transport_parameters_client(void)
static int
test_tlsext_quic_transport_parameters_server(void)
{
const SSL_QUIC_METHOD quic_method;
const SSL_QUIC_METHOD quic_method = {0};
unsigned char *data = NULL;
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: isavar.h,v 1.58 2014/03/18 22:36:37 miod Exp $ */
/* $OpenBSD: isavar.h,v 1.59 2024/03/31 09:49:33 miod Exp $ */
/* $NetBSD: isavar.h,v 1.26 1997/06/06 23:43:57 thorpej Exp $ */
/*-
@ -119,8 +119,6 @@ struct isabus_attach_args;
#include <alpha/isa/isa_machdep.h>
#elif defined(__i386__)
#include <i386/isa/isa_machdep.h>
#elif defined(__powerpc__)
#include <powerpc/isa/isa_machdep.h>
#else
#include <machine/isa_machdep.h>
#endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: drm_linux.c,v 1.111 2024/03/20 02:42:17 jsg Exp $ */
/* $OpenBSD: drm_linux.c,v 1.112 2024/03/30 13:33:20 mpi Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@ -162,7 +162,7 @@ wake_up_process(struct proc *p)
int s, rv;
SCHED_LOCK(s);
rv = wakeup_proc(p, NULL, 0);
rv = wakeup_proc(p, 0);
SCHED_UNLOCK(s);
return rv;
}

View File

@ -1,4 +1,4 @@
$OpenBSD: pcidevs,v 1.2069 2024/03/23 10:35:50 sthen Exp $
$OpenBSD: pcidevs,v 1.2070 2024/03/30 11:12:20 jsg Exp $
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
/*
@ -310,6 +310,7 @@ vendor LENOVO 0x17aa Lenovo
vendor HAWKING 0x17b3 Hawking Technology
vendor QUALCOMM 0x17cb Qualcomm
vendor NETCHIP 0x17cc NetChip Technology
vendor CADENCE 0x17cd Cadence
vendor I4 0x17cf I4
vendor ARECA 0x17d3 Areca
vendor NETERION 0x17d5 Neterion
@ -348,6 +349,7 @@ vendor UMIS 0x1cc4 Union Memory
vendor BAIKAL 0x1d39 Baikal Electronics
vendor AQUANTIA 0x1d6a Aquantia
vendor ROCKCHIP 0x1d87 Rockchip
vendor LONGSYS 0x1d97 Longsys
vendor TEKRAM2 0x1de1 Tekram
vendor AMPERE 0x1def Ampere
vendor KIOXIA 0x1e0f Kioxia
@ -7367,6 +7369,9 @@ product LMC SSI 0x0005 SSI
product LMC DS1 0x0006 DS1
product LMC HSSIC 0x0007 HSSIc
/* Longsys products */
product LONGSYS FORESEE_XP1000 0x5216 FORESEE XP1000
/* Lucent products */
product LUCENT LTMODEM 0x0440 K56flex DSVD LTMODEM
product LUCENT LTMODEM_0441 0x0441 LTMODEM

View File

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2069 2024/03/23 10:35:50 sthen Exp
* OpenBSD: pcidevs,v 1.2070 2024/03/30 11:12:20 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -315,6 +315,7 @@
#define PCI_VENDOR_HAWKING 0x17b3 /* Hawking Technology */
#define PCI_VENDOR_QUALCOMM 0x17cb /* Qualcomm */
#define PCI_VENDOR_NETCHIP 0x17cc /* NetChip Technology */
#define PCI_VENDOR_CADENCE 0x17cd /* Cadence */
#define PCI_VENDOR_I4 0x17cf /* I4 */
#define PCI_VENDOR_ARECA 0x17d3 /* Areca */
#define PCI_VENDOR_NETERION 0x17d5 /* Neterion */
@ -353,6 +354,7 @@
#define PCI_VENDOR_BAIKAL 0x1d39 /* Baikal Electronics */
#define PCI_VENDOR_AQUANTIA 0x1d6a /* Aquantia */
#define PCI_VENDOR_ROCKCHIP 0x1d87 /* Rockchip */
#define PCI_VENDOR_LONGSYS 0x1d97 /* Longsys */
#define PCI_VENDOR_TEKRAM2 0x1de1 /* Tekram */
#define PCI_VENDOR_AMPERE 0x1def /* Ampere */
#define PCI_VENDOR_KIOXIA 0x1e0f /* Kioxia */
@ -7372,6 +7374,9 @@
#define PCI_PRODUCT_LMC_DS1 0x0006 /* DS1 */
#define PCI_PRODUCT_LMC_HSSIC 0x0007 /* HSSIc */
/* Longsys products */
#define PCI_PRODUCT_LONGSYS_FORESEE_XP1000 0x5216 /* FORESEE XP1000 */
/* Lucent products */
#define PCI_PRODUCT_LUCENT_LTMODEM 0x0440 /* K56flex DSVD LTMODEM */
#define PCI_PRODUCT_LUCENT_LTMODEM_0441 0x0441 /* LTMODEM */

View File

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2069 2024/03/23 10:35:50 sthen Exp
* OpenBSD: pcidevs,v 1.2070 2024/03/30 11:12:20 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -26671,6 +26671,10 @@ static const struct pci_known_product pci_known_products[] = {
PCI_VENDOR_LMC, PCI_PRODUCT_LMC_HSSIC,
"HSSIc",
},
{
PCI_VENDOR_LONGSYS, PCI_PRODUCT_LONGSYS_FORESEE_XP1000,
"FORESEE XP1000",
},
{
PCI_VENDOR_LUCENT, PCI_PRODUCT_LUCENT_LTMODEM,
"K56flex DSVD LTMODEM",
@ -37071,6 +37075,10 @@ static const struct pci_known_vendor pci_known_vendors[] = {
PCI_VENDOR_NETCHIP,
"NetChip Technology",
},
{
PCI_VENDOR_CADENCE,
"Cadence",
},
{
PCI_VENDOR_I4,
"I4",
@ -37223,6 +37231,10 @@ static const struct pci_known_vendor pci_known_vendors[] = {
PCI_VENDOR_ROCKCHIP,
"Rockchip",
},
{
PCI_VENDOR_LONGSYS,
"Longsys",
},
{
PCI_VENDOR_TEKRAM2,
"Tekram",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sig.c,v 1.322 2024/02/25 00:07:13 deraadt Exp $ */
/* $OpenBSD: kern_sig.c,v 1.323 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@ -1205,6 +1205,7 @@ runfast:
if (p->p_usrpri > PUSER)
p->p_usrpri = PUSER;
run:
unsleep(p);
setrunnable(p);
out:
/* finally adjust siglist */
@ -2109,6 +2110,7 @@ single_thread_set(struct proc *p, int flags)
if (q->p_flag & P_WEXIT) {
if (mode == SINGLE_EXIT) {
if (q->p_stat == SSTOP) {
unsleep(q);
setrunnable(q);
atomic_inc_int(&pr->ps_singlecount);
}
@ -2130,12 +2132,14 @@ single_thread_set(struct proc *p, int flags)
break;
}
/* need to unwind or exit, so wake it */
unsleep(q);
setrunnable(q);
}
atomic_inc_int(&pr->ps_singlecount);
break;
case SSTOP:
if (mode == SINGLE_EXIT) {
unsleep(q);
setrunnable(q);
atomic_inc_int(&pr->ps_singlecount);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_synch.c,v 1.200 2023/09/13 14:25:49 claudio Exp $ */
/* $OpenBSD: kern_synch.c,v 1.201 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
@ -467,25 +467,23 @@ sleep_signal_check(void)
}
int
wakeup_proc(struct proc *p, const volatile void *chan, int flags)
wakeup_proc(struct proc *p, int flags)
{
int awakened = 0;
SCHED_ASSERT_LOCKED();
if (p->p_wchan != NULL &&
((chan == NULL) || (p->p_wchan == chan))) {
if (p->p_wchan != NULL) {
awakened = 1;
if (flags)
atomic_setbits_int(&p->p_flag, flags);
#ifdef DIAGNOSTIC
if (p->p_stat != SSLEEP && p->p_stat != SSTOP)
panic("thread %d p_stat is %d", p->p_tid, p->p_stat);
#endif
unsleep(p);
if (p->p_stat == SSLEEP)
setrunnable(p);
else if (p->p_stat == SSTOP)
unsleep(p);
#ifdef DIAGNOSTIC
else
panic("wakeup: p_stat is %d", (int)p->p_stat);
#endif
}
return awakened;
@ -505,7 +503,7 @@ endtsleep(void *arg)
int s;
SCHED_LOCK(s);
wakeup_proc(p, NULL, P_TIMEOUT);
wakeup_proc(p, P_TIMEOUT);
SCHED_UNLOCK(s);
}
@ -531,21 +529,35 @@ unsleep(struct proc *p)
void
wakeup_n(const volatile void *ident, int n)
{
struct slpque *qp;
struct slpque *qp, wakeq;
struct proc *p;
struct proc *pnext;
int s;
TAILQ_INIT(&wakeq);
SCHED_LOCK(s);
qp = &slpque[LOOKUP(ident)];
for (p = TAILQ_FIRST(qp); p != NULL && n != 0; p = pnext) {
pnext = TAILQ_NEXT(p, p_runq);
#ifdef DIAGNOSTIC
if (p->p_stat != SSLEEP && p->p_stat != SSTOP)
panic("wakeup: p_stat is %d", (int)p->p_stat);
panic("thread %d p_stat is %d", p->p_tid, p->p_stat);
#endif
if (wakeup_proc(p, ident, 0))
KASSERT(p->p_wchan != NULL);
if (p->p_wchan == ident) {
TAILQ_REMOVE(qp, p, p_runq);
p->p_wchan = NULL;
TAILQ_INSERT_TAIL(&wakeq, p, p_runq);
--n;
}
}
while ((p = TAILQ_FIRST(&wakeq))) {
TAILQ_REMOVE(&wakeq, p, p_runq);
TRACEPOINT(sched, unsleep, p->p_tid + THREAD_PID_OFFSET,
p->p_p->ps_pid);
if (p->p_stat == SSLEEP)
setrunnable(p);
}
SCHED_UNLOCK(s);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sched_bsd.c,v 1.90 2024/01/24 19:23:38 cheloha Exp $ */
/* $OpenBSD: sched_bsd.c,v 1.91 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@ -500,12 +500,10 @@ setrunnable(struct proc *p)
if ((pr->ps_flags & PS_TRACED) != 0 && pr->ps_xsig != 0)
atomic_setbits_int(&p->p_siglist, sigmask(pr->ps_xsig));
prio = p->p_usrpri;
unsleep(p);
setrunqueue(NULL, p, prio);
break;
case SSLEEP:
prio = p->p_slppri;
unsleep(p); /* e.g. when sending signals */
/* if not yet asleep, don't add to runqueue */
if (ISSET(p->p_flag, P_WSLEEP))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sys_process.c,v 1.95 2023/11/21 14:00:13 bluhm Exp $ */
/* $OpenBSD: sys_process.c,v 1.96 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */
/*-
@ -493,6 +493,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data)
if (t->p_stat == SSTOP) {
tr->ps_xsig = data;
SCHED_LOCK(s);
unsleep(t);
setrunnable(t);
SCHED_UNLOCK(s);
} else {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sys_socket.c,v 1.62 2024/03/26 09:46:47 mvs Exp $ */
/* $OpenBSD: sys_socket.c,v 1.63 2024/03/31 13:50:00 mvs Exp $ */
/* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */
/*
@ -91,6 +91,7 @@ soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
case FIOASYNC:
solock(so);
mtx_enter(&so->so_rcv.sb_mtx);
if (*(int *)data) {
so->so_rcv.sb_flags |= SB_ASYNC;
so->so_snd.sb_flags |= SB_ASYNC;
@ -98,6 +99,7 @@ soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
so->so_rcv.sb_flags &= ~SB_ASYNC;
so->so_snd.sb_flags &= ~SB_ASYNC;
}
mtx_leave(&so->so_rcv.sb_mtx);
sounlock(so);
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.323 2024/03/27 22:47:53 mvs Exp $ */
/* $OpenBSD: uipc_socket.c,v 1.325 2024/03/31 14:01:28 mvs Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@ -155,6 +155,8 @@ soalloc(const struct protosw *prp, int wait)
case AF_INET6:
switch (prp->pr_type) {
case SOCK_DGRAM:
so->so_rcv.sb_flags |= SB_OWNLOCK;
/* FALLTHROUGH */
case SOCK_RAW:
so->so_rcv.sb_flags |= SB_MTXLOCK;
break;
@ -231,6 +233,14 @@ solisten(struct socket *so, int backlog)
int sominconn_local = READ_ONCE(sominconn);
int error;
switch (so->so_type) {
case SOCK_STREAM:
case SOCK_SEQPACKET:
break;
default:
return (EOPNOTSUPP);
}
soassertlocked(so);
if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING))
@ -1392,7 +1402,9 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
* we sleep, the socket buffers are not marked as spliced yet.
*/
if (somove(so, M_WAIT)) {
mtx_enter(&so->so_rcv.sb_mtx);
so->so_rcv.sb_flags |= SB_SPLICE;
mtx_leave(&so->so_rcv.sb_mtx);
sosp->so_snd.sb_flags |= SB_SPLICE;
}
@ -1420,7 +1432,9 @@ sounsplice(struct socket *so, struct socket *sosp, int freeing)
task_del(sosplice_taskq, &so->so_splicetask);
timeout_del(&so->so_idleto);
sosp->so_snd.sb_flags &= ~SB_SPLICE;
mtx_enter(&so->so_rcv.sb_mtx);
so->so_rcv.sb_flags &= ~SB_SPLICE;
mtx_leave(&so->so_rcv.sb_mtx);
so->so_sp->ssp_socket = sosp->so_sp->ssp_soback = NULL;
/* Do not wakeup a socket that is about to be freed. */
if ((freeing & SOSP_FREEING_READ) == 0 && soreadable(so))
@ -1678,6 +1692,7 @@ somove(struct socket *so, int wait)
pru_rcvd(so);
/* Receive buffer did shrink by len bytes, adjust oob. */
mtx_enter(&so->so_rcv.sb_mtx);
rcvstate = so->so_rcv.sb_state;
so->so_rcv.sb_state &= ~SS_RCVATMARK;
oobmark = so->so_oobmark;
@ -1688,6 +1703,7 @@ somove(struct socket *so, int wait)
if (oobmark >= len)
oobmark = 0;
}
mtx_leave(&so->so_rcv.sb_mtx);
/*
* Handle oob data. If any malloc fails, ignore error.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket2.c,v 1.146 2024/03/27 22:47:53 mvs Exp $ */
/* $OpenBSD: uipc_socket2.c,v 1.147 2024/03/31 13:50:00 mvs Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@ -351,7 +351,9 @@ void
socantrcvmore(struct socket *so)
{
soassertlocked(so);
mtx_enter(&so->so_rcv.sb_mtx);
so->so_rcv.sb_state |= SS_CANTRCVMORE;
mtx_leave(&so->so_rcv.sb_mtx);
sorwakeup(so);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: route.c,v 1.435 2024/02/29 12:01:59 naddy Exp $ */
/* $OpenBSD: route.c,v 1.436 2024/03/31 15:53:12 bluhm Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@ -239,6 +239,24 @@ route_cache(struct route *ro, const struct in_addr *dst,
return (ESRCH);
}
/*
* Check cache for route, else allocate a new one, potentially using multipath
* to select the peer. Update cache and return valid route or NULL.
*/
struct rtentry *
route_mpath(struct route *ro, const struct in_addr *dst,
const struct in_addr *src, u_int rtableid)
{
if (route_cache(ro, dst, src, rtableid)) {
uint32_t *s = NULL;
if (ro->ro_srcin.s_addr != INADDR_ANY)
s = &ro->ro_srcin.s_addr;
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa, s, ro->ro_tableid);
}
return (ro->ro_rt);
}
#ifdef INET6
int
route6_cache(struct route *ro, const struct in6_addr *dst,
@ -277,6 +295,20 @@ route6_cache(struct route *ro, const struct in6_addr *dst,
return (ESRCH);
}
struct rtentry *
route6_mpath(struct route *ro, const struct in6_addr *dst,
const struct in6_addr *src, u_int rtableid)
{
if (route6_cache(ro, dst, src, rtableid)) {
uint32_t *s = NULL;
if (!IN6_IS_ADDR_UNSPECIFIED(&ro->ro_srcin6))
s = &ro->ro_srcin6.s6_addr32[0];
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa, s, ro->ro_tableid);
}
return (ro->ro_rt);
}
#endif
/*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: route.h,v 1.209 2024/02/29 12:01:59 naddy Exp $ */
/* $OpenBSD: route.h,v 1.210 2024/03/31 15:53:12 bluhm Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@ -465,8 +465,12 @@ struct bfd_config;
void route_init(void);
int route_cache(struct route *, const struct in_addr *,
const struct in_addr *, u_int);
struct rtentry *route_mpath(struct route *, const struct in_addr *,
const struct in_addr *, u_int);
int route6_cache(struct route *, const struct in6_addr *,
const struct in6_addr *, u_int);
struct rtentry *route6_mpath(struct route *, const struct in6_addr *,
const struct in6_addr *, u_int);
void rtm_ifchg(struct ifnet *);
void rtm_ifannounce(struct ifnet *, int);
void rtm_bfd(struct bfd_config *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: in_pcb.c,v 1.298 2024/03/22 21:48:38 bluhm Exp $ */
/* $OpenBSD: in_pcb.c,v 1.299 2024/03/31 15:53:12 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@ -904,23 +904,15 @@ in_pcblookup_local_lock(struct inpcbtable *table, const void *laddrp,
struct rtentry *
in_pcbrtentry(struct inpcb *inp)
{
struct route *ro;
#ifdef INET6
if (ISSET(inp->inp_flags, INP_IPV6))
return in6_pcbrtentry(inp);
#endif
ro = &inp->inp_route;
if (inp->inp_faddr.s_addr == INADDR_ANY)
return (NULL);
if (route_cache(ro, &inp->inp_faddr, &inp->inp_laddr,
inp->inp_rtableid)) {
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa,
&inp->inp_laddr.s_addr, ro->ro_tableid);
}
return (ro->ro_rt);
return (route_mpath(&inp->inp_route, &inp->inp_faddr, &inp->inp_laddr,
inp->inp_rtableid));
}
/*
@ -934,7 +926,7 @@ in_pcbselsrc(struct in_addr *insrc, struct sockaddr_in *sin,
struct inpcb *inp)
{
struct ip_moptions *mopts = inp->inp_moptions;
struct route *ro = &inp->inp_route;
struct rtentry *rt;
const struct in_addr *laddr = &inp->inp_laddr;
u_int rtableid = inp->inp_rtableid;
struct sockaddr *ip4_source = NULL;
@ -979,17 +971,14 @@ in_pcbselsrc(struct in_addr *insrc, struct sockaddr_in *sin,
* If route is known or can be allocated now,
* our src addr is taken from the i/f, else punt.
*/
if (route_cache(ro, &sin->sin_addr, NULL, rtableid)) {
/* No route yet, so try to acquire one */
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa, NULL, ro->ro_tableid);
}
rt = route_mpath(&inp->inp_route, &sin->sin_addr, NULL, rtableid);
/*
* If we found a route, use the address
* corresponding to the outgoing interface.
*/
if (ro->ro_rt != NULL)
ia = ifatoia(ro->ro_rt->rt_ifa);
if (rt != NULL)
ia = ifatoia(rt->rt_ifa);
/*
* Use preferred source address if :
@ -997,8 +986,8 @@ in_pcbselsrc(struct in_addr *insrc, struct sockaddr_in *sin,
* - preferred source address is set
* - output interface is UP
*/
if (ro->ro_rt && !(ro->ro_rt->rt_flags & RTF_LLINFO) &&
!(ro->ro_rt->rt_flags & RTF_HOST)) {
if (rt != NULL && !(rt->rt_flags & RTF_LLINFO) &&
!(rt->rt_flags & RTF_HOST)) {
ip4_source = rtable_getsource(rtableid, AF_INET);
if (ip4_source != NULL) {
struct ifaddr *ifa;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: in6_pcb.c,v 1.142 2024/03/22 18:05:01 bluhm Exp $ */
/* $OpenBSD: in6_pcb.c,v 1.143 2024/03/31 15:53:12 bluhm Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -561,16 +561,10 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr_in6 *dst,
struct rtentry *
in6_pcbrtentry(struct inpcb *inp)
{
struct route *ro = &inp->inp_route;
if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
return (NULL);
if (route6_cache(ro, &inp->inp_faddr6, &inp->inp_laddr6,
inp->inp_rtableid)) {
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa,
&inp->inp_laddr6.s6_addr32[0], ro->ro_tableid);
}
return (ro->ro_rt);
return (route6_mpath(&inp->inp_route, &inp->inp_faddr6,
&inp->inp_laddr6, inp->inp_rtableid));
}
struct inpcb *

View File

@ -1,4 +1,4 @@
/* $OpenBSD: in6_src.c,v 1.97 2024/02/29 12:01:59 naddy Exp $ */
/* $OpenBSD: in6_src.c,v 1.98 2024/03/31 15:53:12 bluhm Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@ -95,7 +95,7 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
struct inpcb *inp, struct ip6_pktopts *opts)
{
struct ip6_moptions *mopts = inp->inp_moptions6;
struct route *ro = &inp->inp_route;
struct rtentry *rt;
const struct in6_addr *laddr = &inp->inp_laddr6;
u_int rtableid = inp->inp_rtableid;
struct ifnet *ifp = NULL;
@ -118,7 +118,8 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
struct sockaddr_in6 sa6;
/* get the outgoing interface */
error = in6_selectif(dst, opts, mopts, ro, &ifp, rtableid);
error = in6_selectif(dst, opts, mopts, &inp->inp_route, &ifp,
rtableid);
if (error)
return (error);
@ -179,9 +180,7 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
* If route is known or can be allocated now,
* our src addr is taken from the i/f, else punt.
*/
if (route6_cache(ro, dst, NULL, rtableid)) {
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa, NULL, ro->ro_tableid);
}
rt = route6_mpath(&inp->inp_route, dst, NULL, rtableid);
/*
* in_pcbconnect() checks out IFF_LOOPBACK to skip using
@ -190,14 +189,14 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
* so doesn't check out IFF_LOOPBACK.
*/
if (ro->ro_rt) {
ifp = if_get(ro->ro_rt->rt_ifidx);
if (rt != NULL) {
ifp = if_get(rt->rt_ifidx);
if (ifp != NULL) {
ia6 = in6_ifawithscope(ifp, dst, rtableid);
if_put(ifp);
}
if (ia6 == NULL) /* xxx scope error ?*/
ia6 = ifatoia6(ro->ro_rt->rt_ifa);
ia6 = ifatoia6(rt->rt_ifa);
}
/*
@ -206,8 +205,8 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
* - preferred source address is set
* - output interface is UP
*/
if (ro->ro_rt && !(ro->ro_rt->rt_flags & RTF_LLINFO) &&
!(ro->ro_rt->rt_flags & RTF_HOST)) {
if (rt != NULL && !(rt->rt_flags & RTF_LLINFO) &&
!(rt->rt_flags & RTF_HOST)) {
ip6_source = rtable_getsource(rtableid, AF_INET6);
if (ip6_source != NULL) {
struct ifaddr *ifa;
@ -304,11 +303,9 @@ in6_selectroute(const struct in6_addr *dst, struct ip6_pktopts *opts,
* a new one.
*/
if (ro) {
if (route6_cache(ro, dst, NULL, rtableid)) {
/* No route yet, so try to acquire one */
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa, NULL,
ro->ro_tableid);
}
struct rtentry *rt;
rt = route6_mpath(ro, dst, NULL, rtableid);
/*
* Check if the outgoing interface conflicts with
@ -319,15 +316,13 @@ in6_selectroute(const struct in6_addr *dst, struct ip6_pktopts *opts,
*/
if (opts && opts->ip6po_pktinfo &&
opts->ip6po_pktinfo->ipi6_ifindex) {
if (ro->ro_rt != NULL &&
!ISSET(ro->ro_rt->rt_flags, RTF_LOCAL) &&
ro->ro_rt->rt_ifidx !=
opts->ip6po_pktinfo->ipi6_ifindex) {
if (rt != NULL && !ISSET(rt->rt_flags, RTF_LOCAL) &&
rt->rt_ifidx != opts->ip6po_pktinfo->ipi6_ifindex) {
return (NULL);
}
}
return (ro->ro_rt);
return (rt);
}
return (NULL);
@ -338,7 +333,7 @@ in6_selectif(const struct in6_addr *dst, struct ip6_pktopts *opts,
struct ip6_moptions *mopts, struct route *ro, struct ifnet **retifp,
u_int rtableid)
{
struct rtentry *rt = NULL;
struct rtentry *rt;
struct in6_pktinfo *pi = NULL;
/* If the caller specify the outgoing interface explicitly, use it. */
@ -377,11 +372,10 @@ in6_selectif(const struct in6_addr *dst, struct ip6_pktopts *opts,
* Although this may not be very harmful, it should still be confusing.
* We thus reject the case here.
*/
if (rt && (rt->rt_flags & (RTF_REJECT | RTF_BLACKHOLE)))
if (ISSET(rt->rt_flags, RTF_REJECT | RTF_BLACKHOLE))
return (rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
if (rt != NULL)
*retifp = if_get(rt->rt_ifidx);
*retifp = if_get(rt->rt_ifidx);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: nfs_socket.c,v 1.146 2024/03/22 07:15:04 claudio Exp $ */
/* $OpenBSD: nfs_socket.c,v 1.147 2024/03/31 13:50:00 mvs Exp $ */
/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
@ -371,7 +371,9 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep)
error = soreserve(so, sndreserve, rcvreserve);
if (error)
goto bad_locked;
mtx_enter(&so->so_rcv.sb_mtx);
so->so_rcv.sb_flags |= SB_NOINTR;
mtx_leave(&so->so_rcv.sb_mtx);
so->so_snd.sb_flags |= SB_NOINTR;
sounlock(so);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: nfs_syscalls.c,v 1.122 2024/03/22 07:15:04 claudio Exp $ */
/* $OpenBSD: nfs_syscalls.c,v 1.123 2024/03/31 13:50:00 mvs Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@ -297,12 +297,12 @@ nfssvc_addsock(struct file *fp, struct mbuf *mynam)
m_freem(m);
}
solock(so);
so->so_rcv.sb_flags &= ~SB_NOINTR;
mtx_enter(&so->so_rcv.sb_mtx);
so->so_rcv.sb_flags &= ~SB_NOINTR;
so->so_rcv.sb_timeo_nsecs = INFSLP;
mtx_leave(&so->so_rcv.sb_mtx);
so->so_snd.sb_flags &= ~SB_NOINTR;
mtx_enter(&so->so_snd.sb_mtx);
so->so_snd.sb_flags &= ~SB_NOINTR;
so->so_snd.sb_timeo_nsecs = INFSLP;
mtx_leave(&so->so_snd.sb_mtx);
sounlock(so);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.h,v 1.356 2024/02/03 18:51:58 beck Exp $ */
/* $OpenBSD: proc.h,v 1.357 2024/03/30 13:33:21 mpi Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@ -555,7 +555,7 @@ void procinit(void);
void setpriority(struct proc *, uint32_t, uint8_t);
void setrunnable(struct proc *);
void endtsleep(void *);
int wakeup_proc(struct proc *, const volatile void *, int);
int wakeup_proc(struct proc *, int);
void unsleep(struct proc *);
void reaper(void *);
__dead void exit1(struct proc *, int, int, int);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uvm.h,v 1.71 2022/10/07 05:01:44 deraadt Exp $ */
/* $OpenBSD: uvm.h,v 1.72 2024/03/30 12:47:47 mpi Exp $ */
/* $NetBSD: uvm.h,v 1.24 2000/11/27 08:40:02 chs Exp $ */
/*
@ -47,6 +47,7 @@
*
* Locks used to protect struct members in this file:
* Q uvm.pageqlock
* F uvm.fpageqlock
*/
struct uvm {
/* vm_page related parameters */
@ -58,7 +59,7 @@ struct uvm {
struct mutex pageqlock; /* [] lock for active/inactive page q */
struct mutex fpageqlock; /* [] lock for free page q + pdaemon */
boolean_t page_init_done; /* TRUE if uvm_page_init() finished */
struct uvm_pmr_control pmr_control; /* pmemrange data */
struct uvm_pmr_control pmr_control; /* [F] pmemrange data */
/* page daemon trigger */
int pagedaemon; /* daemon sleeps on this */