sync with OpenBSD -current

This commit is contained in:
purplerain 2025-01-16 19:47:34 +00:00
parent 9134045afa
commit ec3f37444a
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
30 changed files with 3441 additions and 481 deletions

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: pcap_open_live.3,v 1.4 2020/05/29 05:51:19 jmc Exp $ .\" $OpenBSD: pcap_open_live.3,v 1.5 2025/01/16 04:02:08 dlg Exp $
.\" .\"
.\" Copyright (c) 1994, 1996, 1997 .\" Copyright (c) 1994, 1996, 1997
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -19,7 +19,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\" .\"
.Dd $Mdocdate: May 29 2020 $ .Dd $Mdocdate: January 16 2025 $
.Dt PCAP_OPEN_LIVE 3 .Dt PCAP_OPEN_LIVE 3
.Os .Os
.Sh NAME .Sh NAME
@ -169,7 +169,7 @@
.Fn pcap_list_datalinks "pcap_t *p" "int **dlt_buffer" .Fn pcap_list_datalinks "pcap_t *p" "int **dlt_buffer"
.Ft void .Ft void
.Fn pcap_free_datalinks "int *dlt_list" .Fn pcap_free_datalinks "int *dlt_list"
.Ft pcap_t .Ft pcap_t *
.Fn pcap_open_dead "int linktype" "int snaplen" .Fn pcap_open_dead "int linktype" "int snaplen"
.Ft pcap_t .Ft pcap_t
.Fn pcap_fopen_offline "FILE *fp" "char *errbuf" .Fn pcap_fopen_offline "FILE *fp" "char *errbuf"

View file

@ -1,4 +1,4 @@
/* $OpenBSD: mountd.c,v 1.96 2024/11/21 13:35:20 claudio Exp $ */ /* $OpenBSD: mountd.c,v 1.97 2025/01/16 12:48:45 kn Exp $ */
/* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */
/* /*
@ -373,6 +373,19 @@ privchild(int sock)
char *path; char *path;
int error, size; int error, size;
if (unveil("/", "r") == -1) {
syslog(LOG_ERR, "unveil /: %m");
_exit(1);
}
if (unveil(_PATH_RMOUNTLIST, "rwc") == -1) {
syslog(LOG_ERR, "unveil %s: %m", _PATH_RMOUNTLIST);
_exit(1);
}
if (unveil(NULL, NULL) == -1) {
syslog(LOG_ERR, "unveil: %m");
_exit(1);
}
if (imsgbuf_init(&ibuf, sock) == -1) { if (imsgbuf_init(&ibuf, sock) == -1) {
syslog(LOG_ERR, "imsgbuf_init: %m"); syslog(LOG_ERR, "imsgbuf_init: %m");
_exit(1); _exit(1);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nfsd.c,v 1.44 2025/01/11 18:21:02 kn Exp $ */ /* $OpenBSD: nfsd.c,v 1.45 2025/01/16 12:46:03 kn Exp $ */
/* $NetBSD: nfsd.c,v 1.19 1996/02/18 23:18:56 mycroft Exp $ */ /* $NetBSD: nfsd.c,v 1.19 1996/02/18 23:18:56 mycroft Exp $ */
/* /*
@ -113,6 +113,15 @@ main(int argc, char *argv[])
/* Start by writing to both console and log. */ /* Start by writing to both console and log. */
openlog("nfsd", LOG_PID | LOG_PERROR, LOG_DAEMON); openlog("nfsd", LOG_PID | LOG_PERROR, LOG_DAEMON);
if (unveil("/", "") == -1) {
syslog(LOG_ERR, "unveil /: %s", strerror(errno));
return (1);
}
if (unveil(NULL, NULL) == -1) {
syslog(LOG_ERR, "unveil: %s", strerror(errno));
return (1);
}
while ((ch = getopt(argc, argv, "n:rtu")) != -1) while ((ch = getopt(argc, argv, "n:rtu")) != -1)
switch (ch) { switch (ch) {
case 'n': case 'n':

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: video.4,v 1.20 2022/03/31 17:27:21 naddy Exp $ .\" $OpenBSD: video.4,v 1.21 2025/01/15 20:34:50 kirill Exp $
.\" .\"
.\" Copyright (c) 2008 Marcus Glocker <mglocker@openbsd.org> .\" Copyright (c) 2008 Marcus Glocker <mglocker@openbsd.org>
.\" .\"
@ -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: March 31 2022 $ .Dd $Mdocdate: January 15 2025 $
.Dt VIDEO 4 .Dt VIDEO 4
.Os .Os
.Sh NAME .Sh NAME
@ -80,7 +80,8 @@ struct v4l2_fmtdesc {
u_int32_t flags; u_int32_t flags;
u_int8_t description[32]; u_int8_t description[32];
u_int32_t pixelformat; u_int32_t pixelformat;
u_int32_t reserved[4]; u_int32_t mbus_code;
u_int32_t reserved[3];
}; };
.Ed .Ed
.It Dv VIDIOC_S_FMT Fa "struct v4l2_format *" .It Dv VIDIOC_S_FMT Fa "struct v4l2_format *"
@ -95,6 +96,7 @@ struct v4l2_format {
struct v4l2_vbi_format vbi; struct v4l2_vbi_format vbi;
struct v4l2_sliced_vbi_format sliced; struct v4l2_sliced_vbi_format sliced;
struct v4l2_sdr_format sdr; struct v4l2_sdr_format sdr;
struct v4l2_meta_format meta;
u_int8_t raw_data[200]; u_int8_t raw_data[200];
} fmt; } fmt;
}; };
@ -130,7 +132,9 @@ struct v4l2_requestbuffers {
u_int32_t count; u_int32_t count;
u_int32_t type; u_int32_t type;
u_int32_t memory; u_int32_t memory;
u_int32_t reserved[2]; u_int32_t capabilities;
u_Int32_t flags;
u_int32_t reserved[3];
}; };
.Ed .Ed
.It Dv VIDIOC_QUERYBUF Fa "struct v4l2_buffer *" .It Dv VIDIOC_QUERYBUF Fa "struct v4l2_buffer *"
@ -154,7 +158,10 @@ struct v4l2_buffer {
} m; } m;
u_int32_t length; u_int32_t length;
u_int32_t reserved2; u_int32_t reserved2;
union {
int32_t request_fd;
u_int32_t reserved; u_int32_t reserved;
}
}; };
.Ed .Ed
.It Dv VIDIOC_QBUF Fa "struct v4l2_buffer *" .It Dv VIDIOC_QBUF Fa "struct v4l2_buffer *"
@ -265,6 +272,9 @@ enum v4l2_buf_type {
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
V4L2_BUF_TYPE_SDR_CAPTURE = 11, V4L2_BUF_TYPE_SDR_CAPTURE = 11,
V4L2_BUF_TYPE_SDR_OUTPUT = 12, V4L2_BUF_TYPE_SDR_OUTPUT = 12,
V4L2_BUF_TYPE_META_CAPTURE = 13,
V4L2_BUF_TYPE_META_OUTPUT = 14,
/* Deprecated, do not use */
V4L2_BUF_TYPE_PRIVATE = 0x80, V4L2_BUF_TYPE_PRIVATE = 0x80,
}; };
@ -289,6 +299,40 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_U8 = 0x0100, V4L2_CTRL_TYPE_U8 = 0x0100,
V4L2_CTRL_TYPE_U16 = 0x0101, V4L2_CTRL_TYPE_U16 = 0x0101,
V4L2_CTRL_TYPE_U32 = 0x0102, V4L2_CTRL_TYPE_U32 = 0x0102,
V4L2_CTRL_TYPE_AREA = 0x0106,
/* Compound types are >= 0x0100 */
V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110,
V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111,
V4L2_CTRL_TYPE_H264_SPS = 0x0200,
V4L2_CTRL_TYPE_H264_PPS = 0x0201,
V4L2_CTRL_TYPE_H264_SCALING_MATRIX = 0x0202,
V4L2_CTRL_TYPE_H264_SLICE_PARAMS = 0x0203,
V4L2_CTRL_TYPE_H264_DECODE_PARAMS = 0x0204,
V4L2_CTRL_TYPE_H264_PRED_WEIGHTS = 0x0205,
V4L2_CTRL_TYPE_FWHT_PARAMS = 0x0220,
V4L2_CTRL_TYPE_VP8_FRAME = 0x0240,
V4L2_CTRL_TYPE_MPEG2_QUANTISATION = 0x0250,
V4L2_CTRL_TYPE_MPEG2_SEQUENCE = 0x0251,
V4L2_CTRL_TYPE_MPEG2_PICTURE = 0x0252,
V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR = 0x0260,
V4L2_CTRL_TYPE_VP9_FRAME = 0x0261,
V4L2_CTRL_TYPE_HEVC_SPS = 0x0270,
V4L2_CTRL_TYPE_HEVC_PPS = 0x0271,
V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS = 0x0272,
V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX = 0x0273,
V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS = 0x0274,
V4L2_CTRL_TYPE_AV1_SEQUENCE = 0x280,
V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281,
V4L2_CTRL_TYPE_AV1_FRAME = 0x282,
V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283,
}; };
enum v4l2_frmivaltypes { enum v4l2_frmivaltypes {
@ -310,7 +354,6 @@ struct v4l2_pix_format {
u_int32_t colorspace; u_int32_t colorspace;
u_int32_t priv; u_int32_t priv;
u_int32_t flags; u_int32_t flags;
u_int32_t ycbcr_enc;
union { union {
u_int32_t ycbcr_enc; u_int32_t ycbcr_enc;
u_int32_t hsv_enc; u_int32_t hsv_enc;
@ -323,7 +366,7 @@ struct v4l2_window {
struct v4l2_rect w; struct v4l2_rect w;
u_int32_t field; u_int32_t field;
u_int32_t chromakey; u_int32_t chromakey;
struct v4l2_clip __user *clips; struct v4l2_clip *clips;
u_int32_t clipcount; u_int32_t clipcount;
void __user *bitmap; void __user *bitmap;
u_int8_t global_alpha; u_int8_t global_alpha;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vioblk.c,v 1.44 2024/12/20 22:18:27 sf Exp $ */ /* $OpenBSD: vioblk.c,v 1.45 2025/01/16 10:33:27 sf Exp $ */
/* /*
* Copyright (c) 2012 Stefan Fritsch. * Copyright (c) 2012 Stefan Fritsch.
@ -67,7 +67,7 @@
/* In the virtqueue, we need space for header and footer, too */ /* In the virtqueue, we need space for header and footer, too */
#define ALLOC_SEGS (SEG_MAX + 2) #define ALLOC_SEGS (SEG_MAX + 2)
struct virtio_feature_name vioblk_feature_names[] = { static const struct virtio_feature_name vioblk_feature_names[] = {
#if VIRTIO_DEBUG #if VIRTIO_DEBUG
{ VIRTIO_BLK_F_BARRIER, "Barrier" }, { VIRTIO_BLK_F_BARRIER, "Barrier" },
{ VIRTIO_BLK_F_SIZE_MAX, "SizeMax" }, { VIRTIO_BLK_F_SIZE_MAX, "SizeMax" },

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viocon.c,v 1.16 2024/12/20 22:18:27 sf Exp $ */ /* $OpenBSD: viocon.c,v 1.17 2025/01/16 10:33:27 sf Exp $ */
/* /*
* Copyright (c) 2013-2015 Stefan Fritsch <sf@sfritsch.de> * Copyright (c) 2013-2015 Stefan Fritsch <sf@sfritsch.de>
@ -46,7 +46,7 @@
#define DPRINTF(x...) #define DPRINTF(x...)
#endif #endif
struct virtio_feature_name viocon_feature_names[] = { static const struct virtio_feature_name viocon_feature_names[] = {
#if VIRTIO_DEBUG #if VIRTIO_DEBUG
{ VIRTIO_CONSOLE_F_SIZE, "Size" }, { VIRTIO_CONSOLE_F_SIZE, "Size" },
{ VIRTIO_CONSOLE_F_MULTIPORT, "MultiPort" }, { VIRTIO_CONSOLE_F_MULTIPORT, "MultiPort" },

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viogpu.c,v 1.11 2024/12/20 22:18:27 sf Exp $ */ /* $OpenBSD: viogpu.c,v 1.12 2025/01/16 10:33:27 sf Exp $ */
/* /*
* Copyright (c) 2021-2023 joshua stein <jcs@openbsd.org> * Copyright (c) 2021-2023 joshua stein <jcs@openbsd.org>
@ -93,7 +93,7 @@ struct viogpu_softc {
struct timeout sc_timo; struct timeout sc_timo;
}; };
struct virtio_feature_name viogpu_feature_names[] = { static const struct virtio_feature_name viogpu_feature_names[] = {
#if VIRTIO_DEBUG #if VIRTIO_DEBUG
{ VIRTIO_GPU_F_VIRGL, "VirGL" }, { VIRTIO_GPU_F_VIRGL, "VirGL" },
{ VIRTIO_GPU_F_EDID, "EDID" }, { VIRTIO_GPU_F_EDID, "EDID" },

View file

@ -1,4 +1,4 @@
/* $OpenBSD: utvfu.c,v 1.21 2025/01/12 16:39:39 mglocker Exp $ */ /* $OpenBSD: utvfu.c,v 1.22 2025/01/15 20:34:50 kirill Exp $ */
/* /*
* Copyright (c) 2013 Lubomir Rintel * Copyright (c) 2013 Lubomir Rintel
* Copyright (c) 2013 Federico Simoncelli * Copyright (c) 2013 Federico Simoncelli
@ -1693,6 +1693,8 @@ utvfu_reqbufs(void *v, struct v4l2_requestbuffers *rb)
/* tell how many buffers we have really allocated */ /* tell how many buffers we have really allocated */
rb->count = sc->sc_mmap_count; rb->count = sc->sc_mmap_count;
rb->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP;
return (0); return (0);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uvideo.c,v 1.234 2025/01/13 15:32:36 kirill Exp $ */ /* $OpenBSD: uvideo.c,v 1.235 2025/01/15 20:34:50 kirill Exp $ */
/* /*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org> * Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@ -3347,6 +3347,8 @@ uvideo_reqbufs(void *v, struct v4l2_requestbuffers *rb)
/* tell how many buffers we have really allocated */ /* tell how many buffers we have really allocated */
rb->count = sc->sc_mmap_count; rb->count = sc->sc_mmap_count;
rb->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP;
return (0); return (0);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket2.c,v 1.164 2025/01/05 12:36:48 bluhm Exp $ */ /* $OpenBSD: uipc_socket2.c,v 1.165 2025/01/16 16:35:01 bluhm Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/* /*
@ -186,14 +186,8 @@ struct socket *
sonewconn(struct socket *head, int connstatus, int wait) sonewconn(struct socket *head, int connstatus, int wait)
{ {
struct socket *so; struct socket *so;
int persocket = solock_persocket(head);
int soqueue = connstatus ? 1 : 0; int soqueue = connstatus ? 1 : 0;
/*
* XXXSMP as long as `so' and `head' share the same lock, we
* can call soreserve() and pr_attach() below w/o explicitly
* locking `so'.
*/
soassertlocked(head); soassertlocked(head);
if (m_pool_used() > 95) if (m_pool_used() > 95)
@ -218,8 +212,7 @@ sonewconn(struct socket *head, int connstatus, int wait)
/* /*
* Lock order will be `head' -> `so' while these sockets are linked. * Lock order will be `head' -> `so' while these sockets are linked.
*/ */
if (persocket) solock_nonet(so);
solock(so);
/* /*
* Inherit watermarks but those may get clamped in low mem situations. * Inherit watermarks but those may get clamped in low mem situations.
@ -252,14 +245,12 @@ sonewconn(struct socket *head, int connstatus, int wait)
wakeup(&head->so_timeo); wakeup(&head->so_timeo);
} }
if (persocket) sounlock_nonet(so);
sounlock(so);
return (so); return (so);
fail: fail:
if (persocket) sounlock_nonet(so);
sounlock(so);
sigio_free(&so->so_sigio); sigio_free(&so->so_sigio);
klist_free(&so->so_rcv.sb_klist); klist_free(&so->so_rcv.sb_klist);
klist_free(&so->so_snd.sb_klist); klist_free(&so->so_snd.sb_klist);
@ -363,12 +354,21 @@ solock_shared(struct socket *so)
case PF_INET: case PF_INET:
case PF_INET6: case PF_INET6:
NET_LOCK_SHARED(); NET_LOCK_SHARED();
rw_enter_write(&so->so_lock);
break;
default:
rw_enter_write(&so->so_lock);
break; break;
} }
rw_enter_write(&so->so_lock);
}
void
solock_nonet(struct socket *so)
{
switch (so->so_proto->pr_domain->dom_family) {
case PF_INET:
case PF_INET6:
NET_ASSERT_LOCKED();
break;
}
rw_enter_write(&so->so_lock);
} }
int int
@ -416,18 +416,21 @@ sounlock(struct socket *so)
void void
sounlock_shared(struct socket *so) sounlock_shared(struct socket *so)
{ {
rw_exit_write(&so->so_lock);
switch (so->so_proto->pr_domain->dom_family) { switch (so->so_proto->pr_domain->dom_family) {
case PF_INET: case PF_INET:
case PF_INET6: case PF_INET6:
rw_exit_write(&so->so_lock);
NET_UNLOCK_SHARED(); NET_UNLOCK_SHARED();
break; break;
default:
rw_exit_write(&so->so_lock);
break;
} }
} }
void
sounlock_nonet(struct socket *so)
{
rw_exit_write(&so->so_lock);
}
void void
soassertlocked_readonly(struct socket *so) soassertlocked_readonly(struct socket *so)
{ {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_syscalls.c,v 1.221 2025/01/05 11:33:45 mvs Exp $ */ /* $OpenBSD: uipc_syscalls.c,v 1.222 2025/01/16 16:35:01 bluhm Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/* /*
@ -247,34 +247,6 @@ sys_accept4(struct proc *p, void *v, register_t *retval)
SCARG(uap, anamelen), SCARG(uap, flags), retval)); SCARG(uap, anamelen), SCARG(uap, flags), retval));
} }
void
doaccept_solock(struct socket *so, int take_netlock)
{
if (take_netlock) {
switch (so->so_proto->pr_domain->dom_family) {
case PF_INET:
case PF_INET6:
NET_LOCK_SHARED();
}
}
rw_enter_write(&so->so_lock);
}
void
doaccept_sounlock(struct socket *so, int release_netlock)
{
rw_exit_write(&so->so_lock);
if (release_netlock) {
switch (so->so_proto->pr_domain->dom_family) {
case PF_INET:
case PF_INET6:
NET_UNLOCK_SHARED();
}
}
}
int int
doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen, doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
int flags, register_t *retval) int flags, register_t *retval)
@ -307,7 +279,7 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
nam = m_get(M_WAIT, MT_SONAME); nam = m_get(M_WAIT, MT_SONAME);
head = headfp->f_data; head = headfp->f_data;
doaccept_solock(head, 1); solock_shared(head);
if (isdnssocket(head) || (head->so_options & SO_ACCEPTCONN) == 0) { if (isdnssocket(head) || (head->so_options & SO_ACCEPTCONN) == 0) {
error = EINVAL; error = EINVAL;
@ -341,7 +313,7 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
*/ */
so = TAILQ_FIRST(&head->so_q); so = TAILQ_FIRST(&head->so_q);
doaccept_solock(so, 0); solock_nonet(so);
if (soqremque(so, 1) == 0) if (soqremque(so, 1) == 0)
panic("accept"); panic("accept");
@ -353,7 +325,7 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
/* connection has been removed from the listen queue */ /* connection has been removed from the listen queue */
knote(&head->so_rcv.sb_klist, 0); knote(&head->so_rcv.sb_klist, 0);
doaccept_sounlock(head, 0); sounlock_nonet(head);
fp->f_type = DTYPE_SOCKET; fp->f_type = DTYPE_SOCKET;
fp->f_flag = FREAD | FWRITE | nflag; fp->f_flag = FREAD | FWRITE | nflag;
@ -362,7 +334,7 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
error = soaccept(so, nam); error = soaccept(so, nam);
doaccept_sounlock(so, 1); sounlock_shared(so);
if (error) if (error)
goto out; goto out;
@ -385,7 +357,7 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
return 0; return 0;
out_unlock: out_unlock:
doaccept_sounlock(head, 1); sounlock_shared(head);
out: out:
fdplock(fdp); fdplock(fdp);
fdremove(fdp, tmpfd); fdremove(fdp, tmpfd);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if.c,v 1.721 2024/10/17 05:02:12 jsg Exp $ */ /* $OpenBSD: if.c,v 1.722 2025/01/16 17:20:23 mvs Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/* /*
@ -2493,8 +2493,6 @@ ifioctl_get(u_long cmd, caddr_t data)
{ {
struct ifnet *ifp; struct ifnet *ifp;
struct ifreq *ifr = (struct ifreq *)data; struct ifreq *ifr = (struct ifreq *)data;
char ifdescrbuf[IFDESCRSIZE];
char ifrtlabelbuf[RTLABEL_LEN];
int error = 0; int error = 0;
size_t bytesdone; size_t bytesdone;
@ -2525,14 +2523,11 @@ ifioctl_get(u_long cmd, caddr_t data)
} }
KERNEL_LOCK(); KERNEL_LOCK();
ifp = if_unit(ifr->ifr_name); ifp = if_unit(ifr->ifr_name);
if (ifp == NULL) {
KERNEL_UNLOCK(); KERNEL_UNLOCK();
return (ENXIO);
}
NET_LOCK_SHARED(); if (ifp == NULL)
return (ENXIO);
switch(cmd) { switch(cmd) {
case SIOCGIFFLAGS: case SIOCGIFFLAGS:
@ -2559,26 +2554,39 @@ ifioctl_get(u_long cmd, caddr_t data)
case SIOCGIFDATA: { case SIOCGIFDATA: {
struct if_data ifdata; struct if_data ifdata;
NET_LOCK_SHARED();
KERNEL_LOCK();
if_getdata(ifp, &ifdata); if_getdata(ifp, &ifdata);
KERNEL_UNLOCK();
NET_UNLOCK_SHARED();
error = copyout(&ifdata, ifr->ifr_data, sizeof(ifdata)); error = copyout(&ifdata, ifr->ifr_data, sizeof(ifdata));
break; break;
} }
case SIOCGIFDESCR: case SIOCGIFDESCR: {
char ifdescrbuf[IFDESCRSIZE];
KERNEL_LOCK();
strlcpy(ifdescrbuf, ifp->if_description, IFDESCRSIZE); strlcpy(ifdescrbuf, ifp->if_description, IFDESCRSIZE);
KERNEL_UNLOCK();
error = copyoutstr(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE, error = copyoutstr(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE,
&bytesdone); &bytesdone);
break; break;
}
case SIOCGIFRTLABEL: {
char ifrtlabelbuf[RTLABEL_LEN];
u_short rtlabelid = READ_ONCE(ifp->if_rtlabelid);
case SIOCGIFRTLABEL: if (rtlabelid && rtlabel_id2name(rtlabelid,
if (ifp->if_rtlabelid && rtlabel_id2name(ifp->if_rtlabelid,
ifrtlabelbuf, RTLABEL_LEN) != NULL) { ifrtlabelbuf, RTLABEL_LEN) != NULL) {
error = copyoutstr(ifrtlabelbuf, ifr->ifr_data, error = copyoutstr(ifrtlabelbuf, ifr->ifr_data,
RTLABEL_LEN, &bytesdone); RTLABEL_LEN, &bytesdone);
} else } else
error = ENOENT; error = ENOENT;
break; break;
}
case SIOCGIFPRIORITY: case SIOCGIFPRIORITY:
ifr->ifr_metric = ifp->if_priority; ifr->ifr_metric = ifp->if_priority;
break; break;
@ -2588,7 +2596,9 @@ ifioctl_get(u_long cmd, caddr_t data)
break; break;
case SIOCGIFGROUP: case SIOCGIFGROUP:
NET_LOCK_SHARED();
error = if_getgroup(data, ifp); error = if_getgroup(data, ifp);
NET_UNLOCK_SHARED();
break; break;
case SIOCGIFLLPRIO: case SIOCGIFLLPRIO:
@ -2599,10 +2609,6 @@ ifioctl_get(u_long cmd, caddr_t data)
panic("invalid ioctl %lu", cmd); panic("invalid ioctl %lu", cmd);
} }
NET_UNLOCK_SHARED();
KERNEL_UNLOCK();
if_put(ifp); if_put(ifp);
return (error); return (error);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_input.c,v 1.422 2025/01/10 20:19:03 bluhm Exp $ */ /* $OpenBSD: tcp_input.c,v 1.423 2025/01/16 11:59:20 bluhm Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/* /*
@ -109,7 +109,6 @@ int tcp_flush_queue(struct tcpcb *);
#endif /* INET6 */ #endif /* INET6 */
const int tcprexmtthresh = 3; const int tcprexmtthresh = 3;
int tcptv_keep_init = TCPTV_KEEP_INIT;
int tcp_rst_ppslim = 100; /* 100pps */ int tcp_rst_ppslim = 100; /* 100pps */
int tcp_rst_ppslim_count = 0; int tcp_rst_ppslim_count = 0;
@ -870,7 +869,7 @@ findpcb:
*/ */
tp->t_rcvtime = now; tp->t_rcvtime = now;
if (TCPS_HAVEESTABLISHED(tp->t_state)) if (TCPS_HAVEESTABLISHED(tp->t_state))
TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle); TCP_TIMER_ARM(tp, TCPT_KEEP, atomic_load_int(&tcp_keepidle));
if (tp->sack_enable) if (tp->sack_enable)
tcp_del_sackholes(tp, th); /* Delete stale SACK holes */ tcp_del_sackholes(tp, th); /* Delete stale SACK holes */
@ -1187,7 +1186,8 @@ findpcb:
soisconnected(so); soisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT; tp->t_flags &= ~TF_BLOCKOUTPUT;
tp->t_state = TCPS_ESTABLISHED; tp->t_state = TCPS_ESTABLISHED;
TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle); TCP_TIMER_ARM(tp, TCPT_KEEP,
atomic_load_int(&tcp_keepidle));
/* Do window scaling on this connection? */ /* Do window scaling on this connection? */
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) == if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
(TF_RCVD_SCALE|TF_REQ_SCALE)) { (TF_RCVD_SCALE|TF_REQ_SCALE)) {
@ -1473,7 +1473,7 @@ trimthenstep6:
soisconnected(so); soisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT; tp->t_flags &= ~TF_BLOCKOUTPUT;
tp->t_state = TCPS_ESTABLISHED; tp->t_state = TCPS_ESTABLISHED;
TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle); TCP_TIMER_ARM(tp, TCPT_KEEP, atomic_load_int(&tcp_keepidle));
/* Do window scaling? */ /* Do window scaling? */
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) == if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
(TF_RCVD_SCALE|TF_REQ_SCALE)) { (TF_RCVD_SCALE|TF_REQ_SCALE)) {
@ -1809,10 +1809,14 @@ trimthenstep6:
* we'll hang forever. * we'll hang forever.
*/ */
if (so->so_rcv.sb_state & SS_CANTRCVMORE) { if (so->so_rcv.sb_state & SS_CANTRCVMORE) {
int maxidle;
tp->t_flags |= TF_BLOCKOUTPUT; tp->t_flags |= TF_BLOCKOUTPUT;
soisdisconnected(so); soisdisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT; tp->t_flags &= ~TF_BLOCKOUTPUT;
TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_maxidle); maxidle = TCPTV_KEEPCNT *
atomic_load_int(&tcp_keepidle);
TCP_TIMER_ARM(tp, TCPT_2MSL, maxidle);
} }
tp->t_state = TCPS_FIN_WAIT_2; tp->t_state = TCPS_FIN_WAIT_2;
} }
@ -3394,7 +3398,7 @@ syn_cache_timer(void *arg)
* than the keep alive timer would allow, expire it. * than the keep alive timer would allow, expire it.
*/ */
sc->sc_rxttot += sc->sc_rxtcur; sc->sc_rxttot += sc->sc_rxtcur;
if (sc->sc_rxttot >= READ_ONCE(tcptv_keep_init)) if (sc->sc_rxttot >= atomic_load_int(&tcp_keepinit))
goto dropit; goto dropit;
/* Advance the timer back-off. */ /* Advance the timer back-off. */
@ -3673,7 +3677,7 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th,
tp->t_sndtime = now; tp->t_sndtime = now;
tp->t_rcvacktime = now; tp->t_rcvacktime = now;
tp->t_sndacktime = now; tp->t_sndacktime = now;
TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init); TCP_TIMER_ARM(tp, TCPT_KEEP, atomic_load_int(&tcp_keepinit));
tcpstat_inc(tcps_accepts); tcpstat_inc(tcps_accepts);
tcp_mss(tp, sc->sc_peermaxseg); /* sets t_maxseg */ tcp_mss(tp, sc->sc_peermaxseg); /* sets t_maxseg */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_subr.c,v 1.204 2025/01/03 17:23:51 bluhm Exp $ */ /* $OpenBSD: tcp_subr.c,v 1.205 2025/01/16 11:59:20 bluhm Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */ /* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/* /*
@ -184,9 +184,6 @@ tcp_init(void)
/* Initialize the compressed state engine. */ /* Initialize the compressed state engine. */
syn_cache_init(); syn_cache_init();
/* Initialize timer state. */
tcp_timer_init();
} }
/* /*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_timer.c,v 1.81 2025/01/14 13:49:44 bluhm Exp $ */ /* $OpenBSD: tcp_timer.c,v 1.82 2025/01/16 11:59:20 bluhm Exp $ */
/* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */
/* /*
@ -61,16 +61,14 @@
*/ */
int tcp_always_keepalive; int tcp_always_keepalive;
int tcp_keepidle; int tcp_keepinit = TCPTV_KEEPINIT;
int tcp_keepintvl; int tcp_keepidle = TCPTV_KEEPIDLE;
int tcp_maxpersistidle; /* max idle time in persist */ int tcp_keepintvl = TCPTV_KEEPINTVL;
int tcp_maxidle; /* [T] max idle time for keep alive */ int tcp_keepinit_sec = TCPTV_KEEPINIT / TCP_TIME(1);
int tcp_keepidle_sec = TCPTV_KEEPIDLE / TCP_TIME(1);
/* int tcp_keepintvl_sec = TCPTV_KEEPINTVL / TCP_TIME(1);
* Time to delay the ACK. This is initialized in tcp_init(), unless int tcp_maxpersistidle = TCPTV_KEEPIDLE; /* max idle time in persist */
* its patched. int tcp_delack_msecs = TCP_DELACK_MSECS; /* time to delay the ACK */
*/
int tcp_delack_msecs;
void tcp_timer_rexmt(void *); void tcp_timer_rexmt(void *);
void tcp_timer_persist(void *); void tcp_timer_persist(void *);
@ -86,26 +84,6 @@ const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS] = {
tcp_timer_delack, tcp_timer_delack,
}; };
/*
* Timer state initialization, called from tcp_init().
*/
void
tcp_timer_init(void)
{
if (tcp_keepidle == 0)
tcp_keepidle = TCPTV_KEEP_IDLE;
if (tcp_keepintvl == 0)
tcp_keepintvl = TCPTV_KEEPINTVL;
if (tcp_maxpersistidle == 0)
tcp_maxpersistidle = TCPTV_KEEP_IDLE;
if (tcp_delack_msecs == 0)
tcp_delack_msecs = TCP_DELACK_MSECS;
}
static inline int static inline int
tcp_timer_enter(struct inpcb *inp, struct socket **so, struct tcpcb **tp, tcp_timer_enter(struct inpcb *inp, struct socket **so, struct tcpcb **tp,
u_int timer) u_int timer)
@ -176,7 +154,6 @@ void
tcp_slowtimo(void) tcp_slowtimo(void)
{ {
mtx_enter(&tcp_timer_mtx); mtx_enter(&tcp_timer_mtx);
tcp_maxidle = TCPTV_KEEPCNT * tcp_keepintvl;
tcp_iss += TCP_ISSINCR2/PR_SLOWHZ; /* increment iss */ tcp_iss += TCP_ISSINCR2/PR_SLOWHZ; /* increment iss */
mtx_leave(&tcp_timer_mtx); mtx_leave(&tcp_timer_mtx);
} }
@ -488,13 +465,14 @@ tcp_timer_keep(void *arg)
if ((atomic_load_int(&tcp_always_keepalive) || if ((atomic_load_int(&tcp_always_keepalive) ||
so->so_options & SO_KEEPALIVE) && so->so_options & SO_KEEPALIVE) &&
tp->t_state <= TCPS_CLOSING) { tp->t_state <= TCPS_CLOSING) {
int maxidle; int keepidle, maxidle;
uint64_t now; uint64_t now;
maxidle = READ_ONCE(tcp_maxidle); keepidle = atomic_load_int(&tcp_keepidle);
maxidle = TCPTV_KEEPCNT * keepidle;
now = tcp_now(); now = tcp_now();
if ((maxidle > 0) && if ((maxidle > 0) &&
((now - tp->t_rcvtime) >= tcp_keepidle + maxidle)) { ((now - tp->t_rcvtime) >= keepidle + maxidle)) {
tcpstat_inc(tcps_keepdrops); tcpstat_inc(tcps_keepdrops);
tp = tcp_drop(tp, ETIMEDOUT); tp = tcp_drop(tp, ETIMEDOUT);
goto out; goto out;
@ -514,9 +492,9 @@ tcp_timer_keep(void *arg)
tcpstat_inc(tcps_keepprobe); tcpstat_inc(tcps_keepprobe);
tcp_respond(tp, mtod(tp->t_template, caddr_t), tcp_respond(tp, mtod(tp->t_template, caddr_t),
NULL, tp->rcv_nxt, tp->snd_una - 1, 0, 0, now); NULL, tp->rcv_nxt, tp->snd_una - 1, 0, 0, now);
TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepintvl); TCP_TIMER_ARM(tp, TCPT_KEEP, atomic_load_int(&tcp_keepintvl));
} else } else
TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle); TCP_TIMER_ARM(tp, TCPT_KEEP, atomic_load_int(&tcp_keepidle));
if (otp) if (otp)
tcp_trace(TA_TIMER, ostate, tp, otp, NULL, TCPT_KEEP, 0); tcp_trace(TA_TIMER, ostate, tp, otp, NULL, TCPT_KEEP, 0);
out: out:
@ -542,11 +520,11 @@ tcp_timer_2msl(void *arg)
} }
tcp_timer_freesack(tp); tcp_timer_freesack(tp);
maxidle = READ_ONCE(tcp_maxidle); maxidle = TCPTV_KEEPCNT * atomic_load_int(&tcp_keepidle);
now = tcp_now(); now = tcp_now();
if (tp->t_state != TCPS_TIME_WAIT && if (tp->t_state != TCPS_TIME_WAIT &&
((maxidle == 0) || ((now - tp->t_rcvtime) <= maxidle))) ((maxidle == 0) || ((now - tp->t_rcvtime) <= maxidle)))
TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_keepintvl); TCP_TIMER_ARM(tp, TCPT_2MSL, atomic_load_int(&tcp_keepintvl));
else else
tp = tcp_close(tp); tp = tcp_close(tp);
if (otp) if (otp)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_timer.h,v 1.25 2025/01/03 17:23:51 bluhm Exp $ */ /* $OpenBSD: tcp_timer.h,v 1.26 2025/01/16 11:59:20 bluhm Exp $ */
/* $NetBSD: tcp_timer.h,v 1.6 1995/03/26 20:32:37 jtc Exp $ */ /* $NetBSD: tcp_timer.h,v 1.6 1995/03/26 20:32:37 jtc Exp $ */
/* /*
@ -93,8 +93,8 @@
#define TCPTV_PERSMIN TCP_TIME(5) /* retransmit persistence */ #define TCPTV_PERSMIN TCP_TIME(5) /* retransmit persistence */
#define TCPTV_PERSMAX TCP_TIME(60) /* maximum persist interval */ #define TCPTV_PERSMAX TCP_TIME(60) /* maximum persist interval */
#define TCPTV_KEEP_INIT TCP_TIME(75) /* initial connect keep alive */ #define TCPTV_KEEPINIT TCP_TIME(75) /* initial connect keep alive */
#define TCPTV_KEEP_IDLE TCP_TIME(120*60) /* dflt time before probing */ #define TCPTV_KEEPIDLE TCP_TIME(120*60) /* dflt time before probing */
#define TCPTV_KEEPINTVL TCP_TIME(75) /* default probe interval */ #define TCPTV_KEEPINTVL TCP_TIME(75) /* default probe interval */
#define TCPTV_KEEPCNT 8 /* max probes before drop */ #define TCPTV_KEEPCNT 8 /* max probes before drop */
@ -154,16 +154,17 @@ typedef void (*tcp_timer_func_t)(void *);
extern const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS]; extern const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS];
extern int tcp_delack_msecs; /* delayed ACK timeout in millisecs */ extern int tcp_delack_msecs; /* [I] delayed ACK timeout in millisecs */
extern int tcptv_keep_init; extern int tcp_always_keepalive;/* [a] assume SO_KEEPALIVE always set */
extern int tcp_always_keepalive; /* [a] assume SO_KEEPALIVE always set */ extern int tcp_keepinit; /* [a] time to keep alive initial SYN packet */
extern int tcp_keepidle; /* time before keepalive probes begin */ extern int tcp_keepidle; /* [a] time before keepalive probes begin */
extern int tcp_keepintvl; /* time between keepalive probes */ extern int tcp_keepintvl; /* [a] time between keepalive probes */
extern int tcp_maxidle; /* time to drop after starting probes */ extern int tcp_keepinit_sec; /* [a] copy of above in seconds for sysctl */
extern int tcp_keepidle_sec; /* [a] copy of above in seconds for sysctl */
extern int tcp_keepintvl_sec; /* [a] copy of above in seconds for sysctl */
extern int tcp_ttl; /* time to live for TCP segs */ extern int tcp_ttl; /* time to live for TCP segs */
extern const int tcp_backoff[]; extern const int tcp_backoff[];
void tcp_timer_init(void);
void tcp_timer_reaper(void *); void tcp_timer_reaper(void *);
#endif /* _KERNEL */ #endif /* _KERNEL */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_usrreq.c,v 1.239 2025/01/09 16:47:24 bluhm Exp $ */ /* $OpenBSD: tcp_usrreq.c,v 1.240 2025/01/16 11:59:20 bluhm Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/* /*
@ -160,6 +160,12 @@ const struct pr_usrreqs tcp6_usrreqs = {
#endif #endif
const struct sysctl_bounded_args tcpctl_vars[] = { const struct sysctl_bounded_args tcpctl_vars[] = {
{ TCPCTL_KEEPINITTIME, &tcp_keepinit_sec, 1,
3 * TCPTV_KEEPINIT / TCP_TIME(1) },
{ TCPCTL_KEEPIDLE, &tcp_keepidle_sec, 1,
5 * TCPTV_KEEPIDLE / TCP_TIME(1) },
{ TCPCTL_KEEPINTVL, &tcp_keepintvl_sec, 1,
3 * TCPTV_KEEPINTVL / TCP_TIME(1) },
{ TCPCTL_RFC1323, &tcp_do_rfc1323, 0, 1 }, { TCPCTL_RFC1323, &tcp_do_rfc1323, 0, 1 },
{ TCPCTL_SACK, &tcp_do_sack, 0, 1 }, { TCPCTL_SACK, &tcp_do_sack, 0, 1 },
{ TCPCTL_MSSDFLT, &tcp_mssdflt, TCP_MSS, 65535 }, { TCPCTL_MSSDFLT, &tcp_mssdflt, TCP_MSS, 65535 },
@ -682,7 +688,7 @@ tcp_connect(struct socket *so, struct mbuf *nam)
soisconnecting(so); soisconnecting(so);
tcpstat_inc(tcps_connattempt); tcpstat_inc(tcps_connattempt);
tp->t_state = TCPS_SYN_SENT; tp->t_state = TCPS_SYN_SENT;
TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init); TCP_TIMER_ARM(tp, TCPT_KEEP, atomic_load_int(&tcp_keepinit));
tcp_set_iss_tsm(tp); tcp_set_iss_tsm(tp);
tcp_sendseqinit(tp); tcp_sendseqinit(tp);
tp->snd_last = tp->snd_una; tp->snd_last = tp->snd_una;
@ -1107,8 +1113,13 @@ tcp_usrclosed(struct tcpcb *tp)
* a full close, we start a timer to make sure sockets are * a full close, we start a timer to make sure sockets are
* not left in FIN_WAIT_2 forever. * not left in FIN_WAIT_2 forever.
*/ */
if (tp->t_state == TCPS_FIN_WAIT_2) if (tp->t_state == TCPS_FIN_WAIT_2) {
TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_maxidle); int maxidle;
maxidle = TCPTV_KEEPCNT *
atomic_load_int(&tcp_keepidle);
TCP_TIMER_ARM(tp, TCPT_2MSL, maxidle);
}
} }
return (tp); return (tp);
} }
@ -1409,36 +1420,6 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (ENOTDIR); return (ENOTDIR);
switch (name[0]) { switch (name[0]) {
case TCPCTL_KEEPINITTIME:
NET_LOCK();
nval = tcptv_keep_init / TCP_TIME(1);
error = sysctl_int_bounded(oldp, oldlenp, newp, newlen, &nval,
1, 3 * (TCPTV_KEEP_INIT / TCP_TIME(1)));
if (!error)
tcptv_keep_init = TCP_TIME(nval);
NET_UNLOCK();
return (error);
case TCPCTL_KEEPIDLE:
NET_LOCK();
nval = tcp_keepidle / TCP_TIME(1);
error = sysctl_int_bounded(oldp, oldlenp, newp, newlen, &nval,
1, 5 * (TCPTV_KEEP_IDLE / TCP_TIME(1)));
if (!error)
tcp_keepidle = TCP_TIME(nval);
NET_UNLOCK();
return (error);
case TCPCTL_KEEPINTVL:
NET_LOCK();
nval = tcp_keepintvl / TCP_TIME(1);
error = sysctl_int_bounded(oldp, oldlenp, newp, newlen, &nval,
1, 3 * (TCPTV_KEEPINTVL / TCP_TIME(1)));
if (!error)
tcp_keepintvl = TCP_TIME(nval);
NET_UNLOCK();
return (error);
case TCPCTL_BADDYNAMIC: case TCPCTL_BADDYNAMIC:
NET_LOCK(); NET_LOCK();
error = sysctl_struct(oldp, oldlenp, newp, newlen, error = sysctl_struct(oldp, oldlenp, newp, newlen,
@ -1528,8 +1509,23 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (error); return (error);
default: default:
return sysctl_bounded_arr(tcpctl_vars, nitems(tcpctl_vars), error = sysctl_bounded_arr(tcpctl_vars, nitems(tcpctl_vars),
name, namelen, oldp, oldlenp, newp, newlen); name, namelen, oldp, oldlenp, newp, newlen);
switch (name[0]) {
case TCPCTL_KEEPINITTIME:
atomic_store_int(&tcp_keepinit,
atomic_load_int(&tcp_keepinit_sec) * TCP_TIME(1));
break;
case TCPCTL_KEEPIDLE:
atomic_store_int(&tcp_keepidle,
atomic_load_int(&tcp_keepidle_sec) * TCP_TIME(1));
break;
case TCPCTL_KEEPINTVL:
atomic_store_int(&tcp_keepintvl,
atomic_load_int(&tcp_keepintvl_sec) * TCP_TIME(1));
break;
}
return (error);
} }
/* NOTREACHED */ /* NOTREACHED */
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_var.h,v 1.184 2025/01/05 12:18:48 bluhm Exp $ */ /* $OpenBSD: tcp_var.h,v 1.185 2025/01/16 11:59:20 bluhm Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/* /*
@ -679,7 +679,6 @@ extern struct pool tcpcb_pool;
extern struct inpcbtable tcbtable, tcb6table; /* queue of active tcpcb's */ extern struct inpcbtable tcbtable, tcb6table; /* queue of active tcpcb's */
extern int tcp_do_rfc1323; /* [a] enabled/disabled? */ extern int tcp_do_rfc1323; /* [a] enabled/disabled? */
extern const int tcprexmtthresh; extern const int tcprexmtthresh;
extern int tcptv_keep_init; /* [N] time to keep alive initial SYN packet */
extern int tcp_mssdflt; /* [a] default maximum segment size */ extern int tcp_mssdflt; /* [a] default maximum segment size */
extern int tcp_rst_ppslim; /* [a] maximum outgoing RST packet per second */ extern int tcp_rst_ppslim; /* [a] maximum outgoing RST packet per second */
extern int tcp_ack_on_push; /* [a] ACK immediately on PUSH */ extern int tcp_ack_on_push; /* [a] ACK immediately on PUSH */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: socketvar.h,v 1.138 2025/01/03 12:56:15 mvs Exp $ */ /* $OpenBSD: socketvar.h,v 1.139 2025/01/16 16:35:01 bluhm Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */ /* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*- /*-
@ -451,10 +451,12 @@ int sockargs(struct mbuf **, const void *, size_t, int);
int sosleep_nsec(struct socket *, void *, int, const char *, uint64_t); int sosleep_nsec(struct socket *, void *, int, const char *, uint64_t);
void solock(struct socket *); void solock(struct socket *);
void solock_shared(struct socket *); void solock_shared(struct socket *);
void solock_nonet(struct socket *);
int solock_persocket(struct socket *); int solock_persocket(struct socket *);
void solock_pair(struct socket *, struct socket *); void solock_pair(struct socket *, struct socket *);
void sounlock(struct socket *); void sounlock(struct socket *);
void sounlock_shared(struct socket *); void sounlock_shared(struct socket *);
void sounlock_nonet(struct socket *);
int sendit(struct proc *, int, struct msghdr *, int, register_t *); int sendit(struct proc *, int, struct msghdr *, int, register_t *);
int recvit(struct proc *, int, struct msghdr *, caddr_t, register_t *); int recvit(struct proc *, int, struct msghdr *, caddr_t, register_t *);

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.71 2023/11/27 11:30:49 claudio Exp $ */ /* $OpenBSD: main.c,v 1.72 2025/01/16 14:06:49 job Exp $ */
/* /*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* *
@ -29,6 +29,7 @@
#include <util.h> #include <util.h>
#include "extern.h" #include "extern.h"
#include "version.h"
int verbose; int verbose;
int poll_contimeout; int poll_contimeout;
@ -423,8 +424,8 @@ main(int argc, char *argv[])
verbose++; verbose++;
break; break;
case 'V': case 'V':
fprintf(stderr, "openrsync: protocol version %u\n", fprintf(stderr, "openrsync %s (protocol version %u)\n",
RSYNC_PROTOCOL); RSYNC_VERSION, RSYNC_PROTOCOL);
exit(0); exit(0);
case 'x': case 'x':
opts.one_file_system++; opts.one_file_system++;

3
usr.bin/rsync/version.h Normal file
View file

@ -0,0 +1,3 @@
/* $OpenBSD: version.h,v 1.1 2025/01/16 14:06:49 job Exp $ */
#define RSYNC_VERSION "0.1"

View file

@ -1,4 +1,4 @@
/* $OpenBSD: servconf.c,v 1.420 2024/10/14 01:57:50 djm Exp $ */ /* $OpenBSD: servconf.c,v 1.421 2025/01/15 22:23:13 dtucker Exp $ */
/* /*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved * All rights reserved
@ -2728,23 +2728,25 @@ parse_server_match_config(ServerOptions *options,
copy_set_server_options(options, &mo, 0); copy_set_server_options(options, &mo, 0);
} }
int parse_server_match_testspec(struct connection_info *ci, char *spec) int
parse_server_match_testspec(struct connection_info *ci, char *spec)
{ {
char *p; char *p;
const char *val;
while ((p = strsep(&spec, ",")) && *p != '\0') { while ((p = strsep(&spec, ",")) && *p != '\0') {
if (strncmp(p, "addr=", 5) == 0) { if ((val = strprefix(p, "addr=", 0)) != NULL) {
ci->address = xstrdup(p + 5); ci->address = xstrdup(val);
} else if (strncmp(p, "host=", 5) == 0) { } else if ((val = strprefix(p, "host=", 0)) != NULL) {
ci->host = xstrdup(p + 5); ci->host = xstrdup(val);
} else if (strncmp(p, "user=", 5) == 0) { } else if ((val = strprefix(p, "user=", 0)) != NULL) {
ci->user = xstrdup(p + 5); ci->user = xstrdup(val);
} else if (strncmp(p, "laddr=", 6) == 0) { } else if ((val = strprefix(p, "laddr=", 0)) != NULL) {
ci->laddress = xstrdup(p + 6); ci->laddress = xstrdup(val);
} else if (strncmp(p, "rdomain=", 8) == 0) { } else if ((val = strprefix(p, "rdomain=", 0)) != NULL) {
ci->rdomain = xstrdup(p + 8); ci->rdomain = xstrdup(val);
} else if (strncmp(p, "lport=", 6) == 0) { } else if ((val = strprefix(p, "lport=", 0)) != NULL) {
ci->lport = a2port(p + 6); ci->lport = a2port(val);
if (ci->lport == -1) { if (ci->lport == -1) {
fprintf(stderr, "Invalid port '%s' in test mode" fprintf(stderr, "Invalid port '%s' in test mode"
" specification %s\n", p+6, p); " specification %s\n", p+6, p);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshd-auth.c,v 1.2 2024/12/03 22:30:03 jsg Exp $ */ /* $OpenBSD: sshd-auth.c,v 1.3 2025/01/16 06:37:10 dtucker Exp $ */
/* /*
* SSH2 implementation: * SSH2 implementation:
* Privilege Separation: * Privilege Separation:
@ -602,8 +602,6 @@ main(int ac, char **av)
exit(1); exit(1);
} }
debug("sshd version %s, %s", SSH_VERSION, SSH_OPENSSL_VERSION);
/* Connection passed by stdin/out */ /* Connection passed by stdin/out */
if (inetd_flag) { if (inetd_flag) {
/* /*
@ -641,6 +639,11 @@ main(int ac, char **av)
fill_default_server_options(&options); fill_default_server_options(&options);
options.timing_secret = timing_secret; /* XXX eliminate from unpriv */ options.timing_secret = timing_secret; /* XXX eliminate from unpriv */
/* Reinit logging in case config set Level, Facility or Verbose. */
log_init(__progname, options.log_level, options.log_facility, 1);
debug("sshd-auth version %s, %s", SSH_VERSION, SSH_OPENSSL_VERSION);
#ifdef WITH_OPENSSL #ifdef WITH_OPENSSL
if (options.moduli_file != NULL) if (options.moduli_file != NULL)
dh_set_moduli_file(options.moduli_file); dh_set_moduli_file(options.moduli_file);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshd-session.c,v 1.10 2024/10/14 01:57:50 djm Exp $ */ /* $OpenBSD: sshd-session.c,v 1.11 2025/01/16 06:37:10 dtucker Exp $ */
/* /*
* SSH2 implementation: * SSH2 implementation:
* Privilege Separation: * Privilege Separation:
@ -892,8 +892,6 @@ main(int ac, char **av)
exit(1); exit(1);
} }
debug("sshd version %s, %s", SSH_VERSION, SSH_OPENSSL_VERSION);
if (!rexeced_flag) if (!rexeced_flag)
fatal("sshd-session should not be executed directly"); fatal("sshd-session should not be executed directly");
@ -935,8 +933,6 @@ main(int ac, char **av)
SYSLOG_FACILITY_AUTH : options.log_facility, SYSLOG_FACILITY_AUTH : options.log_facility,
log_stderr || !inetd_flag || debug_flag); log_stderr || !inetd_flag || debug_flag);
debug("sshd version %s, %s", SSH_VERSION, SSH_OPENSSL_VERSION);
/* Fetch our configuration */ /* Fetch our configuration */
if ((cfg = sshbuf_new()) == NULL) if ((cfg = sshbuf_new()) == NULL)
fatal("sshbuf_new config buf failed"); fatal("sshbuf_new config buf failed");
@ -950,6 +946,12 @@ main(int ac, char **av)
fill_default_server_options(&options); fill_default_server_options(&options);
options.timing_secret = timing_secret; options.timing_secret = timing_secret;
/* Reinit logging in case config set Level, Facility or Verbose. */
log_init(__progname, options.log_level, options.log_facility,
log_stderr || !inetd_flag || debug_flag);
debug("sshd-session version %s, %s", SSH_VERSION, SSH_OPENSSL_VERSION);
if (!debug_flag && !inetd_flag) { if (!debug_flag && !inetd_flag) {
if ((startup_pipe = dup(REEXEC_STARTUP_PIPE_FD)) == -1) if ((startup_pipe = dup(REEXEC_STARTUP_PIPE_FD)) == -1)
fatal("internal error: no startup pipe"); fatal("internal error: no startup pipe");

View file

@ -1,4 +1,4 @@
/* $OpenBSD: connection.c,v 1.21 2015/12/05 06:38:18 mmcc Exp $ */ /* $OpenBSD: connection.c,v 1.22 2025/01/16 16:19:39 claudio Exp $ */
/* /*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@ -324,28 +324,26 @@ conn_gen_kvp(struct connection *c, struct kvp *kvp, size_t *nkvp)
if (s->mine.MaxConnections != iscsi_sess_defaults.MaxConnections) { if (s->mine.MaxConnections != iscsi_sess_defaults.MaxConnections) {
if (kvp && i < *nkvp) { if (kvp && i < *nkvp) {
kvp[i].key = strdup("MaxConnections"); kvp[i].key = "MaxConnections";
if (kvp[i].key == NULL)
return -1;
if (asprintf(&kvp[i].value, "%hu", if (asprintf(&kvp[i].value, "%hu",
s->mine.MaxConnections) == -1) { s->mine.MaxConnections) == -1) {
kvp[i].value = NULL; kvp[i].value = NULL;
return -1; return -1;
} }
kvp[i].flags |= KVP_VALUE_ALLOCED;
} }
i++; i++;
} }
if (c->mine.MaxRecvDataSegmentLength != if (c->mine.MaxRecvDataSegmentLength !=
iscsi_conn_defaults.MaxRecvDataSegmentLength) { iscsi_conn_defaults.MaxRecvDataSegmentLength) {
if (kvp && i < *nkvp) { if (kvp && i < *nkvp) {
kvp[i].key = strdup("MaxRecvDataSegmentLength"); kvp[i].key = "MaxRecvDataSegmentLength";
if (kvp[i].key == NULL)
return -1;
if (asprintf(&kvp[i].value, "%u", if (asprintf(&kvp[i].value, "%u",
c->mine.MaxRecvDataSegmentLength) == -1) { c->mine.MaxRecvDataSegmentLength) == -1) {
kvp[i].value = NULL; kvp[i].value = NULL;
return -1; return -1;
} }
kvp[i].flags |= KVP_VALUE_ALLOCED;
} }
i++; i++;
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: initiator.c,v 1.15 2015/01/16 15:57:06 deraadt Exp $ */ /* $OpenBSD: initiator.c,v 1.16 2025/01/16 16:19:39 claudio Exp $ */
/* /*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@ -280,7 +280,7 @@ initiator_login_kvp(struct connection *c, u_int8_t stage)
if (!(kvp = calloc(nkvp, sizeof(*kvp)))) if (!(kvp = calloc(nkvp, sizeof(*kvp))))
return NULL; return NULL;
if (conn_gen_kvp(c, kvp, &nkvp) == -1) { if (conn_gen_kvp(c, kvp, &nkvp) == -1) {
free(kvp); kvp_free(kvp);
return NULL; return NULL;
} }
break; break;
@ -327,10 +327,10 @@ initiator_login_build(struct connection *c, struct task_login *tl)
return NULL; return NULL;
} }
if ((n = text_to_pdu(kvp, p)) == -1) { if ((n = text_to_pdu(kvp, p)) == -1) {
free(kvp); kvp_free(kvp);
return NULL; return NULL;
} }
free(kvp); kvp_free(kvp);
if (n > 8192) { if (n > 8192) {
log_warn("initiator_login_build: help, I'm too verbose"); log_warn("initiator_login_build: help, I'm too verbose");
@ -409,11 +409,11 @@ initiator_login_cb(struct connection *c, void *arg, struct pdu *p)
} }
if (conn_parse_kvp(c, kvp) == -1) { if (conn_parse_kvp(c, kvp) == -1) {
free(kvp); kvp_free(kvp);
conn_fail(c); conn_fail(c);
goto done; goto done;
} }
free(kvp); kvp_free(kvp);
} }
/* advance FSM if possible */ /* advance FSM if possible */
@ -480,7 +480,7 @@ initiator_discovery_cb(struct connection *c, void *arg, struct pdu *p)
for (k = kvp; k->key; k++) { for (k = kvp; k->key; k++) {
log_debug("%s\t=>\t%s", k->key, k->value); log_debug("%s\t=>\t%s", k->key, k->value);
} }
free(kvp); kvp_free(kvp);
session_shutdown(c->session); session_shutdown(c->session);
break; break;
default: default:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: iscsid.h,v 1.19 2024/05/21 05:00:48 jsg Exp $ */ /* $OpenBSD: iscsid.h,v 1.20 2025/01/16 16:19:39 claudio Exp $ */
/* /*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@ -385,6 +385,7 @@ void *pdu_getbuf(struct pdu *, size_t *, unsigned int);
void pdu_free(struct pdu *); void pdu_free(struct pdu *);
int socket_setblockmode(int, int); int socket_setblockmode(int, int);
const char *log_sockaddr(void *); const char *log_sockaddr(void *);
void kvp_free(struct kvp *);
void task_init(struct task *, struct session *, int, void *, void task_init(struct task *, struct session *, int, void *,
void (*)(struct connection *, void *, struct pdu *), void (*)(struct connection *, void *, struct pdu *),

View file

@ -1,4 +1,4 @@
/* $OpenBSD: session.c,v 1.9 2023/03/08 04:43:13 guenther Exp $ */ /* $OpenBSD: session.c,v 1.10 2025/01/16 16:17:32 claudio Exp $ */
/* /*
* Copyright (c) 2011 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2011 Claudio Jeker <claudio@openbsd.org>
@ -430,7 +430,6 @@ sess_do_reinstatement(struct session *s, struct sessev *sev)
if (c->state & CONN_FAILED) { if (c->state & CONN_FAILED) {
conn_fsm(c, CONN_EV_FREE); conn_fsm(c, CONN_EV_FREE);
TAILQ_REMOVE(&s->connections, c, entry);
conn_free(c); conn_free(c);
} }
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.9 2021/04/12 10:03:33 claudio Exp $ */ /* $OpenBSD: util.c,v 1.10 2025/01/16 16:19:39 claudio Exp $ */
/* /*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@ -189,3 +189,19 @@ fail:
pdu_free(pdu); pdu_free(pdu);
return -1; return -1;
} }
void
kvp_free(struct kvp *kvp)
{
struct kvp *k;
if (kvp == NULL)
return;
for (k = kvp; k->key; k++) {
if (k->flags & KVP_KEY_ALLOCED)
free(k->key);
if (k->flags & KVP_VALUE_ALLOCED)
free(k->value);
}
free(kvp);
}