sync with OpenBSD -current

This commit is contained in:
purplerain 2024-08-18 01:23:47 +00:00
parent b5dda3c267
commit c78abe7784
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
59 changed files with 509 additions and 656 deletions

View file

@ -2227,7 +2227,6 @@
./usr/share/man/man3/X509_STORE_new.3 ./usr/share/man/man3/X509_STORE_new.3
./usr/share/man/man3/X509_STORE_set1_param.3 ./usr/share/man/man3/X509_STORE_set1_param.3
./usr/share/man/man3/X509_STORE_set_verify_cb_func.3 ./usr/share/man/man3/X509_STORE_set_verify_cb_func.3
./usr/share/man/man3/X509_TRUST_set.3
./usr/share/man/man3/X509_VERIFY_PARAM_new.3 ./usr/share/man/man3/X509_VERIFY_PARAM_new.3
./usr/share/man/man3/X509_VERIFY_PARAM_set_flags.3 ./usr/share/man/man3/X509_VERIFY_PARAM_set_flags.3
./usr/share/man/man3/X509_add1_trust_object.3 ./usr/share/man/man3/X509_add1_trust_object.3

View file

@ -1,5 +1,5 @@
/* infomap.h -- description of a keymap in Info and related functions. /* infomap.h -- description of a keymap in Info and related functions.
$Id: infomap.h,v 1.1.1.4 2006/07/17 16:03:43 espie Exp $ $Id: infomap.h,v 1.2 2024/08/16 23:09:25 guenther Exp $
Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc. Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc.
@ -40,7 +40,7 @@
#define Meta_p(c) (((c) > meta_character_threshold)) #define Meta_p(c) (((c) > meta_character_threshold))
#define Control_p(c) ((c) < control_character_threshold) #define Control_p(c) ((c) < control_character_threshold)
#define Meta(c) ((c) | (meta_character_bit)) #define Meta(c) ((unsigned char)((c) | (meta_character_bit)))
#define UnMeta(c) ((c) & (~meta_character_bit)) #define UnMeta(c) ((c) & (~meta_character_bit))
#define Control(c) ((toupper (c)) & (~control_character_bit)) #define Control(c) ((toupper (c)) & (~control_character_bit))
#define UnControl(c) (tolower ((c) | control_character_bit)) #define UnControl(c) (tolower ((c) | control_character_bit))

View file

@ -1,5 +1,5 @@
/* system.h: system-dependent declarations; include this first. /* system.h: system-dependent declarations; include this first.
$Id: system.h,v 1.5 2006/07/17 16:12:36 espie Exp $ $Id: system.h,v 1.6 2024/08/16 22:57:03 guenther Exp $
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc. Foundation, Inc.
@ -60,6 +60,7 @@ extern char *substring (const char *, const char *);
#ifdef STDC_HEADERS #ifdef STDC_HEADERS
#define getopt system_getopt #define getopt system_getopt
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#undef getopt #undef getopt
#else #else
extern char *getenv (); extern char *getenv ();
@ -117,14 +118,6 @@ extern char *strerror ();
#define PATH_MAX _POSIX_PATH_MAX #define PATH_MAX _POSIX_PATH_MAX
#endif #endif
#ifndef HAVE_DECL_STRCASECMP
extern int strcasecmp ();
#endif
#ifndef HAVE_DECL_STRNCASECMP
extern int strncasecmp ();
#endif
#ifndef HAVE_DECL_STRCOLL #ifndef HAVE_DECL_STRCOLL
extern int strcoll (); extern int strcoll ();
#endif #endif

View file

@ -1,5 +1,5 @@
/* files.c -- file-related functions for makeinfo. /* files.c -- file-related functions for makeinfo.
$Id: files.c,v 1.1.1.3 2006/07/17 16:03:46 espie Exp $ $Id: files.c,v 1.2 2024/08/16 22:53:32 guenther Exp $
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc. Foundation, Inc.
@ -456,8 +456,8 @@ full_pathname (char *filename)
temp_home = (char *) getenv ("HOME"); temp_home = (char *) getenv ("HOME");
result = xmalloc (strlen (&filename[1]) result = xmalloc (strlen (&filename[1])
+ 1 + 1
+ temp_home ? strlen (temp_home) + (temp_home ? strlen (temp_home)
: 0); : 0));
*result = 0; *result = 0;
if (temp_home) if (temp_home)

View file

@ -1,5 +1,5 @@
/* xml.c -- xml output. /* xml.c -- xml output.
$Id: xml.c,v 1.3 2019/05/27 07:13:38 otto Exp $ $Id: xml.c,v 1.4 2024/08/16 22:57:44 guenther Exp $
Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
@ -871,7 +871,7 @@ xml_insert_element_with_attribute (elt, arg, format, va_alist)
return; return;
} }
if (!xml_element_list[elt].name || !strlen (xml_element_list[elt].name)) if (!strlen (xml_element_list[elt].name))
{ {
/*printf ("Warning: Inserting empty element %d\n", elt);*/ /*printf ("Warning: Inserting empty element %d\n", elt);*/
return; return;

View file

@ -1,5 +1,5 @@
/* texindex -- sort TeX index dribble output into an actual index. /* texindex -- sort TeX index dribble output into an actual index.
$Id: texindex.c,v 1.6 2015/11/14 23:06:06 deraadt Exp $ $Id: texindex.c,v 1.7 2024/08/16 22:58:54 guenther Exp $
Copyright (C) 1987, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001, Copyright (C) 1987, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004 Free Software Foundation, Inc. 2002, 2003, 2004 Free Software Foundation, Inc.
@ -143,7 +143,6 @@ int merge_direct (char **infiles, int nfiles, char *outfile);
void pfatal_with_name (const char *name); void pfatal_with_name (const char *name);
void fatal (const char *format, const char *arg); void fatal (const char *format, const char *arg);
void error (const char *format, const char *arg); void error (const char *format, const char *arg);
void *xmalloc (), *xrealloc ();
char *concat (char *s1, char *s2); char *concat (char *s1, char *s2);
void flush_tempfiles (int to_count); void flush_tempfiles (int to_count);
@ -565,7 +564,7 @@ find_field (struct keyfield *keyfield, char *str, long int *lengthptr)
{ {
char *start; char *start;
char *end; char *end;
char *(*fun) (); char *(*fun) (char *, int, int, int);
if (keyfield->braced) if (keyfield->braced)
fun = find_braced_pos; fun = find_braced_pos;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: md_init.h,v 1.18 2023/11/18 16:26:16 deraadt Exp $ */ /* $OpenBSD: md_init.h,v 1.19 2024/08/17 09:48:31 phessler Exp $ */
/*- /*-
* Copyright (c) 2001 Ross Harvey * Copyright (c) 2001 Ross Harvey
@ -87,7 +87,6 @@
* of COPY relocations for WEAK symbols. * of COPY relocations for WEAK symbols.
*/ */
#define MD_CRT0_START \ #define MD_CRT0_START \
char **environ, *__progname; \
__asm( \ __asm( \
".text \n" \ ".text \n" \
" .align 0 \n" \ " .align 0 \n" \

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.288 2024/07/10 08:51:28 tb Exp $ # $OpenBSD: Makefile,v 1.289 2024/08/17 09:16:37 tb Exp $
.include <bsd.own.mk> .include <bsd.own.mk>
@ -349,7 +349,6 @@ MAN= \
X509_STORE_new.3 \ X509_STORE_new.3 \
X509_STORE_set1_param.3 \ X509_STORE_set1_param.3 \
X509_STORE_set_verify_cb_func.3 \ X509_STORE_set_verify_cb_func.3 \
X509_TRUST_set.3 \
X509_VERIFY_PARAM_new.3 \ X509_VERIFY_PARAM_new.3 \
X509_VERIFY_PARAM_set_flags.3 \ X509_VERIFY_PARAM_set_flags.3 \
X509_add1_trust_object.3 \ X509_add1_trust_object.3 \

View file

@ -1,286 +0,0 @@
.\" $OpenBSD: X509_TRUST_set.3,v 1.1 2021/07/24 14:33:14 schwarze Exp $
.\"
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: July 24 2021 $
.Dt X509_TRUST_SET 3
.Os
.Sh NAME
.Nm X509_TRUST_set ,
.Nm X509_TRUST_get_by_id ,
.Nm X509_TRUST_add ,
.Nm X509_TRUST_get_count ,
.Nm X509_TRUST_cleanup ,
.Nm X509_TRUST_get0 ,
.Nm X509_TRUST_get_trust ,
.Nm X509_TRUST_get0_name ,
.Nm X509_TRUST_get_flags
.Nd trust objects, indices, and identifiers
.Sh SYNOPSIS
.In openssl/x509.h
.Ft int
.Fo X509_TRUST_set
.Fa "int *id_out"
.Fa "int id_in"
.Fc
.Ft int
.Fn X509_TRUST_get_by_id "int identifier"
.Ft int
.Fo X509_TRUST_add
.Fa "int identifier"
.Fa "int flags"
.Fa "int (*check_trust)(X509_TRUST *, X509 *, int)"
.Fa "const char *name"
.Fa "int arg1"
.Fa "void *arg2"
.Fc
.Ft int
.Fn X509_TRUST_get_count void
.Ft void
.Fn X509_TRUST_cleanup void
.Ft X509_TRUST *
.Fn X509_TRUST_get0 "int index"
.Ft int
.Fn X509_TRUST_get_trust "const X509_TRUST *object"
.Ft char *
.Fn X509_TRUST_get0_name "const X509_TRUST *object"
.Ft int
.Fn X509_TRUST_get_flags "const X509_TRUST *object"
.Sh DESCRIPTION
The purposes that an X.509 certificate is trusted for
can be identified in three equivalent ways:
.Bl -enum
.It
By trust identifiers, which are positive integer constants.
Standard trust identifiers lie in the range from
.Dv X509_TRUST_MIN
to
.Dv X509_TRUST_MAX ,
inclusive.
User defined trust identifiers are larger than
.Dv X509_TRUST_MAX .
.It
By trust indices, which are non-negative integer constants but
differ from the trust identifiers expressing the same kind of trust.
Standard trust indices are smaller than
.Dv X509_TRUST_MAX .
User defined trust indices are larger than or equal to
.Dv X509_TRUST_MAX .
.It
By trust objects of the type
.Vt X509_TRUST .
Standard trust objects are available in static storage.
User defined trust objects can be created with
.Fn X509_TRUST_add .
.El
.Pp
Application programmers cannot choose the way to identify kinds of trust
that they like best; depending on the circumstances, all three ways
are needed.
Be warned that the naming of most functions is misleading.
.Pp
Most API functions documented outside the present manual page
use trust identifiers rather than trust indices.
.Pp
ASN.1 object identifiers and NIDs provide a fourth and a fifth way
to identify purposes that a certificate is trusted for.
These are almost, but not exactly, equivalent
to the three ways listed above; see the
.Xr X509_check_trust 3
manual for details.
.Ss Using trust identifiers
.Fn X509_TRUST_set
validates the trust identifier
.Fa id_in .
If it is valid, it is copied to
.Pf * Fa id_out .
Otherwise,
.Pf * Fa id_out
remains unchanged.
.Pp
.Fn X509_TRUST_get_by_id
converts the trust
.Fa identifier
to the corresponding trust
.Fa index .
To find the corresponding trust object, pass the result to
.Fn X509_TRUST_get0 .
.Pp
.Fn X509_TRUST_add
defines a purpose certificates can be trusted for with the given
.Fa identifier
or modifies its properties if it already exists.
The trust
.Fa identifier ,
the
.Fa flags ,
the
.Fa check_trust
function, the
.Fa name ,
the number
.Fa arg1 ,
and the pointer
.Fa arg2
are copied into the
.Vt X509_TRUST
object.
When modifying an existing trust object, previous
values of fields are overwritten and a previous
.Fa name
string is freed if it was dynamically allocated.
When creating a new trust object,
it is added to the global array of user-defined trust objects.
.Pp
.Dv X509_TRUST_DYNAMIC
and
.Dv X509_TRUST_DYNAMIC_NAME
are always ignored in the
.Fa flags
argument.
.Dv X509_TRUST_DYNAMIC
is automatically set if the object was created by the user.
It is never set for standard objects,
not even if they were modified by the user.
.Dv X509_trust_DYNAMIC_NAME
is automatically set if the object was created or modified by the user.
It is only unset for unmodified standard objects.
The library does not appear to define any other flags,
so the flags argument is probably useless
unless users define their own flags and use them in the
.Fa check_trust
function.
.Pp
The third and final argument of the
.Fa check_trust
function is the
.Fa flags
argument of
.Fn X509_check_trust .
.Pp
The built-in trust checking functions documented in the
.Xr X509_check_trust 3
manual page use
.Fa arg1
as the corresponding ASN.1 object NID and ignore
.Fa arg2
and
.Fa flags ,
but a user-supplied
.Fa check_trust
function can use these fields in any arbitrary way.
.Pp
.Fn X509_TRUST_get_count
returns the total number of trust objects currently existing,
including both standard and user-defined objects.
If no user-defined objects exist, the returned value is
.Dv X509_TRUST_MAX .
.Pp
.Fn X509_TRUST_cleanup
deletes all user-defined trust objects
and invalidates their trust identifiers and trust indices.
If any of the standard trust objects were modified by the user,
those changes are
.Em not
reverted.
.Ss Using trust indices
.Fn X509_TRUST_get0
converts the trust
.Fa index
to a pointer to the corresponding trust object.
To find the corresponding trust identifier, pass the result to
.Fn X509_TRUST_get_trust .
.Ss Using trust objects
.Fn X509_TRUST_get_trust
converts a pointer to a trust
.Fa object
to the corresponding trust identifier.
To find the corresponding trust index, pass the result to
.Fn X509_TRUST_get_by_id .
.Pp
.Fn X509_TRUST_get0_name
and
.Fn X509_TRUST_get_flags
retrieve the name and flags from the
.Fa object ,
respectively.
.Sh RETURN VALUES
.Fn X509_TRUST_set
returns 1 if
.Fa id_in
is valid or 0 otherwise.
.Pp
.Fn X509_TRUST_get_by_id
returns the corresponding trust index or -1 if the
.Fa identifier
is invalid.
.Pp
.Fn X509_TRUST_add
returns 1 for success or 0 for failure.
.Pp
.Fn X509_TRUST_get_count
returns the total number of trust objects currently existing.
.Pp
.Fn X509_TRUST_get0
returns a standard or user-defined trust object or
.Dv NULL
if the
.Fa index
is invalid.
.Pp
.Fn X509_TRUST_get_trust
always returns a valid trust identifier.
.Pp
.Fn X509_TRUST_get0_name
returns a pointer to storage owned by the
.Fa object .
.Pp
.Fn X509_TRUST_get_flags
returns the flags associated with the
.Fa object .
.Sh ERRORS
The following diagnostics can be retrieved with
.Xr ERR_get_error 3 ,
.Xr ERR_GET_REASON 3 ,
and
.Xr ERR_reason_error_string 3 :
.Bl -tag -width Ds
.It Dv X509_R_INVALID_TRUST Qq "invalid trust"
.Fn X509_TRUST_set
was called with an invalid
.Fa id_in
argument.
.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
.Fn X509_TRUST_add
failed to allocate memory.
.El
.Pp
The other functions provide no diagnostics.
.Sh SEE ALSO
.Xr X509_check_trust 3 ,
.Xr X509_new 3 ,
.Xr X509_PURPOSE_set 3 ,
.Xr X509_VERIFY_PARAM_set_trust 3
.Sh HISTORY
.Fn X509_TRUST_set
first appeared in OpenSSL 0.9.7 and has been available since
.Ox 3.2 .
.Pp
The other functions first appeared in OpenSSL 0.9.5
and have been available since
.Ox 2.7 .
.Sh CAVEATS
The difference between trust identifiers and trust indices
provides an ideal breeding ground for off-by-one bugs.

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: X509_check_trust.3,v 1.8 2023/04/30 14:49:47 tb Exp $ .\" $OpenBSD: X509_check_trust.3,v 1.10 2024/08/17 09:19:04 tb Exp $
.\" .\"
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> .\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
.\" .\"
@ -14,12 +14,11 @@
.\" 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 30 2023 $ .Dd $Mdocdate: August 17 2024 $
.Dt X509_CHECK_TRUST 3 .Dt X509_CHECK_TRUST 3
.Os .Os
.Sh NAME .Sh NAME
.Nm X509_check_trust , .Nm X509_check_trust
.Nm X509_TRUST_set_default
.Nd check whether a certificate is trusted .Nd check whether a certificate is trusted
.Sh SYNOPSIS .Sh SYNOPSIS
.In openssl/x509.h .In openssl/x509.h
@ -29,12 +28,6 @@
.Fa "int trust" .Fa "int trust"
.Fa "int flags" .Fa "int flags"
.Fc .Fc
.Ft int
.Fo "(*X509_TRUST_set_default(int (*handler)(int, X509 *, int)))"
.Fa "int trust"
.Fa "X509 *certificate"
.Fa "int flags"
.Fc
.Sh DESCRIPTION .Sh DESCRIPTION
.Fn X509_check_trust .Fn X509_check_trust
checks whether the checks whether the
@ -183,27 +176,6 @@ identifiers listed above, or it may have installed additional,
user-supplied checking functions for user-defined user-supplied checking functions for user-defined
.Fa trust .Fa trust
identifiers not listed above. identifiers not listed above.
.Pp
If the function
.Fn X509_TRUST_set_default
was called, the
.Fa handler
function passed to it is used instead of the standard algorithm,
but only in the case where the
.Fa trust
argument of
.Fn X509_check_trust
is invalid.
The compatibility step is not used in this case.
.Pp
If the return value of the first call to
.Fn X509_TRUST_set_default
is saved and passed back to
.Fn X509_TRUST_set_default
later on, the standard behaviour
of using the standard algorithm for invalid
.Fa trust
arguments is restored.
.Sh RETURN VALUES .Sh RETURN VALUES
.Fn X509_check_trust .Fn X509_check_trust
returns the following values: returns the following values:
@ -222,27 +194,14 @@ The
is neither trusted nor explicitly rejected, is neither trusted nor explicitly rejected,
which implies that it is not trusted. which implies that it is not trusted.
.El .El
.Pp
.Fn X509_TRUST_set_default
returns a pointer to the handler function for invalid
.Fa trust
that was installed before the call, which may either be a pointer
to a function installed by a previous call to
.Fn X509_TRUST_set_default
or a pointer to the built-in function implementing the standard algorithm if
.Fn X509_TRUST_set_default
was never called before.
.Sh SEE ALSO .Sh SEE ALSO
.Xr PEM_read_X509_AUX 3 , .Xr PEM_read_X509_AUX 3 ,
.Xr X509_add1_trust_object 3 , .Xr X509_add1_trust_object 3 ,
.Xr X509_CERT_AUX_new 3 , .Xr X509_CERT_AUX_new 3 ,
.Xr X509_check_purpose 3 , .Xr X509_check_purpose 3 ,
.Xr X509_new 3 , .Xr X509_new 3 ,
.Xr X509_TRUST_set 3 ,
.Xr X509_VERIFY_PARAM_set_trust 3 .Xr X509_VERIFY_PARAM_set_trust 3
.Sh HISTORY .Sh HISTORY
.Fn X509_check_trust .Fn X509_check_trust
and
.Fn X509_TRUST_set_default
first appeared in OpenSSL 0.9.5 and has been available since first appeared in OpenSSL 0.9.5 and has been available since
.Ox 2.7 . .Ox 2.7 .

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: X509_new.3,v 1.43 2023/09/29 08:57:49 tb Exp $ .\" $OpenBSD: X509_new.3,v 1.44 2024/08/17 09:16:37 tb Exp $
.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
.\" .\"
.\" This file is a derived work. .\" This file is a derived work.
@ -66,7 +66,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: September 29 2023 $ .Dd $Mdocdate: August 17 2024 $
.Dt X509_NEW 3 .Dt X509_NEW 3
.Os .Os
.Sh NAME .Sh NAME
@ -241,7 +241,6 @@ if an error occurs.
.Xr X509_STORE_CTX_new 3 , .Xr X509_STORE_CTX_new 3 ,
.Xr X509_STORE_get_by_subject 3 , .Xr X509_STORE_get_by_subject 3 ,
.Xr X509_STORE_new 3 , .Xr X509_STORE_new 3 ,
.Xr X509_TRUST_set 3 ,
.Xr X509v3_addr_add_inherit 3 , .Xr X509v3_addr_add_inherit 3 ,
.Xr X509v3_addr_get_range 3 , .Xr X509v3_addr_get_range 3 ,
.Xr X509v3_addr_inherits 3 , .Xr X509v3_addr_inherits 3 ,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: radius.c,v 1.9 2024/08/08 03:58:53 yasuoka Exp $ */ /* $OpenBSD: radius.c,v 1.10 2024/08/17 03:28:22 yasuoka Exp $ */
/* /*
* Copyright (c) 2024 Internet Initiative Japan Inc. * Copyright (c) 2024 Internet Initiative Japan Inc.
@ -198,11 +198,8 @@ iked_radius_on_event(int fd, short ev, void *ctx)
log_info("%s: received an invalid RADIUS message: " log_info("%s: received an invalid RADIUS message: "
"code %u", __func__, (unsigned)code); "code %u", __func__, (unsigned)code);
} }
timer_del(env, &req->rr_timer);
TAILQ_REMOVE(&server->rs_reqs, req, rr_entry);
req->rr_server = NULL;
free(req);
radius_delete_packet(pkt); radius_delete_packet(pkt);
iked_radius_request_free(env, req);
return; return;
} }
@ -229,8 +226,12 @@ iked_radius_on_event(int fd, short ev, void *ctx)
"state attribute", __func__); "state attribute", __func__);
goto fail; goto fail;
} }
if ((req->rr_state != NULL && if (req->rr_state != NULL &&
ibuf_set(req->rr_state, 0, attrval, attrlen) != 0) || ibuf_set(req->rr_state, 0, attrval, attrlen) != 0) {
ibuf_free(req->rr_state);
req->rr_state = NULL;
}
if (req->rr_state == NULL &&
(req->rr_state = ibuf_new(attrval, attrlen)) == NULL) { (req->rr_state = ibuf_new(attrval, attrlen)) == NULL) {
log_info("%s: ibuf_new() failed: %s", __func__, log_info("%s: ibuf_new() failed: %s", __func__,
strerror(errno)); strerror(errno));
@ -321,6 +322,7 @@ iked_radius_on_event(int fd, short ev, void *ctx)
radius_delete_packet(pkt); radius_delete_packet(pkt);
ikev2_send_ike_e(env, req->rr_sa, e, IKEV2_PAYLOAD_EAP, ikev2_send_ike_e(env, req->rr_sa, e, IKEV2_PAYLOAD_EAP,
IKEV2_EXCHANGE_IKE_AUTH, 1); IKEV2_EXCHANGE_IKE_AUTH, 1);
ibuf_free(e);
/* keep request for challenge state and config parameters */ /* keep request for challenge state and config parameters */
req->rr_reqid = -1; /* release reqid */ req->rr_reqid = -1; /* release reqid */
return; return;

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: sti.4,v 1.25 2014/03/19 12:57:51 jmc Exp $ .\" $OpenBSD: sti.4,v 1.26 2024/08/17 08:41:25 miod Exp $
.\" .\"
.\" Copyright (c) 2001 Michael Shalayeff .\" Copyright (c) 2001 Michael Shalayeff
.\" All rights reserved. .\" All rights reserved.
@ -24,7 +24,7 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE. .\" THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: March 19 2014 $ .Dd $Mdocdate: August 17 2024 $
.Dt STI 4 .Dt STI 4
.Os .Os
.Sh NAME .Sh NAME
@ -65,7 +65,7 @@ The following models are supported
.\" .It "Visualize 24" Ta "24" Ta "16" Ta "y" Ta "GSC" .\" .It "Visualize 24" Ta "24" Ta "16" Ta "y" Ta "GSC"
.\" .It "Visualize 48" Ta "24" Ta "16" Ta "y" Ta "GSC" .\" .It "Visualize 48" Ta "24" Ta "16" Ta "y" Ta "GSC"
.\" .It "Visualize 48XP" Ta "24" Ta "16" Ta "y" Ta "GSC" .\" .It "Visualize 48XP" Ta "24" Ta "16" Ta "y" Ta "GSC"
.It "Visualize FXE" Ta "24" Ta "24" Ta "y" Ta "PCI 32/66" .It "Visualize FXe" Ta "24" Ta "24" Ta "y" Ta "PCI 32/66"
.It "Visualize FX2" Ta "24" Ta "24" Ta "y" Ta "PCI 64/66" .It "Visualize FX2" Ta "24" Ta "24" Ta "y" Ta "PCI 64/66"
.It "Visualize FX4/FX6" Ta "24" Ta "32" Ta "y" Ta "PCI 64/66" .It "Visualize FX4/FX6" Ta "24" Ta "32" Ta "y" Ta "PCI 64/66"
.\" .It "Visualize FX5pro" Ta "24" Ta "64" Ta "y" Ta "PCI 64/66" .\" .It "Visualize FX5pro" Ta "24" Ta "64" Ta "y" Ta "PCI 64/66"
@ -232,18 +232,18 @@ due to rearchitecture for performance.
.Nm process_mgr .Nm process_mgr
function added. function added.
.El .El
.It 8.0a .It 8.10
PCXL2 and PCXU dual PCXL2 and PCXU dual
.Nm PCI .Nm PCI
EPROM map mode, implemented on EPROM map mode, implemented on
.Nm Visualize EG . .Nm Visualize EG .
.It 8.0b .It 8.11
Support for HP-UX non-implicit locking DMA, implemented on Support for HP-UX non-implicit locking DMA, implemented on
.Nm Visualize FXE . .Nm Visualize FXE .
.It 8.0c .It 8.12
.Nm sti_util .Nm sti_util
function added (flashing under HP-UX and other sideband traffic). function added (flashing under HP-UX and other sideband traffic).
.It 8.0d .It 8.13
Colour frame buffer support. Colour frame buffer support.
.El .El
.Sh SEE ALSO .Sh SEE ALSO

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: tty.4,v 1.55 2022/02/18 23:17:15 jsg Exp $ .\" $OpenBSD: tty.4,v 1.56 2024/08/16 16:10:27 florian Exp $
.\" $NetBSD: tty.4,v 1.4 1996/03/19 04:26:01 paulus Exp $ .\" $NetBSD: tty.4,v 1.4 1996/03/19 04:26:01 paulus Exp $
.\" .\"
.\" Copyright (c) 1991, 1992, 1993 .\" Copyright (c) 1991, 1992, 1993
@ -30,7 +30,7 @@
.\" .\"
.\" @(#)tty.4 8.3 (Berkeley) 4/19/94 .\" @(#)tty.4 8.3 (Berkeley) 4/19/94
.\" .\"
.Dd $Mdocdate: February 18 2022 $ .Dd $Mdocdate: August 16 2024 $
.Dt TTY 4 .Dt TTY 4
.Os .Os
.Sh NAME .Sh NAME
@ -61,8 +61,6 @@ These special terminal devices are called
and provide the mechanism necessary to give users the same interface to the and provide the mechanism necessary to give users the same interface to the
system when logging in over a network (using system when logging in over a network (using
.Xr ssh 1 .Xr ssh 1
or
.Xr telnet 1
for example). for example).
Even in these cases the details of how the terminal Even in these cases the details of how the terminal
file was opened and set up is already handled by special software file was opened and set up is already handled by special software

View file

@ -1,4 +1,4 @@
/* $OpenBSD: icc.c,v 1.1 2022/11/11 15:25:13 matthieu Exp $ */ /* $OpenBSD: icc.c,v 1.2 2024/08/17 15:10:00 deraadt Exp $ */
/* /*
* Copyright (c) 2021 Anton Lindqvist <anton@openbsd.org> * Copyright (c) 2021 Anton Lindqvist <anton@openbsd.org>
@ -48,6 +48,7 @@ const struct cfattach icc_ca = {
sizeof(struct icc_softc), sizeof(struct icc_softc),
icc_match, icc_match,
icc_attach, icc_attach,
icc_detach
}; };
int int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dwiic.c,v 1.15 2023/08/29 12:09:40 kettenis Exp $ */ /* $OpenBSD: dwiic.c,v 1.21 2024/08/17 02:35:00 deraadt Exp $ */
/* /*
* Synopsys DesignWare I2C controller * Synopsys DesignWare I2C controller
* *
@ -21,14 +21,6 @@
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#ifdef __HAVE_ACPI
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpidev.h>
#include <dev/acpi/amltypes.h>
#include <dev/acpi/dsdt.h>
#endif
#include <dev/i2c/i2cvar.h> #include <dev/i2c/i2cvar.h>
#include <dev/ic/dwiicvar.h> #include <dev/ic/dwiicvar.h>
@ -41,34 +33,50 @@ int
dwiic_activate(struct device *self, int act) dwiic_activate(struct device *self, int act)
{ {
struct dwiic_softc *sc = (struct dwiic_softc *)self; struct dwiic_softc *sc = (struct dwiic_softc *)self;
int rv;
switch (act) { switch (act) {
case DVACT_SUSPEND: case DVACT_SUSPEND:
rv = config_activate_children(self, act);
/* disable controller */ /* disable controller */
dwiic_enable(sc, 0); dwiic_enable(sc, 0);
/* disable interrupts */ /* disable interrupts */
dwiic_write(sc, DW_IC_INTR_MASK, 0); dwiic_write(sc, DW_IC_INTR_MASK, 0);
dwiic_read(sc, DW_IC_CLR_INTR); dwiic_read(sc, DW_IC_CLR_INTR);
#if notyet
/* power down the controller */
dwiic_acpi_power(sc, 0);
#endif
break; break;
case DVACT_WAKEUP: case DVACT_RESUME:
#if notyet /* if it became enabled for some reason, force it down */
/* power up the controller */ dwiic_enable(sc, 0);
dwiic_acpi_power(sc, 1);
#endif
dwiic_init(sc);
dwiic_write(sc, DW_IC_INTR_MASK, 0);
dwiic_read(sc, DW_IC_CLR_INTR);
/* write standard-mode SCL timing parameters */
dwiic_write(sc, DW_IC_SS_SCL_HCNT, sc->ss_hcnt);
dwiic_write(sc, DW_IC_SS_SCL_LCNT, sc->ss_lcnt);
/* and fast-mode SCL timing parameters */
dwiic_write(sc, DW_IC_FS_SCL_HCNT, sc->fs_hcnt);
dwiic_write(sc, DW_IC_FS_SCL_LCNT, sc->fs_lcnt);
/* SDA hold time */
dwiic_write(sc, DW_IC_SDA_HOLD, sc->sda_hold_time);
dwiic_write(sc, DW_IC_TX_TL, sc->tx_fifo_depth / 2);
dwiic_write(sc, DW_IC_RX_TL, 0);
/* configure as i2c master with fast speed */
sc->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
dwiic_write(sc, DW_IC_CON, sc->master_cfg);
rv = config_activate_children(self, act);
break;
default:
rv = config_activate_children(self, act);
break; break;
} }
return rv;
config_activate_children(self, act);
return 0;
} }
int int
@ -489,32 +497,32 @@ dwiic_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, const void *cmdbuf,
uint32_t uint32_t
dwiic_read_clear_intrbits(struct dwiic_softc *sc) dwiic_read_clear_intrbits(struct dwiic_softc *sc)
{ {
uint32_t stat; uint32_t stat;
stat = dwiic_read(sc, DW_IC_INTR_STAT); stat = dwiic_read(sc, DW_IC_INTR_STAT);
if (stat & DW_IC_INTR_RX_UNDER) if (stat & DW_IC_INTR_RX_UNDER)
dwiic_read(sc, DW_IC_CLR_RX_UNDER); dwiic_read(sc, DW_IC_CLR_RX_UNDER);
if (stat & DW_IC_INTR_RX_OVER) if (stat & DW_IC_INTR_RX_OVER)
dwiic_read(sc, DW_IC_CLR_RX_OVER); dwiic_read(sc, DW_IC_CLR_RX_OVER);
if (stat & DW_IC_INTR_TX_OVER) if (stat & DW_IC_INTR_TX_OVER)
dwiic_read(sc, DW_IC_CLR_TX_OVER); dwiic_read(sc, DW_IC_CLR_TX_OVER);
if (stat & DW_IC_INTR_RD_REQ) if (stat & DW_IC_INTR_RD_REQ)
dwiic_read(sc, DW_IC_CLR_RD_REQ); dwiic_read(sc, DW_IC_CLR_RD_REQ);
if (stat & DW_IC_INTR_TX_ABRT) if (stat & DW_IC_INTR_TX_ABRT)
dwiic_read(sc, DW_IC_CLR_TX_ABRT); dwiic_read(sc, DW_IC_CLR_TX_ABRT);
if (stat & DW_IC_INTR_RX_DONE) if (stat & DW_IC_INTR_RX_DONE)
dwiic_read(sc, DW_IC_CLR_RX_DONE); dwiic_read(sc, DW_IC_CLR_RX_DONE);
if (stat & DW_IC_INTR_ACTIVITY) if (stat & DW_IC_INTR_ACTIVITY)
dwiic_read(sc, DW_IC_CLR_ACTIVITY); dwiic_read(sc, DW_IC_CLR_ACTIVITY);
if (stat & DW_IC_INTR_STOP_DET) if (stat & DW_IC_INTR_STOP_DET)
dwiic_read(sc, DW_IC_CLR_STOP_DET); dwiic_read(sc, DW_IC_CLR_STOP_DET);
if (stat & DW_IC_INTR_START_DET) if (stat & DW_IC_INTR_START_DET)
dwiic_read(sc, DW_IC_CLR_START_DET); dwiic_read(sc, DW_IC_CLR_START_DET);
if (stat & DW_IC_INTR_GEN_CALL) if (stat & DW_IC_INTR_GEN_CALL)
dwiic_read(sc, DW_IC_CLR_GEN_CALL); dwiic_read(sc, DW_IC_CLR_GEN_CALL);
return stat; return stat;
} }
int int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: qwx.c,v 1.63 2024/06/11 10:06:35 stsp Exp $ */ /* $OpenBSD: qwx.c,v 1.64 2024/08/17 08:12:46 stsp Exp $ */
/* /*
* Copyright 2023 Stefan Sperling <stsp@openbsd.org> * Copyright 2023 Stefan Sperling <stsp@openbsd.org>
@ -19836,10 +19836,7 @@ qwx_core_qmi_firmware_ready(struct qwx_softc *sc)
goto err_core_stop; goto err_core_stop;
} }
#if 0 /* TODO: Is this in the right spot for OpenBSD? */
sc->ops.irq_enable(sc); sc->ops.irq_enable(sc);
#endif
#if 0 #if 0
mutex_unlock(&ab->core_lock); mutex_unlock(&ab->core_lock);
#endif #endif
@ -25390,9 +25387,6 @@ qwx_run(struct qwx_softc *sc)
return ret; return ret;
} }
/* Enable "ext" IRQs for datapath. */
sc->ops.irq_enable(sc);
return 0; return 0;
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sti.c,v 1.83 2022/07/15 19:29:27 deraadt Exp $ */ /* $OpenBSD: sti.c,v 1.84 2024/08/17 08:45:22 miod Exp $ */
/* /*
* Copyright (c) 2000-2003 Michael Shalayeff * Copyright (c) 2000-2003 Michael Shalayeff
@ -110,6 +110,7 @@ void sti_describe_screen(struct sti_softc *, struct sti_screen *);
void sti_end_attach_screen(struct sti_softc *, struct sti_screen *, int); void sti_end_attach_screen(struct sti_softc *, struct sti_screen *, int);
int sti_fetchfonts(struct sti_screen *, struct sti_inqconfout *, u_int32_t, int sti_fetchfonts(struct sti_screen *, struct sti_inqconfout *, u_int32_t,
u_int); u_int);
int32_t sti_gvid(void *, uint32_t, uint32_t *);
void sti_region_setup(struct sti_screen *); void sti_region_setup(struct sti_screen *);
int sti_rom_setup(struct sti_rom *, bus_space_tag_t, bus_space_tag_t, int sti_rom_setup(struct sti_rom *, bus_space_tag_t, bus_space_tag_t,
bus_space_handle_t, bus_addr_t *, u_int); bus_space_handle_t, bus_addr_t *, u_int);
@ -122,6 +123,10 @@ void ngle_elk_setupfb(struct sti_screen *);
void ngle_timber_setupfb(struct sti_screen *); void ngle_timber_setupfb(struct sti_screen *);
int ngle_putcmap(struct sti_screen *, u_int, u_int); int ngle_putcmap(struct sti_screen *, u_int, u_int);
/*
* Helper macros to control whether the STI ROM is accessible on PCI
* devices.
*/
#if NSTI_PCI > 0 #if NSTI_PCI > 0
#define STI_ENABLE_ROM(sc) \ #define STI_ENABLE_ROM(sc) \
do { \ do { \
@ -301,6 +306,15 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt,
dd->dd_pacode[0xf]); dd->dd_pacode[0xf]);
#endif #endif
/*
* Take note that it will be necessary to enable the PCI ROM around
* some sti function calls if the MMAP (multiple map) bit is set in
* the bus support flags, which means the PCI ROM is only available
* through the PCI expansion ROM space and never through regular
* PCI BARs.
*/
rom->rom_enable = dd->dd_bussup & STI_BUSSUPPORT_ROMMAP;
/* /*
* Figure out how much bytes we need for the STI code. * Figure out how much bytes we need for the STI code.
* Note there could be fewer than STI_END entries pointer * Note there could be fewer than STI_END entries pointer
@ -337,9 +351,8 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt,
u_int32_t addr, eaddr; u_int32_t addr, eaddr;
for (addr = dd->dd_pacode[STI_BEGIN], eaddr = addr + size * 4; for (addr = dd->dd_pacode[STI_BEGIN], eaddr = addr + size * 4;
addr < eaddr; addr += 4 ) addr < eaddr; addr += 4)
*p++ = bus_space_read_4(memt, romh, addr) & 0xff; *p++ = bus_space_read_4(memt, romh, addr) & 0xff;
} else /* STI_DEVTYPE4 */ } else /* STI_DEVTYPE4 */
bus_space_read_raw_region_4(memt, romh, bus_space_read_raw_region_4(memt, romh,
dd->dd_pacode[STI_BEGIN], rom->rom_code, size); dd->dd_pacode[STI_BEGIN], rom->rom_code, size);
@ -371,18 +384,10 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt,
(rom->rom_devtype == STI_DEVTYPE1? 4 : 1))) (rom->rom_devtype == STI_DEVTYPE1? 4 : 1)))
rom->init = (sti_init_t)O(STI_INIT_GRAPH); rom->init = (sti_init_t)O(STI_INIT_GRAPH);
rom->mgmt = (sti_mgmt_t)O(STI_STATE_MGMT);
rom->unpmv = (sti_unpmv_t)O(STI_FONT_UNPMV); rom->unpmv = (sti_unpmv_t)O(STI_FONT_UNPMV);
rom->blkmv = (sti_blkmv_t)O(STI_BLOCK_MOVE); rom->blkmv = (sti_blkmv_t)O(STI_BLOCK_MOVE);
rom->test = (sti_test_t)O(STI_SELF_TEST);
rom->exhdl = (sti_exhdl_t)O(STI_EXCEP_HDLR);
rom->inqconf = (sti_inqconf_t)O(STI_INQ_CONF); rom->inqconf = (sti_inqconf_t)O(STI_INQ_CONF);
rom->scment = (sti_scment_t)O(STI_SCM_ENT); rom->scment = (sti_scment_t)O(STI_SCM_ENT);
rom->dmac = (sti_dmac_t)O(STI_DMA_CTRL);
rom->flowc = (sti_flowc_t)O(STI_FLOW_CTRL);
rom->utiming = (sti_utiming_t)O(STI_UTIMING);
rom->pmgr = (sti_pmgr_t)O(STI_PROC_MGR);
rom->util = (sti_util_t)O(STI_UTIL);
#undef O #undef O
@ -502,6 +507,42 @@ sti_region_setup(struct sti_screen *scr)
#endif #endif
} }
/*
* ``gvid'' callback routine.
*
* The FireGL-UX board is using this interface, and will revert to direct
* PDC calls if no gvid callback is set.
* Unfortunately, under OpenBSD it is not possible to invoke PDC directly
* from its physical address once the MMU is turned on, and no documentation
* for the gvid interface (or for the particular PDC_PCI subroutines used
* by the FireGL-UX rom) has been found.
*/
int32_t
sti_gvid(void *v, uint32_t cmd, uint32_t *params)
{
struct sti_screen *scr = v;
struct sti_rom *rom = scr->scr_rom;
/* paranoia */
if (cmd != 0x000c0003)
return -1;
switch (params[0]) {
case 4:
/* register read */
params[2] =
bus_space_read_4(rom->memt, rom->regh[2], params[1]);
return 0;
case 5:
/* register write */
bus_space_write_4(rom->memt, rom->regh[2], params[1],
params[2]);
return 0;
default:
return -1;
}
}
int int
sti_screen_setup(struct sti_screen *scr, int flags) sti_screen_setup(struct sti_screen *scr, int flags)
{ {
@ -510,8 +551,8 @@ sti_screen_setup(struct sti_screen *scr, int flags)
bus_space_handle_t romh = rom->romh; bus_space_handle_t romh = rom->romh;
struct sti_dd *dd = &rom->rom_dd; struct sti_dd *dd = &rom->rom_dd;
struct sti_cfg *cc = &scr->scr_cfg; struct sti_cfg *cc = &scr->scr_cfg;
struct sti_inqconfout cfg; struct sti_inqconfout inq;
struct sti_einqconfout ecfg; struct sti_einqconfout einq;
int error, i; int error, i;
int geometry_kluge = 0; int geometry_kluge = 0;
u_int fontindex = 0; u_int fontindex = 0;
@ -522,7 +563,7 @@ sti_screen_setup(struct sti_screen *scr, int flags)
if (dd->dd_stimemreq) { if (dd->dd_stimemreq) {
scr->scr_ecfg.addr = scr->scr_ecfg.addr =
malloc(dd->dd_stimemreq, M_DEVBUF, M_NOWAIT); malloc(dd->dd_stimemreq, M_DEVBUF, M_NOWAIT | M_ZERO);
if (!scr->scr_ecfg.addr) { if (!scr->scr_ecfg.addr) {
printf("cannot allocate %d bytes for STI\n", printf("cannot allocate %d bytes for STI\n",
dd->dd_stimemreq); dd->dd_stimemreq);
@ -530,6 +571,12 @@ sti_screen_setup(struct sti_screen *scr, int flags)
} }
} }
if (dd->dd_ebussup & STI_EBUSSUPPORT_GVID) {
scr->scr_ecfg.future.g.gvid_cmd_arg = scr;
scr->scr_ecfg.future.g.gvid_cmd =
(int32_t (*)(void *, ...))sti_gvid;
}
sti_region_setup(scr); sti_region_setup(scr);
if ((error = sti_init(scr, 0))) { if ((error = sti_init(scr, 0))) {
@ -537,10 +584,10 @@ sti_screen_setup(struct sti_screen *scr, int flags)
goto fail; goto fail;
} }
bzero(&cfg, sizeof(cfg)); bzero(&inq, sizeof(inq));
bzero(&ecfg, sizeof(ecfg)); bzero(&einq, sizeof(einq));
cfg.ext = &ecfg; inq.ext = &einq;
if ((error = sti_inqcfg(scr, &cfg))) { if ((error = sti_inqcfg(scr, &inq))) {
printf(": error %d inquiring config\n", error); printf(": error %d inquiring config\n", error);
goto fail; goto fail;
} }
@ -550,25 +597,24 @@ sti_screen_setup(struct sti_screen *scr, int flags)
* similar to the displayable area size, at least in m68k mode. * similar to the displayable area size, at least in m68k mode.
* Attempt to detect this and adjust here. * Attempt to detect this and adjust here.
*/ */
if (cfg.owidth == cfg.width && if (inq.owidth == inq.width && inq.oheight == inq.height)
cfg.oheight == cfg.height)
geometry_kluge = 1; geometry_kluge = 1;
if (geometry_kluge) { if (geometry_kluge) {
scr->scr_cfg.oscr_width = cfg.owidth = scr->scr_cfg.oscr_width = inq.owidth =
cfg.fbwidth - cfg.width; inq.fbwidth - inq.width;
scr->scr_cfg.oscr_height = cfg.oheight = scr->scr_cfg.oscr_height = inq.oheight =
cfg.fbheight - cfg.height; inq.fbheight - inq.height;
} }
/* /*
* Save a few fields for sti_describe_screen() later * Save a few fields for sti_describe_screen() later
*/ */
scr->fbheight = cfg.fbheight; scr->fbheight = inq.fbheight;
scr->fbwidth = cfg.fbwidth; scr->fbwidth = inq.fbwidth;
scr->oheight = cfg.oheight; scr->oheight = inq.oheight;
scr->owidth = cfg.owidth; scr->owidth = inq.owidth;
bcopy(cfg.name, scr->name, sizeof(scr->name)); bcopy(inq.name, scr->name, sizeof(scr->name));
if ((error = sti_init(scr, STI_TEXTMODE | flags))) { if ((error = sti_init(scr, STI_TEXTMODE | flags))) {
printf(": can not initialize (%d)\n", error); printf(": can not initialize (%d)\n", error);
@ -576,12 +622,12 @@ sti_screen_setup(struct sti_screen *scr, int flags)
} }
#ifdef STIDEBUG #ifdef STIDEBUG
printf("conf: bpp=%d planes=%d attr=%b\n" printf("conf: bpp=%d planes=%d attr=%b\n"
"crt=0x%x:0x%x:0x%x hw=0x%x:0x%x:0x%x\n", cfg.bpp, "crt=0x%x:0x%x:0x%x hw=0x%x:0x%x:0x%x\n", inq.bpp,
cfg.planes, cfg.attributes, STI_INQCONF_BITS, inq.planes, inq.attributes, STI_INQCONF_BITS,
ecfg.crt_config[0], ecfg.crt_config[1], ecfg.crt_config[2], einq.crt_config[0], einq.crt_config[1], einq.crt_config[2],
ecfg.crt_hw[0], ecfg.crt_hw[1], ecfg.crt_hw[2]); einq.crt_hw[0], einq.crt_hw[1], einq.crt_hw[2]);
#endif #endif
scr->scr_bpp = cfg.bppu; scr->scr_bpp = inq.bppu;
/* /*
* Although scr->scr_ecfg.current_monitor is not filled by * Although scr->scr_ecfg.current_monitor is not filled by
@ -618,7 +664,7 @@ sti_screen_setup(struct sti_screen *scr, int flags)
#endif #endif
} }
if ((error = sti_fetchfonts(scr, &cfg, dd->dd_fntaddr, fontindex))) { if ((error = sti_fetchfonts(scr, &inq, dd->dd_fntaddr, fontindex))) {
printf(": cannot fetch fonts (%d)\n", error); printf(": cannot fetch fonts (%d)\n", error);
goto fail; goto fail;
} }
@ -631,8 +677,8 @@ sti_screen_setup(struct sti_screen *scr, int flags)
*/ */
strlcpy(scr->scr_wsd.name, "std", sizeof(scr->scr_wsd.name)); strlcpy(scr->scr_wsd.name, "std", sizeof(scr->scr_wsd.name));
scr->scr_wsd.ncols = cfg.width / scr->scr_curfont.width; scr->scr_wsd.ncols = inq.width / scr->scr_curfont.width;
scr->scr_wsd.nrows = cfg.height / scr->scr_curfont.height; scr->scr_wsd.nrows = inq.height / scr->scr_curfont.height;
scr->scr_wsd.textops = &sti_emulops; scr->scr_wsd.textops = &sti_emulops;
scr->scr_wsd.fontwidth = scr->scr_curfont.width; scr->scr_wsd.fontwidth = scr->scr_curfont.width;
scr->scr_wsd.fontheight = scr->scr_curfont.height; scr->scr_wsd.fontheight = scr->scr_curfont.height;
@ -699,9 +745,10 @@ sti_screen_setup(struct sti_screen *scr, int flags)
case STI_DD_3X2V: case STI_DD_3X2V:
case STI_DD_DUAL_CRX: case STI_DD_DUAL_CRX:
case STI_DD_HCRX: case STI_DD_HCRX:
case STI_DD_LEGO:
case STI_DD_SUMMIT: case STI_DD_SUMMIT:
case STI_DD_PINNACLE: case STI_DD_PINNACLE:
case STI_DD_LEGO:
case STI_DD_FIREGL:
default: default:
scr->setupfb = NULL; scr->setupfb = NULL;
scr->putcmap = scr->putcmap =
@ -713,7 +760,11 @@ sti_screen_setup(struct sti_screen *scr, int flags)
return (0); return (0);
fail: fail:
/* XXX free resources */ /* free resources */
if (scr->scr_romfont != NULL) {
free(scr->scr_romfont, M_DEVBUF, 0);
scr->scr_romfont = NULL;
}
if (scr->scr_ecfg.addr != NULL) { if (scr->scr_ecfg.addr != NULL) {
free(scr->scr_ecfg.addr, M_DEVBUF, 0); free(scr->scr_ecfg.addr, M_DEVBUF, 0);
scr->scr_ecfg.addr = NULL; scr->scr_ecfg.addr = NULL;
@ -809,7 +860,7 @@ sti_rom_size(bus_space_tag_t memt, bus_space_handle_t romh)
} }
int int
sti_fetchfonts(struct sti_screen *scr, struct sti_inqconfout *cfg, sti_fetchfonts(struct sti_screen *scr, struct sti_inqconfout *inq,
u_int32_t baseaddr, u_int fontindex) u_int32_t baseaddr, u_int fontindex)
{ {
struct sti_rom *rom = scr->scr_rom; struct sti_rom *rom = scr->scr_rom;
@ -901,16 +952,16 @@ rescan:
* display all the characters there in order to display them * display all the characters there in order to display them
* faster with blkmv operations rather than unpmv later on. * faster with blkmv operations rather than unpmv later on.
*/ */
if (size <= cfg->fbheight * if (size <= inq->fbheight *
(cfg->fbwidth - cfg->width - cfg->owidth)) { (inq->fbwidth - inq->width - inq->owidth)) {
bzero(&a, sizeof(a)); bzero(&a, sizeof(a));
a.flags.flags = STI_UNPMVF_WAIT; a.flags.flags = STI_UNPMVF_WAIT;
a.in.fg_colour = STI_COLOUR_WHITE; a.in.fg_colour = STI_COLOUR_WHITE;
a.in.bg_colour = STI_COLOUR_BLACK; a.in.bg_colour = STI_COLOUR_BLACK;
a.in.font_addr = scr->scr_romfont; a.in.font_addr = scr->scr_romfont;
scr->scr_fontmaxcol = cfg->fbheight / fp->height; scr->scr_fontmaxcol = inq->fbheight / fp->height;
scr->scr_fontbase = cfg->width + cfg->owidth; scr->scr_fontbase = inq->width + inq->owidth;
for (uc = fp->first; uc <= fp->last; uc++) { for (uc = fp->first; uc <= fp->last; uc++) {
a.in.x = ((uc - fp->first) / scr->scr_fontmaxcol) * a.in.x = ((uc - fp->first) / scr->scr_fontmaxcol) *
fp->width + scr->scr_fontbase; fp->width + scr->scr_fontbase;
@ -969,7 +1020,15 @@ sti_init(struct sti_screen *scr, int mode)
printf("sti_init,%p(%x, %p, %p, %p)\n", printf("sti_init,%p(%x, %p, %p, %p)\n",
rom->init, a.flags.flags, &a.in, &a.out, &scr->scr_cfg); rom->init, a.flags.flags, &a.in, &a.out, &scr->scr_cfg);
#endif #endif
/*
* Make the ROM visible during initialization, some devices
* look for various data into their ROM image.
*/
if (rom->rom_enable)
STI_ENABLE_ROM(rom->rom_softc);
(*rom->init)(&a.flags, &a.in, &a.out, &scr->scr_cfg); (*rom->init)(&a.flags, &a.in, &a.out, &scr->scr_cfg);
if (rom->rom_enable)
STI_DISABLE_ROM(rom->rom_softc);
if (a.out.text_planes != a.in.text_planes) if (a.out.text_planes != a.in.text_planes)
return (-1); /* not colliding with sti errno values */ return (-1); /* not colliding with sti errno values */
return (a.out.errno); return (a.out.errno);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $ */ /* $OpenBSD: stireg.h,v 1.15 2024/08/17 08:45:22 miod Exp $ */
/* /*
* Copyright (c) 2000 Michael Shalayeff * Copyright (c) 2000 Michael Shalayeff
@ -29,8 +29,6 @@
#ifndef _IC_STIREG_H_ #ifndef _IC_STIREG_H_
#define _IC_STIREG_H_ #define _IC_STIREG_H_
/* #define STIDEBUG */
#define STI_REGION_MAX 8 #define STI_REGION_MAX 8
#define STI_MONITOR_MAX 256 #define STI_MONITOR_MAX 256
#define STI_DEVNAME_LEN 32 #define STI_DEVNAME_LEN 32
@ -134,6 +132,7 @@ struct sti_dd {
#define STI_DD_SUMMIT 0x2FC1066B /* Visualize FX2, FX4, FX6 */ #define STI_DD_SUMMIT 0x2FC1066B /* Visualize FX2, FX4, FX6 */
#define STI_DD_PINNACLE 0x35ACDA16 /* Visualize FXe */ #define STI_DD_PINNACLE 0x35ACDA16 /* Visualize FXe */
#define STI_DD_LEGO 0x35ACDA30 /* Visualize FX5, FX10 */ #define STI_DD_LEGO 0x35ACDA30 /* Visualize FX5, FX10 */
#define STI_DD_FIREGL 0x3BA8F544 /* FireGL-UX */
u_int32_t dd_fntaddr; /* 0x10 font start address */ u_int32_t dd_fntaddr; /* 0x10 font start address */
u_int32_t dd_maxst; /* 0x14 max state storage */ u_int32_t dd_maxst; /* 0x14 max state storage */
u_int32_t dd_romend; /* 0x18 rom last address */ u_int32_t dd_romend; /* 0x18 rom last address */
@ -157,6 +156,7 @@ struct sti_dd {
u_int8_t dd_ebussup; /* 0x37 extended bus support */ u_int8_t dd_ebussup; /* 0x37 extended bus support */
#define STI_EBUSSUPPORT_DMA 0x01 /* supports dma */ #define STI_EBUSSUPPORT_DMA 0x01 /* supports dma */
#define STI_EBUSSUPPORT_PIOLOCK 0x02 /* no implicit locking for dma */ #define STI_EBUSSUPPORT_PIOLOCK 0x02 /* no implicit locking for dma */
#define STI_EBUSSUPPORT_GVID 0x04 /* requires gvid callback */
u_int8_t dd_altcodet; /* 0x38 alternate code type */ u_int8_t dd_altcodet; /* 0x38 alternate code type */
#define STI_ALTCODE_UNKNOWN 0x00 #define STI_ALTCODE_UNKNOWN 0x00
#define STI_ALTCODE_PA64 0x01 /* alt code is in pa64 */ #define STI_ALTCODE_PA64 0x01 /* alt code is in pa64 */
@ -228,7 +228,15 @@ typedef struct sti_ecfg {
u_int16_t power; /* power dissipation Watts */ u_int16_t power; /* power dissipation Watts */
u_int32_t freq_ref; u_int32_t freq_ref;
u_int32_t *addr; /* memory block of size dd_stimemreq */ u_int32_t *addr; /* memory block of size dd_stimemreq */
void *future; union {
struct {
int32_t (*gvid_cmd)(void *, ...);
void *gvid_cmd_arg;
u_int32_t pci_id;
void *future;
} g;
void *future;
} future;
} __packed *sti_ecfg_t; } __packed *sti_ecfg_t;
typedef struct sti_cfg { typedef struct sti_cfg {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: stivar.h,v 1.28 2024/05/29 00:48:15 jsg Exp $ */ /* $OpenBSD: stivar.h,v 1.29 2024/08/17 08:45:22 miod Exp $ */
/* /*
* Copyright (c) 2000-2003 Michael Shalayeff * Copyright (c) 2000-2003 Michael Shalayeff
@ -47,22 +47,16 @@ struct sti_rom {
struct sti_dd rom_dd; /* in word format */ struct sti_dd rom_dd; /* in word format */
u_int8_t *rom_code; u_int8_t *rom_code;
int rom_enable;
/* /*
* ROM-provided function pointers * ROM-provided function pointers
*/ */
sti_init_t init; sti_init_t init;
sti_mgmt_t mgmt;
sti_unpmv_t unpmv; sti_unpmv_t unpmv;
sti_blkmv_t blkmv; sti_blkmv_t blkmv;
sti_test_t test;
sti_exhdl_t exhdl;
sti_inqconf_t inqconf; sti_inqconf_t inqconf;
sti_scment_t scment; sti_scment_t scment;
sti_dmac_t dmac;
sti_flowc_t flowc;
sti_utiming_t utiming;
sti_pmgr_t pmgr;
sti_util_t util;
}; };
/* /*

View file

@ -1487,9 +1487,11 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev,
#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) #if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND)
bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev); bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
void amdgpu_choose_low_power_state(struct amdgpu_device *adev);
#else #else
static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; } static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; }
static inline void amdgpu_choose_low_power_state(struct amdgpu_device *adev) { }
#endif #endif
#if defined(CONFIG_DRM_AMD_DC) #if defined(CONFIG_DRM_AMD_DC)

View file

@ -1519,6 +1519,7 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
if (adev->asic_type < CHIP_RAVEN) if (adev->asic_type < CHIP_RAVEN)
return false; return false;
#ifdef __linux__
/* /*
* If ACPI_FADT_LOW_POWER_S0 is not set in the FADT, it is generally * If ACPI_FADT_LOW_POWER_S0 is not set in the FADT, it is generally
* risky to do any special firmware-related preparations for entering * risky to do any special firmware-related preparations for entering
@ -1531,6 +1532,7 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
"To use suspend-to-idle change the sleep mode in BIOS setup.\n"); "To use suspend-to-idle change the sleep mode in BIOS setup.\n");
return false; return false;
} }
#endif
#if !IS_ENABLED(CONFIG_AMD_PMC) #if !IS_ENABLED(CONFIG_AMD_PMC)
dev_err_once(adev->dev, dev_err_once(adev->dev,
@ -1541,4 +1543,19 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
#endif /* CONFIG_AMD_PMC */ #endif /* CONFIG_AMD_PMC */
} }
/**
* amdgpu_choose_low_power_state
*
* @adev: amdgpu_device_pointer
*
* Choose the target low power state for the GPU
*/
void amdgpu_choose_low_power_state(struct amdgpu_device *adev)
{
if (amdgpu_acpi_is_s0ix_active(adev))
adev->in_s0ix = true;
else if (amdgpu_acpi_is_s3_active(adev))
adev->in_s3 = true;
}
#endif /* CONFIG_SUSPEND */ #endif /* CONFIG_SUSPEND */

View file

@ -4221,13 +4221,15 @@ int amdgpu_device_prepare(struct drm_device *dev)
struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_device *adev = drm_to_adev(dev);
int i, r; int i, r;
amdgpu_choose_low_power_state(adev);
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0; return 0;
/* Evict the majority of BOs before starting suspend sequence */ /* Evict the majority of BOs before starting suspend sequence */
r = amdgpu_device_evict_resources(adev); r = amdgpu_device_evict_resources(adev);
if (r) if (r)
return r; goto unprepare;
flush_delayed_work(&adev->gfx.gfx_off_delay_work); flush_delayed_work(&adev->gfx.gfx_off_delay_work);
@ -4238,10 +4240,15 @@ int amdgpu_device_prepare(struct drm_device *dev)
continue; continue;
r = adev->ip_blocks[i].version->funcs->prepare_suspend((void *)adev); r = adev->ip_blocks[i].version->funcs->prepare_suspend((void *)adev);
if (r) if (r)
return r; goto unprepare;
} }
return 0; return 0;
unprepare:
adev->in_s0ix = adev->in_s3 = false;
return r;
} }
/** /**

View file

@ -2383,8 +2383,6 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work)
} }
} }
#ifdef notyet
static int amdgpu_pmops_prepare(struct device *dev) static int amdgpu_pmops_prepare(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
@ -2477,6 +2475,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
return 0; return 0;
} }
#ifdef notyet
static int amdgpu_pmops_thaw(struct device *dev) static int amdgpu_pmops_thaw(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
@ -2491,6 +2491,8 @@ static int amdgpu_pmops_poweroff(struct device *dev)
return amdgpu_device_suspend(drm_dev, true); return amdgpu_device_suspend(drm_dev, true);
} }
#endif
static int amdgpu_pmops_restore(struct device *dev) static int amdgpu_pmops_restore(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
@ -2498,6 +2500,8 @@ static int amdgpu_pmops_restore(struct device *dev)
return amdgpu_device_resume(drm_dev, true); return amdgpu_device_resume(drm_dev, true);
} }
#ifdef notyet
static int amdgpu_runtime_idle_check_display(struct device *dev) static int amdgpu_runtime_idle_check_display(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
@ -3496,6 +3500,8 @@ amdgpu_attachhook(struct device *self)
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct amdgpu_bo *rbo; struct amdgpu_bo *rbo;
dev_set_drvdata(self, dev);
r = amdgpu_driver_load_kms(adev, adev->flags); r = amdgpu_driver_load_kms(adev, adev->flags);
if (r) if (r)
goto out; goto out;
@ -3671,15 +3677,23 @@ amdgpu_activate(struct device *self, int act)
switch (act) { switch (act) {
case DVACT_QUIESCE: case DVACT_QUIESCE:
rv = config_activate_children(self, act); rv = config_activate_children(self, act);
amdgpu_device_prepare(dev); amdgpu_pmops_prepare(self);
amdgpu_device_suspend(dev, true); if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4)
amdgpu_pmops_freeze(self);
else
amdgpu_pmops_suspend(self);
break; break;
case DVACT_SUSPEND: case DVACT_SUSPEND:
if (!acpi_softc || acpi_softc->sc_state != ACPI_STATE_S4)
amdgpu_pmops_suspend_noirq(self);
break; break;
case DVACT_RESUME: case DVACT_RESUME:
break; break;
case DVACT_WAKEUP: case DVACT_WAKEUP:
amdgpu_device_resume(dev, true); if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4)
amdgpu_pmops_restore(self);
else
amdgpu_pmops_resume(self);
rv = config_activate_children(self, act); rv = config_activate_children(self, act);
break; break;
} }

View file

@ -1550,10 +1550,16 @@ drm_activate(struct device *self, int act)
switch (act) { switch (act) {
case DVACT_QUIESCE: case DVACT_QUIESCE:
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S3) if (acpi_softc) {
pm_suspend_target_state = PM_SUSPEND_MEM; switch (acpi_softc->sc_state) {
else case ACPI_STATE_S0:
pm_suspend_target_state = PM_SUSPEND_TO_IDLE; pm_suspend_target_state = PM_SUSPEND_TO_IDLE;
break;
case ACPI_STATE_S3:
pm_suspend_target_state = PM_SUSPEND_MEM;
break;
}
}
#else #else
pm_suspend_target_state = PM_SUSPEND_TO_IDLE; pm_suspend_target_state = PM_SUSPEND_TO_IDLE;
#endif #endif

View file

@ -36,6 +36,7 @@
#if NACPI > 0 #if NACPI > 0
#define CONFIG_ACPI 1 #define CONFIG_ACPI 1
#define CONFIG_ACPI_SLEEP 1 #define CONFIG_ACPI_SLEEP 1
#define CONFIG_AMD_PMC 1
#endif #endif
#endif #endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pci.h,v 1.16 2024/01/16 23:38:13 jsg Exp $ */ /* $OpenBSD: pci.h,v 1.17 2024/08/16 10:46:46 kettenis Exp $ */
/* /*
* Copyright (c) 2015 Mark Kettenis * Copyright (c) 2015 Mark Kettenis
* *
@ -524,4 +524,10 @@ pci_match_id(const struct pci_device_id *ids, struct pci_dev *pdev)
#define PCI_CLASS_ACCELERATOR_PROCESSING \ #define PCI_CLASS_ACCELERATOR_PROCESSING \
(PCI_CLASS_ACCELERATOR << 8) (PCI_CLASS_ACCELERATOR << 8)
static inline int
pci_device_is_present(struct pci_dev *pdev)
{
return 1;
}
#endif /* _LINUX_PCI_H_ */ #endif /* _LINUX_PCI_H_ */

View file

@ -80,4 +80,10 @@ pm_runtime_get_if_active(struct device *dev, bool x)
return -EINVAL; return -EINVAL;
} }
static inline int
pm_runtime_suspended(struct device *dev)
{
return 0;
}
#endif #endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dwiic_pci.c,v 1.27 2024/05/24 06:02:53 jsg Exp $ */ /* $OpenBSD: dwiic_pci.c,v 1.30 2024/08/17 02:31:15 deraadt Exp $ */
/* /*
* Synopsys DesignWare I2C controller * Synopsys DesignWare I2C controller
* PCI attachment * PCI attachment
@ -293,15 +293,14 @@ dwiic_pci_activate(struct device *self, int act)
struct dwiic_softc *sc = (struct dwiic_softc *)self; struct dwiic_softc *sc = (struct dwiic_softc *)self;
switch (act) { switch (act) {
case DVACT_WAKEUP: case DVACT_RESUME:
DELAY(10000); /* 10 msec */
bus_space_write_4(sc->sc_iot, sc->sc_ioh, LPSS_RESETS, bus_space_write_4(sc->sc_iot, sc->sc_ioh, LPSS_RESETS,
(LPSS_RESETS_I2C | LPSS_RESETS_IDMA)); (LPSS_RESETS_I2C | LPSS_RESETS_IDMA));
DELAY(10000); /* 10 msec */
break; break;
} }
return dwiic_activate(self, act);
dwiic_activate(self, act);
return 0;
} }
void void

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sti_pci.c,v 1.13 2023/04/13 15:07:43 miod Exp $ */ /* $OpenBSD: sti_pci.c,v 1.14 2024/08/17 08:45:22 miod Exp $ */
/* /*
* Copyright (c) 2006, 2007, 2023 Miodrag Vallat. * Copyright (c) 2006, 2007, 2023 Miodrag Vallat.
@ -52,6 +52,9 @@ const struct pci_matchid sti_pci_devices[] = {
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX4 }, { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX4 },
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX6 }, { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX6 },
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FXE }, { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FXE },
#ifdef notyet
{ PCI_VENDOR_IBM, PCI_PRODUCT_IBM_FIREGL2 }
#endif
}; };
int sti_readbar(struct sti_softc *, struct pci_attach_args *, u_int, int); int sti_readbar(struct sti_softc *, struct pci_attach_args *, u_int, int);
@ -267,6 +270,15 @@ sti_check_rom(struct sti_pci_softc *spc, struct pci_attach_args *pa)
bus_space_read_region_1(pa->pa_memt, romh, offs, region_bars, bus_space_read_region_1(pa->pa_memt, romh, offs, region_bars,
STI_REGION_MAX); STI_REGION_MAX);
for (i = 0; i < STI_REGION_MAX; i++) { for (i = 0; i < STI_REGION_MAX; i++) {
/*
* Region 0 is supposed to always be the ROM. FireGL-UX
* ROM agrees so well that it will report the expansion
* ROM BAR rather than any regular BAR.
* We'll address this later after remapping the ROM.
*/
if (i == 0 && region_bars[i] == PCI_ROM_REG)
continue;
rc = sti_readbar(sc, pa, i, region_bars[i]); rc = sti_readbar(sc, pa, i, region_bars[i]);
if (rc != 0) if (rc != 0)
goto unmap_disable_return; goto unmap_disable_return;
@ -297,6 +309,16 @@ sti_check_rom(struct sti_pci_softc *spc, struct pci_attach_args *pa)
goto disable_return; goto disable_return;
} }
/*
* Now set up region 0 if we had skipped it earlier.
*/
if (region_bars[0] == PCI_ROM_REG) {
sc->bases[0] =
(bus_addr_t)bus_space_vaddr(pa->pa_memt, spc->sc_romh) -
(offs - ctx.romoffs);
}
sti_pci_disable_rom(sc); sti_pci_disable_rom(sc);
return 0; return 0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: xhci_pci.c,v 1.13 2024/05/24 06:02:58 jsg Exp $ */ /* $OpenBSD: xhci_pci.c,v 1.14 2024/08/17 01:55:03 jsg Exp $ */
/* /*
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -151,6 +151,11 @@ xhci_pci_attach(struct device *parent, struct device *self, void *aux)
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FRESCO_FL1400) PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FRESCO_FL1400)
pa->pa_flags &= ~PCI_FLAGS_MSI_ENABLED; pa->pa_flags &= ~PCI_FLAGS_MSI_ENABLED;
break; break;
case PCI_VENDOR_AMD:
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_1 ||
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_2)
psc->sc.sc_flags |= XHCI_NOCSS;
break;
} }
/* Map and establish the interrupt. */ /* Map and establish the interrupt. */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vio.c,v 1.45 2024/08/01 11:13:19 sf Exp $ */ /* $OpenBSD: if_vio.c,v 1.46 2024/08/16 13:02:44 jan Exp $ */
/* /*
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@ -1133,9 +1133,6 @@ vio_rx_offload(struct mbuf *m, struct virtio_net_hdr *hdr)
ether_extract_headers(m, &ext); ether_extract_headers(m, &ext);
if (ext.ip4)
SET(m->m_pkthdr.csum_flags, M_IPV4_CSUM_IN_OK);
if (ext.tcp) { if (ext.tcp) {
SET(m->m_pkthdr.csum_flags, M_TCP_CSUM_IN_OK); SET(m->m_pkthdr.csum_flags, M_TCP_CSUM_IN_OK);
if (ISSET(hdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) if (ISSET(hdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM))

View file

@ -1,4 +1,4 @@
/* $OpenBSD: xhci.c,v 1.133 2024/08/15 17:17:05 kettenis Exp $ */ /* $OpenBSD: xhci.c,v 1.134 2024/08/17 01:55:03 jsg Exp $ */
/* /*
* Copyright (c) 2014-2015 Martin Pieuchot * Copyright (c) 2014-2015 Martin Pieuchot
@ -626,24 +626,25 @@ xhci_suspend(struct xhci_softc *sc)
* will prevent the SoC from reaching its lowest idle state. * will prevent the SoC from reaching its lowest idle state.
* So save the state here. * So save the state here.
*/ */
if ((sc->sc_flags & XHCI_NOCSS) == 0) {
XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CSS); /* Save state */
hcr = XOREAD4(sc, XHCI_USBSTS);
for (i = 0; i < 100; i++) {
usb_delay_ms(&sc->sc_bus, 1);
hcr = XOREAD4(sc, XHCI_USBSTS) & XHCI_STS_SSS;
if (!hcr)
break;
}
XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CSS); /* Save state */ if (hcr) {
hcr = XOREAD4(sc, XHCI_USBSTS); printf("%s: save state timeout\n", DEVNAME(sc));
for (i = 0; i < 100; i++) { xhci_reset(sc);
usb_delay_ms(&sc->sc_bus, 1); return;
hcr = XOREAD4(sc, XHCI_USBSTS) & XHCI_STS_SSS; }
if (!hcr)
break; sc->sc_saved_state = 1;
} }
if (hcr) {
printf("%s: save state timeout\n", DEVNAME(sc));
xhci_reset(sc);
return;
}
sc->sc_saved_state = 1;
/* Disable interrupts. */ /* Disable interrupts. */
XRWRITE4(sc, XHCI_IMOD(0), 0); XRWRITE4(sc, XHCI_IMOD(0), 0);
XRWRITE4(sc, XHCI_IMAN(0), 0); XRWRITE4(sc, XHCI_IMAN(0), 0);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: xhcivar.h,v 1.15 2024/08/15 17:17:05 kettenis Exp $ */ /* $OpenBSD: xhcivar.h,v 1.16 2024/08/17 01:55:03 jsg Exp $ */
/* /*
* Copyright (c) 2014 Martin Pieuchot * Copyright (c) 2014 Martin Pieuchot
@ -121,6 +121,9 @@ struct xhci_softc {
char sc_vendor[16]; /* Vendor string for root hub */ char sc_vendor[16]; /* Vendor string for root hub */
int sc_id_vendor; /* Vendor ID for root hub */ int sc_id_vendor; /* Vendor ID for root hub */
int sc_flags;
#define XHCI_NOCSS 0x01
}; };
int xhci_init(struct xhci_softc *); int xhci_init(struct xhci_softc *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: wsmux.c,v 1.58 2024/05/29 06:39:13 jsg Exp $ */ /* $OpenBSD: wsmux.c,v 1.59 2024/08/16 12:22:17 miod Exp $ */
/* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */ /* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */
/* /*
@ -143,7 +143,7 @@ wsmux_getmux(int n)
struct wsmux_softc **new, **old; struct wsmux_softc **new, **old;
int i; int i;
if (n >= WSMUX_MAXDEV) if (n < 0 || n >= WSMUX_MAXDEV)
return (NULL); return (NULL);
/* Make sure there is room for mux n in the table */ /* Make sure there is room for mux n in the table */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.231 2024/08/11 15:10:53 mvs Exp $ */ /* $OpenBSD: kern_exit.c,v 1.232 2024/08/16 16:19:03 mpi Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/* /*
@ -432,7 +432,7 @@ proc_free(struct proc *p)
{ {
crfree(p->p_ucred); crfree(p->p_ucred);
pool_put(&proc_pool, p); pool_put(&proc_pool, p);
nthreads--; atomic_dec_int(&nthreads);
} }
/* /*
@ -471,9 +471,7 @@ reaper(void *arg)
if (p->p_flag & P_THREAD) { if (p->p_flag & P_THREAD) {
/* Just a thread */ /* Just a thread */
KERNEL_LOCK();
proc_free(p); proc_free(p);
KERNEL_UNLOCK();
} else { } else {
struct process *pr = p->p_p; struct process *pr = p->p_p;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_fork.c,v 1.262 2024/08/11 15:10:53 mvs Exp $ */ /* $OpenBSD: kern_fork.c,v 1.263 2024/08/16 16:19:03 mpi Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/* /*
@ -65,7 +65,7 @@
#include <machine/tcb.h> #include <machine/tcb.h>
int nprocesses = 1; /* process 0 */ int nprocesses = 1; /* process 0 */
int nthreads = 1; /* proc 0 */ int nthreads = 1; /* [a] proc 0 */
struct forkstat forkstat; struct forkstat forkstat;
void fork_return(void *); void fork_return(void *);
@ -307,6 +307,8 @@ struct timeval fork_tfmrate = { 10, 0 };
int int
fork_check_maxthread(uid_t uid) fork_check_maxthread(uid_t uid)
{ {
int val;
/* /*
* Although process entries are dynamically created, we still keep * Although process entries are dynamically created, we still keep
* a global limit on the maximum number we will create. We reserve * a global limit on the maximum number we will create. We reserve
@ -316,14 +318,15 @@ fork_check_maxthread(uid_t uid)
* the variable nthreads is the current number of procs, maxthread is * the variable nthreads is the current number of procs, maxthread is
* the limit. * the limit.
*/ */
if ((nthreads >= maxthread - 5 && uid != 0) || nthreads >= maxthread) { val = atomic_inc_int_nv(&nthreads);
if ((val > maxthread - 5 && uid != 0) || val > maxthread) {
static struct timeval lasttfm; static struct timeval lasttfm;
if (ratecheck(&lasttfm, &fork_tfmrate)) if (ratecheck(&lasttfm, &fork_tfmrate))
tablefull("thread"); tablefull("thread");
atomic_dec_int(&nthreads);
return EAGAIN; return EAGAIN;
} }
nthreads++;
return 0; return 0;
} }
@ -369,7 +372,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg,
if (ratecheck(&lasttfm, &fork_tfmrate)) if (ratecheck(&lasttfm, &fork_tfmrate))
tablefull("process"); tablefull("process");
nthreads--; atomic_dec_int(&nthreads);
return EAGAIN; return EAGAIN;
} }
nprocesses++; nprocesses++;
@ -382,7 +385,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg,
if (uid != 0 && count > lim_cur(RLIMIT_NPROC)) { if (uid != 0 && count > lim_cur(RLIMIT_NPROC)) {
(void)chgproccnt(uid, -1); (void)chgproccnt(uid, -1);
nprocesses--; nprocesses--;
nthreads--; atomic_dec_int(&nthreads);
return EAGAIN; return EAGAIN;
} }
@ -390,7 +393,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg,
if (uaddr == 0) { if (uaddr == 0) {
(void)chgproccnt(uid, -1); (void)chgproccnt(uid, -1);
nprocesses--; nprocesses--;
nthreads--; atomic_dec_int(&nthreads);
return (ENOMEM); return (ENOMEM);
} }
@ -547,7 +550,7 @@ thread_fork(struct proc *curp, void *stack, void *tcb, pid_t *tidptr,
uaddr = uvm_uarea_alloc(); uaddr = uvm_uarea_alloc();
if (uaddr == 0) { if (uaddr == 0) {
nthreads--; atomic_dec_int(&nthreads);
return ENOMEM; return ENOMEM;
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_domain.c,v 1.67 2024/08/14 17:52:47 mvs Exp $ */ /* $OpenBSD: uipc_domain.c,v 1.68 2024/08/16 09:20:34 mvs Exp $ */
/* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */ /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
/* /*
@ -237,14 +237,18 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
protocol = name[1]; protocol = name[1];
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_protocol == protocol && pr->pr_sysctl) { if (pr->pr_protocol == protocol && pr->pr_sysctl) {
size_t savelen = *oldlenp; size_t savelen;
int error; int error;
if ((error = sysctl_vslock(oldp, savelen))) if ((pr->pr_flags & PR_MPSYSCTL) == 0) {
return (error); savelen = *oldlenp;
if ((error = sysctl_vslock(oldp, savelen)))
return (error);
}
error = (*pr->pr_sysctl)(name + 2, namelen - 2, error = (*pr->pr_sysctl)(name + 2, namelen - 2,
oldp, oldlenp, newp, newlen); oldp, oldlenp, newp, newlen);
sysctl_vsunlock(oldp, savelen); if ((pr->pr_flags & PR_MPSYSCTL) == 0)
sysctl_vsunlock(oldp, savelen);
return (error); return (error);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ppp_tty.c,v 1.54 2022/01/02 22:36:04 jsg Exp $ */ /* $OpenBSD: ppp_tty.c,v 1.55 2024/08/17 09:52:11 denis Exp $ */
/* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */ /* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */
/* /*
@ -371,6 +371,7 @@ pppwrite(struct tty *tp, struct uio *uio, int flag)
bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN); bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN);
m0->m_data += PPP_HDRLEN; m0->m_data += PPP_HDRLEN;
m0->m_len -= PPP_HDRLEN; m0->m_len -= PPP_HDRLEN;
m0->m_pkthdr.ph_rtableid = sc->sc_if.if_rdomain;
return sc->sc_if.if_output(&sc->sc_if, m0, &dst, NULL); return sc->sc_if.if_output(&sc->sc_if, m0, &dst, NULL);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_proto.c,v 1.107 2024/07/26 14:38:20 bluhm Exp $ */ /* $OpenBSD: in_proto.c,v 1.108 2024/08/16 09:20:35 mvs Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/* /*
@ -354,7 +354,7 @@ const struct protosw inetsw[] = {
.pr_type = SOCK_RAW, .pr_type = SOCK_RAW,
.pr_domain = &inetdomain, .pr_domain = &inetdomain,
.pr_protocol = IPPROTO_DIVERT, .pr_protocol = IPPROTO_DIVERT,
.pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET, .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL,
.pr_ctloutput = rip_ctloutput, .pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &divert_usrreqs, .pr_usrreqs = &divert_usrreqs,
.pr_init = divert_init, .pr_init = divert_init,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */ /* $OpenBSD: ip_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */
/* /*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@ -41,17 +41,22 @@
#include <net/pfvar.h> #include <net/pfvar.h>
/*
* Locks used to protect data:
* a atomic
*/
struct inpcbtable divbtable; struct inpcbtable divbtable;
struct cpumem *divcounters; struct cpumem *divcounters;
#ifndef DIVERT_SENDSPACE #ifndef DIVERT_SENDSPACE
#define DIVERT_SENDSPACE (65536 + 100) #define DIVERT_SENDSPACE (65536 + 100)
#endif #endif
u_int divert_sendspace = DIVERT_SENDSPACE; u_int divert_sendspace = DIVERT_SENDSPACE; /* [a] */
#ifndef DIVERT_RECVSPACE #ifndef DIVERT_RECVSPACE
#define DIVERT_RECVSPACE (65536 + 100) #define DIVERT_RECVSPACE (65536 + 100)
#endif #endif
u_int divert_recvspace = DIVERT_RECVSPACE; u_int divert_recvspace = DIVERT_RECVSPACE; /* [a] */
#ifndef DIVERTHASHSIZE #ifndef DIVERTHASHSIZE
#define DIVERTHASHSIZE 128 #define DIVERTHASHSIZE 128
@ -271,7 +276,8 @@ divert_attach(struct socket *so, int proto, int wait)
if (error) if (error)
return error; return error;
error = soreserve(so, divert_sendspace, divert_recvspace); error = soreserve(so, atomic_load_int(&divert_sendspace),
atomic_load_int(&divert_recvspace));
if (error) if (error)
return error; return error;
@ -346,8 +352,6 @@ int
divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen) size_t newlen)
{ {
int error;
/* All sysctl names at this level are terminal. */ /* All sysctl names at this level are terminal. */
if (namelen != 1) if (namelen != 1)
return (ENOTDIR); return (ENOTDIR);
@ -356,12 +360,9 @@ divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
case DIVERTCTL_STATS: case DIVERTCTL_STATS:
return (divert_sysctl_divstat(oldp, oldlenp, newp)); return (divert_sysctl_divstat(oldp, oldlenp, newp));
default: default:
NET_LOCK(); return (sysctl_bounded_arr(divertctl_vars,
error = sysctl_bounded_arr(divertctl_vars, nitems(divertctl_vars), name, namelen, oldp, oldlenp,
nitems(divertctl_vars), name, namelen, oldp, oldlenp, newp, newp, newlen));
newlen);
NET_UNLOCK();
return (error);
} }
/* NOTREACHED */ /* NOTREACHED */
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in6_proto.c,v 1.117 2024/07/26 14:38:20 bluhm Exp $ */ /* $OpenBSD: in6_proto.c,v 1.118 2024/08/16 09:20:35 mvs Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/* /*
@ -289,7 +289,7 @@ const struct protosw inet6sw[] = {
.pr_type = SOCK_RAW, .pr_type = SOCK_RAW,
.pr_domain = &inet6domain, .pr_domain = &inet6domain,
.pr_protocol = IPPROTO_DIVERT, .pr_protocol = IPPROTO_DIVERT,
.pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET, .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL,
.pr_ctloutput = rip6_ctloutput, .pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &divert6_usrreqs, .pr_usrreqs = &divert6_usrreqs,
.pr_init = divert6_init, .pr_init = divert6_init,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */ /* $OpenBSD: ip6_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */
/* /*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@ -44,17 +44,22 @@
#include <net/pfvar.h> #include <net/pfvar.h>
/*
* Locks used to protect data:
* a atomic
*/
struct inpcbtable divb6table; struct inpcbtable divb6table;
struct cpumem *div6counters; struct cpumem *div6counters;
#ifndef DIVERT_SENDSPACE #ifndef DIVERT_SENDSPACE
#define DIVERT_SENDSPACE (65536 + 100) #define DIVERT_SENDSPACE (65536 + 100)
#endif #endif
u_int divert6_sendspace = DIVERT_SENDSPACE; u_int divert6_sendspace = DIVERT_SENDSPACE; /* [a] */
#ifndef DIVERT_RECVSPACE #ifndef DIVERT_RECVSPACE
#define DIVERT_RECVSPACE (65536 + 100) #define DIVERT_RECVSPACE (65536 + 100)
#endif #endif
u_int divert6_recvspace = DIVERT_RECVSPACE; u_int divert6_recvspace = DIVERT_RECVSPACE; /* [a] */
#ifndef DIVERTHASHSIZE #ifndef DIVERTHASHSIZE
#define DIVERTHASHSIZE 128 #define DIVERTHASHSIZE 128
@ -279,7 +284,8 @@ divert6_attach(struct socket *so, int proto, int wait)
if (error) if (error)
return (error); return (error);
error = soreserve(so, divert6_sendspace, divert6_recvspace); error = soreserve(so, atomic_load_int(&divert6_sendspace),
atomic_load_int(&divert6_recvspace));
if (error) if (error)
return (error); return (error);
@ -322,8 +328,6 @@ int
divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
void *newp, size_t newlen) void *newp, size_t newlen)
{ {
int error;
/* All sysctl names at this level are terminal. */ /* All sysctl names at this level are terminal. */
if (namelen != 1) if (namelen != 1)
return (ENOTDIR); return (ENOTDIR);
@ -332,12 +336,9 @@ divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
case DIVERT6CTL_STATS: case DIVERT6CTL_STATS:
return (divert6_sysctl_div6stat(oldp, oldlenp, newp)); return (divert6_sysctl_div6stat(oldp, oldlenp, newp));
default: default:
NET_LOCK(); return (sysctl_bounded_arr(divert6ctl_vars,
error = sysctl_bounded_arr(divert6ctl_vars,
nitems(divert6ctl_vars), name, namelen, oldp, oldlenp, nitems(divert6ctl_vars), name, namelen, oldp, oldlenp,
newp, newlen); newp, newlen));
NET_UNLOCK();
return (error);
} }
/* NOTREACHED */ /* NOTREACHED */
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nfs_serv.c,v 1.126 2024/05/01 13:15:59 jsg Exp $ */ /* $OpenBSD: nfs_serv.c,v 1.127 2024/08/17 07:02:13 jsg Exp $ */
/* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */
/* /*
@ -1038,12 +1038,12 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0; return 0;
else if (error != 0) else if (error != 0)
goto nfsmout; return error;
fhp = &nfh.fh_generic; fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0) if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout; return error;
if (nfsm_srvnamesiz(&info, &len) != 0) if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout; return error;
if (error) { if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0; return 0;
@ -1325,12 +1325,12 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0; return 0;
else if (error != 0) else if (error != 0)
goto nfsmout; return error;
fhp = &nfh.fh_generic; fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0) if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout; return error;
if (nfsm_srvnamesiz(&info, &len) != 0) if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout; return error;
if (error) { if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0; return 0;
@ -1598,12 +1598,12 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0; return 0;
else if (error != 0) else if (error != 0)
goto nfsmout; return error;
ffhp = &fnfh.fh_generic; ffhp = &fnfh.fh_generic;
if (nfsm_srvmtofh2(&info, ffhp) != 0) if (nfsm_srvmtofh2(&info, ffhp) != 0)
goto nfsmout; return error;
if (nfsm_srvnamesiz(&info, &len) != 0) if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout; return error;
if (error) { if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0; return 0;
@ -1757,12 +1757,6 @@ out1:
nfsmout: nfsmout:
if (fdirp) if (fdirp)
vrele(fdirp); vrele(fdirp);
if (tdirp)
vrele(tdirp);
if (tond.ni_cnd.cn_nameiop) {
vrele(tond.ni_startdir);
pool_put(&namei_pool, tond.ni_cnd.cn_pnbuf);
}
if (fromnd.ni_cnd.cn_nameiop) { if (fromnd.ni_cnd.cn_nameiop) {
if (fromnd.ni_startdir) if (fromnd.ni_startdir)
vrele(fromnd.ni_startdir); vrele(fromnd.ni_startdir);
@ -1928,12 +1922,12 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0; return 0;
else if (error != 0) else if (error != 0)
goto nfsmout; return error;
fhp = &nfh.fh_generic; fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0) if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout; return error;
if (nfsm_srvnamesiz(&info, &len) != 0) if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout; return error;
if (error) { if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0; return 0;
@ -2088,12 +2082,12 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0; return 0;
else if (error != 0) else if (error != 0)
goto nfsmout; return error;
fhp = &nfh.fh_generic; fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0) if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout; return error;
if (nfsm_srvnamesiz(&info, &len) != 0) if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout; return error;
if (error) { if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0; return 0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: protosw.h,v 1.67 2024/07/12 19:50:35 bluhm Exp $ */ /* $OpenBSD: protosw.h,v 1.68 2024/08/16 09:20:35 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*- /*-
@ -131,6 +131,7 @@ struct protosw {
#define PR_SPLICE 0x0040 /* socket splicing is possible */ #define PR_SPLICE 0x0040 /* socket splicing is possible */
#define PR_MPINPUT 0x0080 /* input runs with shared netlock */ #define PR_MPINPUT 0x0080 /* input runs with shared netlock */
#define PR_MPSOCKET 0x0100 /* socket uses shared netlock */ #define PR_MPSOCKET 0x0100 /* socket uses shared netlock */
#define PR_MPSYSCTL 0x0200 /* mp-safe sysctl(2) handler */
/* /*
* The arguments to usrreq are: * The arguments to usrreq are:

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: login.1,v 1.33 2020/02/08 01:09:58 jsg Exp $ .\" $OpenBSD: login.1,v 1.34 2024/08/16 16:11:06 florian Exp $
.\" .\"
.\" Copyright (c) 1980, 1990, 1993 .\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\" .\"
.\" @(#)login.1 8.2 (Berkeley) 5/5/94 .\" @(#)login.1 8.2 (Berkeley) 5/5/94
.\" .\"
.Dd $Mdocdate: February 8 2020 $ .Dd $Mdocdate: August 16 2024 $
.Dt LOGIN 1 .Dt LOGIN 1
.Os .Os
.Sh NAME .Sh NAME
@ -228,7 +228,6 @@ makes login quieter
.Xr chpass 1 , .Xr chpass 1 ,
.Xr passwd 1 , .Xr passwd 1 ,
.Xr su 1 , .Xr su 1 ,
.Xr telnet 1 ,
.Xr readpassphrase 3 , .Xr readpassphrase 3 ,
.Xr setusercontext 3 , .Xr setusercontext 3 ,
.Xr fbtab 5 , .Xr fbtab 5 ,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rpcinfo.c,v 1.18 2024/08/12 06:19:24 florian Exp $ */ /* $OpenBSD: rpcinfo.c,v 1.19 2024/08/16 16:00:30 florian Exp $ */
/* /*
* Copyright (c) 2010, Oracle America, Inc. * Copyright (c) 2010, Oracle America, Inc.
@ -50,6 +50,7 @@
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <err.h>
#define MAXHOSTLEN 256 #define MAXHOSTLEN 256
@ -94,6 +95,15 @@ main(int argc, char *argv[])
function = NONE; function = NONE;
portnum = 0; portnum = 0;
errflg = 0; errflg = 0;
if (unveil("/etc/rpc", "r") == -1)
err(1, "unveil /");
if (unveil(NULL, NULL) == -1)
err(1, "unveil");
if (pledge("stdio inet dns rpath", NULL) == -1)
err(1, "pledge");
while ((c = getopt(argc, argv, "ptubdsn:")) != -1) { while ((c = getopt(argc, argv, "ptubdsn:")) != -1) {
switch (c) { switch (c) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: servconf.c,v 1.412 2024/07/25 23:44:01 djm Exp $ */ /* $OpenBSD: servconf.c,v 1.413 2024/08/17 08:23:04 djm 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
@ -1857,6 +1857,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
xasprintf(&options->subsystem_args[options->num_subsystems], xasprintf(&options->subsystem_args[options->num_subsystems],
"%s%s%s", arg, *arg2 == '\0' ? "" : " ", arg2); "%s%s%s", arg, *arg2 == '\0' ? "" : " ", arg2);
free(arg2); free(arg2);
free(arg);
argv_consume(&ac); argv_consume(&ac);
options->num_subsystems++; options->num_subsystems++;
break; break;

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: ssh-keygen.1,v 1.232 2024/06/17 13:50:18 naddy Exp $ .\" $OpenBSD: ssh-keygen.1,v 1.233 2024/08/17 08:35:04 djm Exp $
.\" .\"
.\" Author: Tatu Ylonen <ylo@cs.hut.fi> .\" Author: Tatu Ylonen <ylo@cs.hut.fi>
.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -35,7 +35,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: June 17 2024 $ .Dd $Mdocdate: August 17 2024 $
.Dt SSH-KEYGEN 1 .Dt SSH-KEYGEN 1
.Os .Os
.Sh NAME .Sh NAME
@ -581,7 +581,7 @@ Specifies the type of key to create.
The possible values are The possible values are
.Dq ecdsa , .Dq ecdsa ,
.Dq ecdsa-sk , .Dq ecdsa-sk ,
.Dq ed25519 , .Dq ed25519 (the default),
.Dq ed25519-sk , .Dq ed25519-sk ,
or or
.Dq rsa . .Dq rsa .
@ -594,7 +594,7 @@ The available RSA signature variants are
.Dq rsa-sha2-256 , .Dq rsa-sha2-256 ,
and and
.Dq rsa-sha2-512 .Dq rsa-sha2-512
(the default). (the default for RSA keys).
.It Fl U .It Fl U
When used in combination with When used in combination with
.Fl s .Fl s

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshd.c,v 1.609 2024/06/27 23:01:15 djm Exp $ */ /* $OpenBSD: sshd.c,v 1.610 2024/08/17 08:09:50 djm Exp $ */
/* /*
* Copyright (c) 2000, 2001, 2002 Markus Friedl. All rights reserved. * Copyright (c) 2000, 2001, 2002 Markus Friedl. All rights reserved.
* Copyright (c) 2002 Niels Provos. All rights reserved. * Copyright (c) 2002 Niels Provos. All rights reserved.
@ -241,7 +241,7 @@ child_register(int pipefd, int sockfd)
} else { } else {
laddr = get_local_ipaddr(sockfd); laddr = get_local_ipaddr(sockfd);
raddr = get_peer_ipaddr(sockfd); raddr = get_peer_ipaddr(sockfd);
xasprintf(&child->id, "connection from %s to %s", laddr, raddr); xasprintf(&child->id, "connection from %s to %s", raddr, laddr);
} }
free(laddr); free(laddr);
free(raddr); free(raddr);

View file

@ -153,8 +153,7 @@ default is 100.
.B \-P\fI pidfile .B \-P\fI pidfile
Use the specified Use the specified
.I pidfile .I pidfile
instead of the platform specific default, which is mostly instead of the platform specific default.
.IR @pidfile@ .
If a If a
.B zonesdir: .B zonesdir:
is specified in the config file, this path can be relative to that is specified in the config file, this path can be relative to that
@ -214,9 +213,6 @@ SIGUSR1
Dump BIND8\-style statistics into the log. Ignored otherwise. Dump BIND8\-style statistics into the log. Ignored otherwise.
.SH "FILES" .SH "FILES"
.TP .TP
@pidfile@
the process id of the name server.
.TP
@nsdconfigfile@ @nsdconfigfile@
default default
.B NSD .B NSD

View file

@ -40,9 +40,6 @@ zonelistfile: @zonelistfile@
logfile: @logfile@ logfile: @logfile@
.RE .RE
.RS 5 .RS 5
pidfile: @pidfile@
.RE
.RS 5
xfrdfile: @xfrdfile@ xfrdfile: @xfrdfile@
.RE .RE
.TP .TP
@ -321,8 +318,7 @@ Preferred EDNS buffer size for IPv4. Default 1232.
Preferred EDNS buffer size for IPv6. Default 1232. Preferred EDNS buffer size for IPv6. Default 1232.
.TP .TP
.B pidfile:\fR <filename> .B pidfile:\fR <filename>
Use the pid file instead of the platform specific default, usually Use the pid file instead of the platform specific default.
.IR @pidfile@.
Same as command-line option Same as command-line option
.BR \-P . .BR \-P .
With "" there is no pidfile, for some startup management setups, With "" there is no pidfile, for some startup management setups,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: chat.c,v 1.37 2024/08/10 05:32:28 jsg Exp $ */ /* $OpenBSD: chat.c,v 1.38 2024/08/17 15:42:20 denis Exp $ */
/* /*
* Chat -- a program for automatic session establishment (i.e. dial * Chat -- a program for automatic session establishment (i.e. dial
@ -172,7 +172,6 @@ int clear_report_next = 0;
int say_next = 0, hup_next = 0; int say_next = 0, hup_next = 0;
void *dup_mem(void *b, size_t c);
void usage(void); void usage(void);
void logmsg(const char *fmt, ...); void logmsg(const char *fmt, ...);
void fatal(int code, const char *fmt, ...); void fatal(int code, const char *fmt, ...);
@ -204,22 +203,6 @@ int vfmtmsg(char *, int, const char *, va_list); /* vsnprintf++ */
int main(int, char *[]); int main(int, char *[]);
void *
dup_mem(void *b, size_t c)
{
void *ans = malloc (c);
if (!ans)
fatal(2, "memory error!");
memcpy (ans, b, c);
return ans;
}
void *copy_of (char *s)
{
return dup_mem (s, strlen (s) + 1);
}
/* /*
* chat [ -v ] [-T number] [-U number] [ -t timeout ] [ -f chat-file ] \ * chat [ -v ] [-T number] [-U number] [ -t timeout ] [ -f chat-file ] \
* [ -r report-file ] \ * [ -r report-file ] \
@ -257,7 +240,8 @@ main(int argc, char **argv)
break; break;
case 'f': case 'f':
chat_file = strdup(optarg); if ((chat_file = strdup(optarg)) == NULL)
fatal(2, "memory error!");
break; break;
case 't': case 't':
@ -267,7 +251,8 @@ main(int argc, char **argv)
case 'r': case 'r':
if (report_fp != NULL) if (report_fp != NULL)
fclose (report_fp); fclose (report_fp);
report_file = copy_of (optarg); if ((report_file = strdup(optarg)) == NULL)
fatal(2, "memory error!");
report_fp = fopen (report_file, "a"); report_fp = fopen (report_file, "a");
if (report_fp != NULL) { if (report_fp != NULL) {
if (verbose) if (verbose)
@ -278,11 +263,14 @@ main(int argc, char **argv)
break; break;
case 'T': case 'T':
phone_num = strdup(optarg); if ((phone_num = strdup(optarg)) == NULL)
fatal(2, "memory error!");
break; break;
case 'U': case 'U':
phone_num2 = strdup(optarg); phone_num2 = strdup(optarg);
if ((phone_num2 = strdup(optarg)) == NULL)
fatal(2, "memory error!");
break; break;
case ':': case ':':

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sys-bsd.c,v 1.35 2024/08/10 05:32:28 jsg Exp $ */ /* $OpenBSD: sys-bsd.c,v 1.36 2024/08/17 09:52:11 denis Exp $ */
/* /*
* sys-bsd.c - System-dependent procedures for setting up * sys-bsd.c - System-dependent procedures for setting up
@ -1031,6 +1031,23 @@ cifaddr(int u, u_int32_t o, u_int32_t h)
return 1; return 1;
} }
/*
* getrtableid - return routing table id of ppp interface
*/
int
getrtableid(void)
{
struct ifreq ifr;
int tableid = 0;
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFRDOMAIN, (caddr_t) &ifr) == 0)
tableid = ifr.ifr_rdomainid;
return tableid;
}
/* /*
* sifdefaultroute - assign a default route through the address given. * sifdefaultroute - assign a default route through the address given.
*/ */
@ -1073,6 +1090,7 @@ dodefaultroute(u_int32_t g, int cmd)
rtmsg.hdr.rtm_type = cmd == 's'? RTM_ADD: RTM_DELETE; rtmsg.hdr.rtm_type = cmd == 's'? RTM_ADD: RTM_DELETE;
rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY; rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY;
rtmsg.hdr.rtm_version = RTM_VERSION; rtmsg.hdr.rtm_version = RTM_VERSION;
rtmsg.hdr.rtm_tableid = getrtableid();
rtmsg.hdr.rtm_seq = ++rtm_seq; rtmsg.hdr.rtm_seq = ++rtm_seq;
rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
rtmsg.dst.sin_len = sizeof(rtmsg.dst); rtmsg.dst.sin_len = sizeof(rtmsg.dst);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: radiusd_eap2mschap.c,v 1.2 2024/07/17 11:19:27 yasuoka Exp $ */ /* $OpenBSD: radiusd_eap2mschap.c,v 1.3 2024/08/16 09:52:16 yasuoka Exp $ */
/* /*
* Copyright (c) 2024 Internet Initiative Japan Inc. * Copyright (c) 2024 Internet Initiative Japan Inc.
@ -74,8 +74,12 @@ main(int argc, char *argv[])
module_start(eap2mschap.base); module_start(eap2mschap.base);
event_loop(0); event_loop(0);
module_destroy(eap2mschap.base); module_destroy(eap2mschap.base);
event_loop(0);
event_base_free(NULL);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -140,10 +144,14 @@ eap2mschap_stop(void *ctx)
evtimer_del(&self->ev_eapt); evtimer_del(&self->ev_eapt);
RB_FOREACH_SAFE(req, access_reqt, &self->eapt, reqt) RB_FOREACH_SAFE(req, access_reqt, &self->eapt, reqt) {
RB_REMOVE(access_reqt, &self->eapt, req);
access_request_free(req); access_request_free(req);
TAILQ_FOREACH_SAFE(req, &self->reqq, next, reqt) }
TAILQ_FOREACH_SAFE(req, &self->reqq, next, reqt) {
TAILQ_REMOVE(&self->reqq, req, next);
access_request_free(req); access_request_free(req);
}
} }
void void

View file

@ -1,4 +1,4 @@
/* $OpenBSD: radiusd_ipcp.c,v 1.9 2024/08/14 04:47:08 yasuoka Exp $ */ /* $OpenBSD: radiusd_ipcp.c,v 1.12 2024/08/16 09:54:21 yasuoka Exp $ */
/* /*
* Copyright (c) 2024 Internet Initiative Japan Inc. * Copyright (c) 2024 Internet Initiative Japan Inc.
@ -191,6 +191,7 @@ static void ipcp_put_db(struct module_ipcp *, struct assigned_ipv4 *);
static void ipcp_del_db(struct module_ipcp *, struct assigned_ipv4 *); static void ipcp_del_db(struct module_ipcp *, struct assigned_ipv4 *);
static void ipcp_db_dump_fill_record(struct radiusd_ipcp_db_dump *, int, static void ipcp_db_dump_fill_record(struct radiusd_ipcp_db_dump *, int,
struct assigned_ipv4 *); struct assigned_ipv4 *);
static void ipcp_update_time(struct module_ipcp *);
static void ipcp_on_timer(int, short, void *); static void ipcp_on_timer(int, short, void *);
static void ipcp_schedule_timer(struct module_ipcp *); static void ipcp_schedule_timer(struct module_ipcp *);
static void ipcp_dae_send_disconnect_request(struct assigned_ipv4 *); static void ipcp_dae_send_disconnect_request(struct assigned_ipv4 *);
@ -252,6 +253,7 @@ main(int argc, char *argv[])
ipcp_fini(&module_ipcp); ipcp_fini(&module_ipcp);
event_loop(0); event_loop(0);
event_base_free(NULL);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -267,6 +269,7 @@ ipcp_init(struct module_ipcp *self)
TAILQ_INIT(&self->daes); TAILQ_INIT(&self->daes);
self->seq = 1; self->seq = 1;
self->no_session_timeout = true; self->no_session_timeout = true;
ipcp_update_time(self);
} }
void void
@ -277,6 +280,7 @@ ipcp_start(void *ctx)
struct module_ipcp_dae *dae; struct module_ipcp_dae *dae;
int sock; int sock;
ipcp_update_time(self);
if (self->start_wait == 0) if (self->start_wait == 0)
self->start_wait = RADIUSD_IPCP_START_WAIT; self->start_wait = RADIUSD_IPCP_START_WAIT;
@ -322,6 +326,7 @@ ipcp_stop(void *ctx)
struct module_ipcp *self = ctx; struct module_ipcp *self = ctx;
struct module_ipcp_dae *dae; struct module_ipcp_dae *dae;
ipcp_update_time(self);
/* stop the sockets for DAE */ /* stop the sockets for DAE */
TAILQ_FOREACH(dae, &self->daes, next) { TAILQ_FOREACH(dae, &self->daes, next) {
if (dae->sock >= 0) { if (dae->sock >= 0) {
@ -341,11 +346,14 @@ ipcp_fini(struct module_ipcp *self)
struct user *user, *usert; struct user *user, *usert;
struct module_ipcp_ctrlconn *ctrl, *ctrlt; struct module_ipcp_ctrlconn *ctrl, *ctrlt;
struct module_ipcp_dae *dae, *daet; struct module_ipcp_dae *dae, *daet;
struct ipcp_address *addr, *addrt;
RB_FOREACH_SAFE(assign, assigned_ipv4_tree, &self->ipv4s, assignt) RB_FOREACH_SAFE(assign, assigned_ipv4_tree, &self->ipv4s, assignt)
ipcp_ipv4_release(self, assign); ipcp_ipv4_release(self, assign);
RB_FOREACH_SAFE(user, user_tree, &self->users, usert) RB_FOREACH_SAFE(user, user_tree, &self->users, usert) {
RB_REMOVE(user_tree, &self->users, user);
free(user); free(user);
}
TAILQ_FOREACH_SAFE(ctrl, &self->ctrls, next, ctrlt) TAILQ_FOREACH_SAFE(ctrl, &self->ctrls, next, ctrlt)
free(ctrl); free(ctrl);
TAILQ_FOREACH_SAFE(dae, &self->daes, next, daet) { TAILQ_FOREACH_SAFE(dae, &self->daes, next, daet) {
@ -355,6 +363,8 @@ ipcp_fini(struct module_ipcp *self)
} }
free(dae); free(dae);
} }
TAILQ_FOREACH_SAFE(addr, &self->addrs, next, addrt)
free(addr);
if (evtimer_pending(&self->ev_timer, NULL)) if (evtimer_pending(&self->ev_timer, NULL))
evtimer_del(&self->ev_timer); evtimer_del(&self->ev_timer);
module_destroy(self->base); module_destroy(self->base);
@ -556,6 +566,7 @@ ipcp_dispatch_control(void *ctx, struct imsg *imsg)
struct radiusctl_client *client; struct radiusctl_client *client;
const char *cause; const char *cause;
ipcp_update_time(self);
datalen = imsg->hdr.len - IMSG_HEADER_SIZE; datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
switch (imsg->hdr.type) { switch (imsg->hdr.type) {
case IMSG_RADIUSD_MODULE_CTRL_UNBIND: case IMSG_RADIUSD_MODULE_CTRL_UNBIND:
@ -711,7 +722,7 @@ ipcp_resdeco(void *ctx, u_int q_id, const u_char *req, size_t reqlen,
struct user *user = NULL; struct user *user = NULL;
struct assigned_ipv4 *assigned = NULL, *assign; struct assigned_ipv4 *assigned = NULL, *assign;
clock_gettime(CLOCK_BOOTTIME, &self->uptime); ipcp_update_time(self);
if ((radres = radius_convert_packet(res, reslen)) == NULL) { if ((radres = radius_convert_packet(res, reslen)) == NULL) {
log_warn("%s: radius_convert_packet() failed", __func__); log_warn("%s: radius_convert_packet() failed", __func__);
@ -1002,7 +1013,7 @@ ipcp_accounting_request(void *ctx, u_int q_id, const u_char *pkt,
stat; stat;
struct module_ipcp_dae *dae; struct module_ipcp_dae *dae;
clock_gettime(CLOCK_BOOTTIME, &self->uptime); ipcp_update_time(self);
if ((radpkt = radius_convert_packet(pkt, pktlen)) == NULL) { if ((radpkt = radius_convert_packet(pkt, pktlen)) == NULL) {
log_warn("%s: radius_convert_packet() failed", __func__); log_warn("%s: radius_convert_packet() failed", __func__);
@ -1466,12 +1477,18 @@ ipcp_db_dump_fill_record(struct radiusd_ipcp_db_dump *dump, int idx,
/*********************************************************************** /***********************************************************************
* Timer * Timer
***********************************************************************/ ***********************************************************************/
void
ipcp_update_time(struct module_ipcp *self)
{
clock_gettime(CLOCK_BOOTTIME, &self->uptime);
}
void void
ipcp_on_timer(int fd, short ev, void *ctx) ipcp_on_timer(int fd, short ev, void *ctx)
{ {
struct module_ipcp *self = ctx; struct module_ipcp *self = ctx;
clock_gettime(CLOCK_BOOTTIME, &self->uptime); ipcp_update_time(self);
ipcp_schedule_timer(self); ipcp_schedule_timer(self);
} }
@ -1573,11 +1590,15 @@ ipcp_dae_request_on_timeout(int fd, short ev, void *ctx)
{ {
struct assigned_ipv4 *assign = ctx; struct assigned_ipv4 *assign = ctx;
char buf[80]; char buf[80];
struct radiusctl_client *client;
if (assign->dae_ntry >= (int)nitems(dae_request_timeouts)) { if (assign->dae_ntry >= (int)nitems(dae_request_timeouts)) {
log_warnx("No answer for Disconnect-Request seq=%u from %s", log_warnx("No answer for Disconnect-Request seq=%u from %s",
assign->seq, print_addr((struct sockaddr *) assign->seq, print_addr((struct sockaddr *)
&assign->dae->nas_addr, buf, sizeof(buf))); &assign->dae->nas_addr, buf, sizeof(buf)));
TAILQ_FOREACH(client, &assign->dae_clients, entry)
module_imsg_compose(assign->dae->ipcp->base, IMSG_NG,
client->peerid, 0, -1, NULL, 0);
ipcp_dae_reset_request(assign); ipcp_dae_reset_request(assign);
} else } else
ipcp_dae_send_disconnect_request(assign); ipcp_dae_send_disconnect_request(assign);
@ -1596,6 +1617,8 @@ ipcp_dae_on_event(int fd, short ev, void *ctx)
const char *cause = ""; const char *cause = "";
struct radiusctl_client *client; struct radiusctl_client *client;
ipcp_update_time(self);
if ((ev & EV_READ) == 0) if ((ev & EV_READ) == 0)
return; return;
@ -1856,7 +1879,7 @@ radius_error_cause_string(unsigned val)
{ RADIUS_ERROR_CAUSE_UNSUPPORTED_EXTENSION, { RADIUS_ERROR_CAUSE_UNSUPPORTED_EXTENSION,
"Unsupported Extension" }, "Unsupported Extension" },
{ RADIUS_ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE, { RADIUS_ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE,
"Invalid Attribute Valu" }, "Invalid Attribute Value" },
{ RADIUS_ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED, { RADIUS_ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED,
"Administratively Prohibited" }, "Administratively Prohibited" },
{ RADIUS_ERROR_CAUSE_REQUEST_NOT_ROUTABLE, { RADIUS_ERROR_CAUSE_REQUEST_NOT_ROUTABLE,
@ -1930,9 +1953,9 @@ parse_addr(const char *str0, int af, struct sockaddr *sa, socklen_t salen)
free(str); free(str);
return (-1); return (-1);
} }
free(str);
if (salen < ai->ai_addrlen) { if (salen < ai->ai_addrlen) {
freeaddrinfo(ai); freeaddrinfo(ai);
free(str);
return (-1); return (-1);
} }
memcpy(sa, ai->ai_addr, ai->ai_addrlen); memcpy(sa, ai->ai_addr, ai->ai_addrlen);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: radiusd_local.h,v 1.17 2024/08/14 07:04:54 yasuoka Exp $ */ /* $OpenBSD: radiusd_local.h,v 1.18 2024/08/16 09:45:52 yasuoka Exp $ */
/* /*
* Copyright (c) 2013 Internet Initiative Japan Inc. * Copyright (c) 2013 Internet Initiative Japan Inc.
@ -138,7 +138,6 @@ struct radius_query {
struct radiusd_authentication *authen; struct radiusd_authentication *authen;
RADIUS_PACKET *req; RADIUS_PACKET *req;
RADIUS_PACKET *res; RADIUS_PACKET *res;
int req_modified;
char username[256]; /* original username */ char username[256]; /* original username */
TAILQ_ENTRY(radius_query) next; TAILQ_ENTRY(radius_query) next;
struct radiusd_module_ref *deco; struct radiusd_module_ref *deco;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: radiusd_radius.c,v 1.21 2024/07/01 03:17:00 yasuoka Exp $ */ /* $OpenBSD: radiusd_radius.c,v 1.22 2024/08/16 09:52:16 yasuoka Exp $ */
/* /*
* Copyright (c) 2013 Internet Initiative Japan Inc. * Copyright (c) 2013 Internet Initiative Japan Inc.
@ -139,6 +139,7 @@ main(int argc, char *argv[])
event_loop(0); event_loop(0);
module_destroy(module_radius.base); module_destroy(module_radius.base);
event_base_free(NULL);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.78 2024/05/18 06:45:00 jsg Exp $ */ /* $OpenBSD: main.c,v 1.79 2024/08/17 20:50:06 mlarkin Exp $ */
/* /*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@ -743,7 +743,7 @@ ctl_convert(const char *srcfile, const char *dstfile, int dsttype, size_t dstsiz
int int
ctl_status(struct parse_result *res, int argc, char *argv[]) ctl_status(struct parse_result *res, int argc, char *argv[])
{ {
char ch; int ch;
while ((ch = getopt(argc, argv, "r")) != -1) { while ((ch = getopt(argc, argv, "r")) != -1) {
switch (ch) { switch (ch) {