sync
This commit is contained in:
parent
451579e149
commit
a2dd1eda92
89 changed files with 1343 additions and 775 deletions
|
@ -770,7 +770,7 @@
|
|||
./usr/lib/libtermlib.so.14.0
|
||||
./usr/lib/libtls.so.27.0
|
||||
./usr/lib/libusbhid.so.7.1
|
||||
./usr/lib/libutil.so.16.0
|
||||
./usr/lib/libutil.so.17.0
|
||||
./usr/lib/libz.so.7.0
|
||||
./usr/lib/locate
|
||||
./usr/lib/locate/src.db
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: crypto_init.c,v 1.8 2023/05/08 13:53:26 tb Exp $ */
|
||||
/* $OpenBSD: crypto_init.c,v 1.9 2023/06/19 18:32:05 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2018 Bob Beck <beck@openbsd.org>
|
||||
*
|
||||
|
@ -21,7 +21,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <openssl/conf.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
|
@ -79,7 +81,9 @@ OPENSSL_cleanup(void)
|
|||
ERR_free_strings();
|
||||
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE_cleanup();
|
||||
#endif
|
||||
EVP_cleanup();
|
||||
x509_issuer_cache_free();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ec_lib.c,v 1.57 2023/05/04 13:51:59 tb Exp $ */
|
||||
/* $OpenBSD: ec_lib.c,v 1.58 2023/06/20 14:37:15 tb Exp $ */
|
||||
/*
|
||||
* Originally written by Bodo Moeller for the OpenSSL project.
|
||||
*/
|
||||
|
@ -236,7 +236,8 @@ EC_METHOD_get_field_type(const EC_METHOD *meth)
|
|||
}
|
||||
|
||||
/*
|
||||
* Try computing the cofactor from generator order n and field cardinality q.
|
||||
* If there is a user-provided cofactor, sanity check and use it. Otherwise
|
||||
* try computing the cofactor from generator order n and field cardinality q.
|
||||
* This works for all curves of cryptographic interest.
|
||||
*
|
||||
* Hasse's theorem: | h * n - (q + 1) | <= 2 * sqrt(q)
|
||||
|
@ -250,38 +251,43 @@ EC_METHOD_get_field_type(const EC_METHOD *meth)
|
|||
* Otherwise, zero cofactor and return success.
|
||||
*/
|
||||
static int
|
||||
ec_guess_cofactor(EC_GROUP *group)
|
||||
ec_set_cofactor(EC_GROUP *group, const BIGNUM *in_cofactor)
|
||||
{
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *q = NULL;
|
||||
BIGNUM *cofactor;
|
||||
int ret = 0;
|
||||
|
||||
BN_zero(&group->cofactor);
|
||||
|
||||
if ((ctx = BN_CTX_new()) == NULL)
|
||||
goto err;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((cofactor = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* Unfortunately, the cofactor is an optional field in many standards.
|
||||
* Internally, the library uses a 0 cofactor as a marker for "unknown
|
||||
* cofactor". So accept in_cofactor == NULL or in_cofactor >= 0.
|
||||
*/
|
||||
if (in_cofactor != NULL && !BN_is_zero(in_cofactor)) {
|
||||
if (BN_is_negative(in_cofactor)) {
|
||||
ECerror(EC_R_UNKNOWN_COFACTOR);
|
||||
goto err;
|
||||
}
|
||||
if (!bn_copy(cofactor, in_cofactor))
|
||||
goto err;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the cofactor is too large, we cannot guess it and default to zero.
|
||||
* The RHS of below is a strict overestimate of log(4 * sqrt(q)).
|
||||
*/
|
||||
if (BN_num_bits(&group->order) <=
|
||||
(BN_num_bits(&group->field) + 1) / 2 + 3) {
|
||||
BN_zero(&group->cofactor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ctx = BN_CTX_new()) == NULL)
|
||||
goto err;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((q = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
/* Set q = 2**m for binary fields; q = p otherwise. */
|
||||
if (group->meth->field_type == NID_X9_62_characteristic_two_field) {
|
||||
BN_zero(q);
|
||||
if (!BN_set_bit(q, BN_num_bits(&group->field) - 1))
|
||||
goto err;
|
||||
} else {
|
||||
if (!bn_copy(q, &group->field))
|
||||
goto err;
|
||||
}
|
||||
(BN_num_bits(&group->field) + 1) / 2 + 3)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Compute
|
||||
|
@ -289,17 +295,26 @@ ec_guess_cofactor(EC_GROUP *group)
|
|||
*/
|
||||
|
||||
/* h = n/2 */
|
||||
if (!BN_rshift1(&group->cofactor, &group->order))
|
||||
if (!BN_rshift1(cofactor, &group->order))
|
||||
goto err;
|
||||
/* h = 1 + n/2 */
|
||||
if (!BN_add(&group->cofactor, &group->cofactor, BN_value_one()))
|
||||
if (!BN_add_word(cofactor, 1))
|
||||
goto err;
|
||||
/* h = q + 1 + n/2 */
|
||||
if (!BN_add(&group->cofactor, &group->cofactor, q))
|
||||
if (!BN_add(cofactor, cofactor, &group->field))
|
||||
goto err;
|
||||
/* h = (q + 1 + n/2) / n */
|
||||
if (!BN_div_ct(&group->cofactor, NULL, &group->cofactor, &group->order,
|
||||
ctx))
|
||||
if (!BN_div_ct(cofactor, NULL, cofactor, &group->order, ctx))
|
||||
goto err;
|
||||
|
||||
done:
|
||||
/* Use Hasse's theorem to bound the cofactor. */
|
||||
if (BN_num_bits(cofactor) > BN_num_bits(&group->field) + 1) {
|
||||
ECerror(EC_R_INVALID_GROUP_ORDER);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!bn_copy(&group->cofactor, cofactor))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
|
@ -308,9 +323,6 @@ ec_guess_cofactor(EC_GROUP *group)
|
|||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
if (ret != 1)
|
||||
BN_zero(&group->cofactor);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -339,16 +351,6 @@ EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unfortunately, the cofactor is an optional field in many standards.
|
||||
* Internally, the library uses a 0 cofactor as a marker for "unknown
|
||||
* cofactor". So accept cofactor == NULL or cofactor >= 0.
|
||||
*/
|
||||
if (cofactor != NULL && BN_is_negative(cofactor)) {
|
||||
ECerror(EC_R_UNKNOWN_COFACTOR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (group->generator == NULL) {
|
||||
group->generator = EC_POINT_new(group);
|
||||
if (group->generator == NULL)
|
||||
|
@ -360,18 +362,8 @@ EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
|||
if (!bn_copy(&group->order, order))
|
||||
return 0;
|
||||
|
||||
/* Either take the provided positive cofactor, or try to compute it. */
|
||||
if (cofactor != NULL && !BN_is_zero(cofactor)) {
|
||||
if (!bn_copy(&group->cofactor, cofactor))
|
||||
if (!ec_set_cofactor(group, cofactor))
|
||||
return 0;
|
||||
} else if (!ec_guess_cofactor(group))
|
||||
return 0;
|
||||
|
||||
/* Use Hasse's theorem to bound the cofactor. */
|
||||
if (BN_num_bits(&group->cofactor) > BN_num_bits(&group->field) + 1) {
|
||||
ECerror(EC_R_INVALID_GROUP_ORDER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pmeth_lib.c,v 1.27 2022/12/26 07:18:52 jmc Exp $ */
|
||||
/* $OpenBSD: pmeth_lib.c,v 1.31 2023/06/20 14:14:00 tb Exp $ */
|
||||
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project 2006.
|
||||
*/
|
||||
|
@ -151,69 +151,65 @@ EVP_PKEY_meth_find(int type)
|
|||
}
|
||||
|
||||
static EVP_PKEY_CTX *
|
||||
int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
|
||||
evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *engine, int id)
|
||||
{
|
||||
EVP_PKEY_CTX *ret;
|
||||
EVP_PKEY_CTX *pkey_ctx = NULL;
|
||||
const EVP_PKEY_METHOD *pmeth;
|
||||
|
||||
if (id == -1) {
|
||||
if (!pkey || !pkey->ameth)
|
||||
if (pkey == NULL || pkey->ameth == NULL)
|
||||
return NULL;
|
||||
id = pkey->ameth->pkey_id;
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (pkey && pkey->engine)
|
||||
e = pkey->engine;
|
||||
/* Try to find an ENGINE which implements this method */
|
||||
if (e) {
|
||||
if (!ENGINE_init(e)) {
|
||||
if (pkey != NULL && pkey->engine != NULL)
|
||||
engine = pkey->engine;
|
||||
/* Try to find an ENGINE which implements this method. */
|
||||
if (engine != NULL) {
|
||||
if (!ENGINE_init(engine)) {
|
||||
EVPerror(ERR_R_ENGINE_LIB);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
e = ENGINE_get_pkey_meth_engine(id);
|
||||
engine = ENGINE_get_pkey_meth_engine(id);
|
||||
|
||||
/* If an ENGINE handled this method look it up. Otherwise
|
||||
* use internal tables.
|
||||
*/
|
||||
|
||||
if (e)
|
||||
pmeth = ENGINE_get_pkey_meth(e, id);
|
||||
/* Look up method handler in ENGINE or use internal tables. */
|
||||
if (engine != NULL)
|
||||
pmeth = ENGINE_get_pkey_meth(engine, id);
|
||||
else
|
||||
#endif
|
||||
pmeth = EVP_PKEY_meth_find(id);
|
||||
|
||||
if (pmeth == NULL) {
|
||||
EVPerror(EVP_R_UNSUPPORTED_ALGORITHM);
|
||||
return NULL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = malloc(sizeof(EVP_PKEY_CTX));
|
||||
if (ret == NULL) {
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE_finish(e);
|
||||
#endif
|
||||
if ((pkey_ctx = calloc(1, sizeof(*pkey_ctx))) == NULL) {
|
||||
EVPerror(ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
goto err;
|
||||
}
|
||||
ret->engine = e;
|
||||
ret->pmeth = pmeth;
|
||||
ret->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
ret->pkey = pkey;
|
||||
ret->peerkey = NULL;
|
||||
ret->pkey_gencb = 0;
|
||||
if (pkey)
|
||||
CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
|
||||
ret->data = NULL;
|
||||
pkey_ctx->engine = engine;
|
||||
engine = NULL;
|
||||
pkey_ctx->pmeth = pmeth;
|
||||
pkey_ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
if ((pkey_ctx->pkey = pkey) != NULL)
|
||||
EVP_PKEY_up_ref(pkey_ctx->pkey);
|
||||
|
||||
if (pmeth->init) {
|
||||
if (pmeth->init(ret) <= 0) {
|
||||
EVP_PKEY_CTX_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
if (pmeth->init != NULL) {
|
||||
if (pmeth->init(pkey_ctx) <= 0)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return pkey_ctx;
|
||||
|
||||
err:
|
||||
EVP_PKEY_CTX_free(pkey_ctx);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE_finish(engine);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EVP_PKEY_METHOD*
|
||||
|
@ -261,57 +257,54 @@ EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth)
|
|||
}
|
||||
|
||||
EVP_PKEY_CTX *
|
||||
EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e)
|
||||
EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *engine)
|
||||
{
|
||||
return int_ctx_new(pkey, e, -1);
|
||||
return evp_pkey_ctx_new(pkey, engine, -1);
|
||||
}
|
||||
|
||||
EVP_PKEY_CTX *
|
||||
EVP_PKEY_CTX_new_id(int id, ENGINE *e)
|
||||
EVP_PKEY_CTX_new_id(int id, ENGINE *engine)
|
||||
{
|
||||
return int_ctx_new(NULL, e, id);
|
||||
return evp_pkey_ctx_new(NULL, engine, id);
|
||||
}
|
||||
|
||||
EVP_PKEY_CTX *
|
||||
EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
|
||||
{
|
||||
EVP_PKEY_CTX *rctx;
|
||||
EVP_PKEY_CTX *rctx = NULL;
|
||||
|
||||
if (!pctx->pmeth || !pctx->pmeth->copy)
|
||||
return NULL;
|
||||
if (pctx->pmeth == NULL || pctx->pmeth->copy == NULL)
|
||||
goto err;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
/* Make sure it's safe to copy a pkey context using an ENGINE */
|
||||
if (pctx->engine && !ENGINE_init(pctx->engine)) {
|
||||
if (pctx->engine != NULL && !ENGINE_init(pctx->engine)) {
|
||||
EVPerror(ERR_R_ENGINE_LIB);
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
rctx = malloc(sizeof(EVP_PKEY_CTX));
|
||||
if (!rctx)
|
||||
return NULL;
|
||||
if ((rctx = calloc(1, sizeof(*rctx))) == NULL) {
|
||||
EVPerror(ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
rctx->pmeth = pctx->pmeth;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
rctx->engine = pctx->engine;
|
||||
#endif
|
||||
|
||||
if (pctx->pkey)
|
||||
CRYPTO_add(&pctx->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
|
||||
if ((rctx->pkey = pctx->pkey) != NULL)
|
||||
EVP_PKEY_up_ref(rctx->pkey);
|
||||
if ((rctx->peerkey = pctx->peerkey) != NULL)
|
||||
EVP_PKEY_up_ref(rctx->peerkey);
|
||||
|
||||
rctx->pkey = pctx->pkey;
|
||||
|
||||
if (pctx->peerkey)
|
||||
CRYPTO_add(&pctx->peerkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
|
||||
|
||||
rctx->peerkey = pctx->peerkey;
|
||||
|
||||
rctx->data = NULL;
|
||||
rctx->app_data = NULL;
|
||||
rctx->operation = pctx->operation;
|
||||
|
||||
if (pctx->pmeth->copy(rctx, pctx) > 0)
|
||||
if (pctx->pmeth->copy(rctx, pctx) <= 0)
|
||||
goto err;
|
||||
|
||||
return rctx;
|
||||
|
||||
err:
|
||||
EVP_PKEY_CTX_free(rctx);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: x509_purp.c,v 1.25 2023/04/23 21:49:15 job Exp $ */
|
||||
/* $OpenBSD: x509_purp.c,v 1.26 2023/06/20 14:21:19 tb Exp $ */
|
||||
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project 2001.
|
||||
*/
|
||||
|
@ -449,6 +449,7 @@ x509v3_cache_extensions_internal(X509 *x)
|
|||
ASN1_BIT_STRING *ns;
|
||||
EXTENDED_KEY_USAGE *extusage;
|
||||
X509_EXTENSION *ex;
|
||||
long version;
|
||||
int i;
|
||||
|
||||
if (x->ex_flags & EXFLAG_SET)
|
||||
|
@ -456,12 +457,18 @@ x509v3_cache_extensions_internal(X509 *x)
|
|||
|
||||
X509_digest(x, X509_CERT_HASH_EVP, x->hash, NULL);
|
||||
|
||||
/* V1 should mean no extensions ... */
|
||||
if (X509_get_version(x) == 0) {
|
||||
version = X509_get_version(x);
|
||||
if (version < 0 || version > 2)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
if (version == 0) {
|
||||
x->ex_flags |= EXFLAG_V1;
|
||||
if (X509_get_ext_count(x) != 0)
|
||||
/* UIDs may only appear in v2 or v3 certs */
|
||||
if (x->cert_info->issuerUID != NULL ||
|
||||
x->cert_info->subjectUID != NULL)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
}
|
||||
if (version != 2 && X509_get_ext_count(x) != 0)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
|
||||
/* Handle basic constraints */
|
||||
if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &i, NULL))) {
|
||||
|
|
|
@ -18,13 +18,28 @@
|
|||
getptmfd;
|
||||
getrawpartition;
|
||||
ibuf_add;
|
||||
ibuf_add_buf;
|
||||
ibuf_add_n8;
|
||||
ibuf_add_n16;
|
||||
ibuf_add_n32;
|
||||
ibuf_add_n64;
|
||||
ibuf_add_zero;
|
||||
ibuf_close;
|
||||
ibuf_data;
|
||||
ibuf_dynamic;
|
||||
ibuf_fd_avail;
|
||||
ibuf_fd_get;
|
||||
ibuf_fd_set;
|
||||
ibuf_free;
|
||||
ibuf_left;
|
||||
ibuf_open;
|
||||
ibuf_reserve;
|
||||
ibuf_seek;
|
||||
ibuf_set;
|
||||
ibuf_set_n8;
|
||||
ibuf_set_n16;
|
||||
ibuf_set_n32;
|
||||
ibuf_set_n64;
|
||||
ibuf_size;
|
||||
ibuf_write;
|
||||
imsg_add;
|
||||
|
@ -32,6 +47,7 @@
|
|||
imsg_close;
|
||||
imsg_compose;
|
||||
imsg_composev;
|
||||
imsg_compose_ibuf;
|
||||
imsg_create;
|
||||
imsg_fd_overhead;
|
||||
imsg_flush;
|
||||
|
@ -47,7 +63,6 @@
|
|||
logout;
|
||||
logwtmp;
|
||||
msgbuf_clear;
|
||||
msgbuf_drain;
|
||||
msgbuf_init;
|
||||
msgbuf_write;
|
||||
ober_add_bitstring;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: imsg-buffer.c,v 1.15 2023/05/23 12:41:28 claudio Exp $ */
|
||||
/* $OpenBSD: imsg-buffer.c,v 1.16 2023/06/19 17:19:50 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
||||
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <endian.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
@ -32,6 +33,7 @@
|
|||
static int ibuf_realloc(struct ibuf *, size_t);
|
||||
static void ibuf_enqueue(struct msgbuf *, struct ibuf *);
|
||||
static void ibuf_dequeue(struct msgbuf *, struct ibuf *);
|
||||
static void msgbuf_drain(struct msgbuf *, size_t);
|
||||
|
||||
struct ibuf *
|
||||
ibuf_open(size_t len)
|
||||
|
@ -99,23 +101,6 @@ ibuf_realloc(struct ibuf *buf, size_t len)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add(struct ibuf *buf, const void *data, size_t len)
|
||||
{
|
||||
if (len > SIZE_MAX - buf->wpos) {
|
||||
errno = ERANGE;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (buf->wpos + len > buf->size)
|
||||
if (ibuf_realloc(buf, len) == -1)
|
||||
return (-1);
|
||||
|
||||
memcpy(buf->buf + buf->wpos, data, len);
|
||||
buf->wpos += len;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void *
|
||||
ibuf_reserve(struct ibuf *buf, size_t len)
|
||||
{
|
||||
|
@ -136,16 +121,156 @@ ibuf_reserve(struct ibuf *buf, size_t len)
|
|||
return (b);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add(struct ibuf *buf, const void *data, size_t len)
|
||||
{
|
||||
void *b;
|
||||
|
||||
if ((b = ibuf_reserve(buf, len)) == NULL)
|
||||
return (-1);
|
||||
|
||||
memcpy(b, data, len);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add_buf(struct ibuf *buf, const struct ibuf *from)
|
||||
{
|
||||
return ibuf_add(buf, from->buf, from->wpos);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add_n8(struct ibuf *buf, uint64_t value)
|
||||
{
|
||||
uint8_t v;
|
||||
|
||||
if (value > UINT8_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
v = value;
|
||||
return ibuf_add(buf, &v, sizeof(v));
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add_n16(struct ibuf *buf, uint64_t value)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
if (value > UINT16_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
v = htobe16(value);
|
||||
return ibuf_add(buf, &v, sizeof(v));
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add_n32(struct ibuf *buf, uint64_t value)
|
||||
{
|
||||
uint32_t v;
|
||||
|
||||
if (value > UINT32_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
v = htobe32(value);
|
||||
return ibuf_add(buf, &v, sizeof(v));
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add_n64(struct ibuf *buf, uint64_t value)
|
||||
{
|
||||
value = htobe64(value);
|
||||
return ibuf_add(buf, &value, sizeof(value));
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_add_zero(struct ibuf *buf, size_t len)
|
||||
{
|
||||
void *b;
|
||||
|
||||
if ((b = ibuf_reserve(buf, len)) == NULL)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void *
|
||||
ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
|
||||
{
|
||||
/* only allowed to seek in already written parts */
|
||||
if (len > SIZE_MAX - pos || pos + len > buf->wpos)
|
||||
if (len > SIZE_MAX - pos || pos + len > buf->wpos) {
|
||||
errno = ERANGE;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
return (buf->buf + pos);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_set(struct ibuf *buf, size_t pos, const void *data, size_t len)
|
||||
{
|
||||
void *b;
|
||||
|
||||
if ((b = ibuf_seek(buf, pos, len)) == NULL)
|
||||
return (-1);
|
||||
|
||||
memcpy(b, data, len);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_set_n8(struct ibuf *buf, size_t pos, uint64_t value)
|
||||
{
|
||||
uint8_t v;
|
||||
|
||||
if (value > UINT8_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
v = value;
|
||||
return (ibuf_set(buf, pos, &v, sizeof(v)));
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_set_n16(struct ibuf *buf, size_t pos, uint64_t value)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
if (value > UINT16_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
v = htobe16(value);
|
||||
return (ibuf_set(buf, pos, &v, sizeof(v)));
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_set_n32(struct ibuf *buf, size_t pos, uint64_t value)
|
||||
{
|
||||
uint32_t v;
|
||||
|
||||
if (value > UINT32_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
v = htobe32(value);
|
||||
return (ibuf_set(buf, pos, &v, sizeof(v)));
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_set_n64(struct ibuf *buf, size_t pos, uint64_t value)
|
||||
{
|
||||
value = htobe64(value);
|
||||
return (ibuf_set(buf, pos, &value, sizeof(value)));
|
||||
}
|
||||
|
||||
void *
|
||||
ibuf_data(struct ibuf *buf)
|
||||
{
|
||||
return (buf->buf);
|
||||
}
|
||||
|
||||
size_t
|
||||
ibuf_size(struct ibuf *buf)
|
||||
{
|
||||
|
@ -164,6 +289,45 @@ ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)
|
|||
ibuf_enqueue(msgbuf, buf);
|
||||
}
|
||||
|
||||
void
|
||||
ibuf_free(struct ibuf *buf)
|
||||
{
|
||||
if (buf == NULL)
|
||||
return;
|
||||
#ifdef NOTYET
|
||||
if (buf->fd != -1)
|
||||
close(buf->fd);
|
||||
#endif
|
||||
freezero(buf->buf, buf->size);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_fd_avail(struct ibuf *buf)
|
||||
{
|
||||
return (buf->fd != -1);
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_fd_get(struct ibuf *buf)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = buf->fd;
|
||||
#ifdef NOTYET
|
||||
buf->fd = -1;
|
||||
#endif
|
||||
return (fd);
|
||||
}
|
||||
|
||||
void
|
||||
ibuf_fd_set(struct ibuf *buf, int fd)
|
||||
{
|
||||
if (buf->fd != -1)
|
||||
close(buf->fd);
|
||||
buf->fd = fd;
|
||||
}
|
||||
|
||||
int
|
||||
ibuf_write(struct msgbuf *msgbuf)
|
||||
{
|
||||
|
@ -200,15 +364,6 @@ again:
|
|||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
ibuf_free(struct ibuf *buf)
|
||||
{
|
||||
if (buf == NULL)
|
||||
return;
|
||||
freezero(buf->buf, buf->size);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
msgbuf_init(struct msgbuf *msgbuf)
|
||||
{
|
||||
|
@ -217,7 +372,7 @@ msgbuf_init(struct msgbuf *msgbuf)
|
|||
TAILQ_INIT(&msgbuf->bufs);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
msgbuf_drain(struct msgbuf *msgbuf, size_t n)
|
||||
{
|
||||
struct ibuf *buf, *next;
|
||||
|
@ -326,8 +481,10 @@ ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
|
|||
{
|
||||
TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
|
||||
|
||||
if (buf->fd != -1)
|
||||
if (buf->fd != -1) {
|
||||
close(buf->fd);
|
||||
buf->fd = -1;
|
||||
}
|
||||
|
||||
msgbuf->queued--;
|
||||
ibuf_free(buf);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: imsg.c,v 1.18 2023/03/08 04:43:05 guenther Exp $ */
|
||||
/* $OpenBSD: imsg.c,v 1.19 2023/06/19 17:19:50 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
||||
|
@ -175,8 +175,7 @@ imsg_compose(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
|
|||
if (imsg_add(wbuf, data, datalen) == -1)
|
||||
return (-1);
|
||||
|
||||
wbuf->fd = fd;
|
||||
|
||||
ibuf_fd_set(wbuf, fd);
|
||||
imsg_close(ibuf, wbuf);
|
||||
|
||||
return (1);
|
||||
|
@ -199,13 +198,49 @@ imsg_composev(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
|
|||
if (imsg_add(wbuf, iov[i].iov_base, iov[i].iov_len) == -1)
|
||||
return (-1);
|
||||
|
||||
wbuf->fd = fd;
|
||||
|
||||
ibuf_fd_set(wbuf, fd);
|
||||
imsg_close(ibuf, wbuf);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
imsg_compose_ibuf(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
|
||||
pid_t pid, struct ibuf *buf)
|
||||
{
|
||||
struct ibuf *wbuf = NULL;
|
||||
struct imsg_hdr hdr;
|
||||
int save_errno;
|
||||
|
||||
if (ibuf_size(buf) + IMSG_HEADER_SIZE > MAX_IMSGSIZE) {
|
||||
errno = ERANGE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hdr.type = type;
|
||||
hdr.len = ibuf_size(buf) + IMSG_HEADER_SIZE;
|
||||
hdr.flags = 0;
|
||||
hdr.peerid = peerid;
|
||||
if ((hdr.pid = pid) == 0)
|
||||
hdr.pid = ibuf->pid;
|
||||
|
||||
if ((wbuf = ibuf_open(IMSG_HEADER_SIZE)) == NULL)
|
||||
goto fail;
|
||||
if (imsg_add(wbuf, &hdr, sizeof(hdr)) == -1)
|
||||
goto fail;
|
||||
|
||||
ibuf_close(&ibuf->w, wbuf);
|
||||
ibuf_close(&ibuf->w, buf);
|
||||
return (1);
|
||||
|
||||
fail:
|
||||
save_errno = errno;
|
||||
ibuf_free(buf);
|
||||
ibuf_free(wbuf);
|
||||
errno = save_errno;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
struct ibuf *
|
||||
imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
|
||||
uint16_t datalen)
|
||||
|
@ -252,10 +287,9 @@ imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
|
|||
hdr = (struct imsg_hdr *)msg->buf;
|
||||
|
||||
hdr->flags &= ~IMSGF_HASFD;
|
||||
if (msg->fd != -1)
|
||||
if (ibuf_fd_avail(msg))
|
||||
hdr->flags |= IMSGF_HASFD;
|
||||
|
||||
hdr->len = (uint16_t)msg->wpos;
|
||||
hdr->len = ibuf_size(msg);
|
||||
|
||||
ibuf_close(&ibuf->w, msg);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: imsg.h,v 1.6 2021/01/13 09:56:28 claudio Exp $ */
|
||||
/* $OpenBSD: imsg.h,v 1.7 2023/06/19 17:19:50 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
|
||||
|
@ -80,21 +80,35 @@ struct imsg {
|
|||
|
||||
struct iovec;
|
||||
|
||||
/* buffer.c */
|
||||
/* imsg-buffer.c */
|
||||
struct ibuf *ibuf_open(size_t);
|
||||
struct ibuf *ibuf_dynamic(size_t, size_t);
|
||||
int ibuf_add(struct ibuf *, const void *, size_t);
|
||||
int ibuf_add_buf(struct ibuf *, const struct ibuf *);
|
||||
int ibuf_add_zero(struct ibuf *, size_t);
|
||||
int ibuf_add_n8(struct ibuf *, uint64_t);
|
||||
int ibuf_add_n16(struct ibuf *, uint64_t);
|
||||
int ibuf_add_n32(struct ibuf *, uint64_t);
|
||||
int ibuf_add_n64(struct ibuf *, uint64_t);
|
||||
void *ibuf_reserve(struct ibuf *, size_t);
|
||||
void *ibuf_seek(struct ibuf *, size_t, size_t);
|
||||
int ibuf_set(struct ibuf *, size_t, const void *, size_t);
|
||||
int ibuf_set_n8(struct ibuf *, size_t, uint64_t);
|
||||
int ibuf_set_n16(struct ibuf *, size_t, uint64_t);
|
||||
int ibuf_set_n32(struct ibuf *, size_t, uint64_t);
|
||||
int ibuf_set_n64(struct ibuf *, size_t, uint64_t);
|
||||
void *ibuf_data(struct ibuf *);
|
||||
size_t ibuf_size(struct ibuf *);
|
||||
size_t ibuf_left(struct ibuf *);
|
||||
void ibuf_close(struct msgbuf *, struct ibuf *);
|
||||
int ibuf_write(struct msgbuf *);
|
||||
void ibuf_free(struct ibuf *);
|
||||
int ibuf_fd_avail(struct ibuf *);
|
||||
int ibuf_fd_get(struct ibuf *);
|
||||
void ibuf_fd_set(struct ibuf *, int);
|
||||
int ibuf_write(struct msgbuf *);
|
||||
void msgbuf_init(struct msgbuf *);
|
||||
void msgbuf_clear(struct msgbuf *);
|
||||
int msgbuf_write(struct msgbuf *);
|
||||
void msgbuf_drain(struct msgbuf *, size_t);
|
||||
|
||||
/* imsg.c */
|
||||
void imsg_init(struct imsgbuf *, int);
|
||||
|
@ -104,6 +118,8 @@ int imsg_compose(struct imsgbuf *, uint32_t, uint32_t, pid_t, int,
|
|||
const void *, uint16_t);
|
||||
int imsg_composev(struct imsgbuf *, uint32_t, uint32_t, pid_t, int,
|
||||
const struct iovec *, int);
|
||||
int imsg_compose_ibuf(struct imsgbuf *, uint32_t, uint32_t, pid_t,
|
||||
struct ibuf *);
|
||||
struct ibuf *imsg_create(struct imsgbuf *, uint32_t, uint32_t, pid_t, uint16_t);
|
||||
int imsg_add(struct ibuf *, const void *, uint16_t);
|
||||
void imsg_close(struct imsgbuf *, struct ibuf *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $OpenBSD: imsg_init.3,v 1.25 2022/05/19 08:05:23 stsp Exp $
|
||||
.\" $OpenBSD: imsg_init.3,v 1.28 2023/06/20 06:53:29 jsg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2010 Nicholas Marriott <nicm@openbsd.org>
|
||||
.\"
|
||||
|
@ -14,7 +14,7 @@
|
|||
.\" 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: May 19 2022 $
|
||||
.Dd $Mdocdate: June 20 2023 $
|
||||
.Dt IMSG_INIT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -23,6 +23,7 @@
|
|||
.Nm imsg_get ,
|
||||
.Nm imsg_compose ,
|
||||
.Nm imsg_composev ,
|
||||
.Nm imsg_compose_ibuf ,
|
||||
.Nm imsg_create ,
|
||||
.Nm imsg_add ,
|
||||
.Nm imsg_close ,
|
||||
|
@ -32,17 +33,31 @@
|
|||
.Nm ibuf_open ,
|
||||
.Nm ibuf_dynamic ,
|
||||
.Nm ibuf_add ,
|
||||
.Nm ibuf_add_buf ,
|
||||
.Nm ibuf_add_n8 ,
|
||||
.Nm ibuf_add_n16 ,
|
||||
.Nm ibuf_add_n32 ,
|
||||
.Nm ibuf_add_n64 ,
|
||||
.Nm ibuf_add_zero ,
|
||||
.Nm ibuf_reserve ,
|
||||
.Nm ibuf_seek ,
|
||||
.Nm ibuf_set ,
|
||||
.Nm ibuf_set_n8 ,
|
||||
.Nm ibuf_set_n16 ,
|
||||
.Nm ibuf_set_n32 ,
|
||||
.Nm ibuf_set_n64 ,
|
||||
.Nm ibuf_data ,
|
||||
.Nm ibuf_size ,
|
||||
.Nm ibuf_left ,
|
||||
.Nm ibuf_close ,
|
||||
.Nm ibuf_write ,
|
||||
.Nm ibuf_free ,
|
||||
.Nm ibuf_fd_avail ,
|
||||
.Nm ibuf_fd_get ,
|
||||
.Nm ibuf_fd_set ,
|
||||
.Nm ibuf_write ,
|
||||
.Nm msgbuf_init ,
|
||||
.Nm msgbuf_clear ,
|
||||
.Nm msgbuf_write ,
|
||||
.Nm msgbuf_drain
|
||||
.Nm msgbuf_write
|
||||
.Nd IPC messaging functions
|
||||
.Sh SYNOPSIS
|
||||
.In sys/types.h
|
||||
|
@ -62,6 +77,9 @@
|
|||
.Ft int
|
||||
.Fn imsg_composev "struct imsgbuf *ibuf" "uint32_t type" "uint32_t peerid" \
|
||||
"pid_t pid" "int fd" "const struct iovec *iov" "int iovcnt"
|
||||
.Ft int
|
||||
.Fn imsg_compose_ibuf "struct imsgbuf *ibuf" "uint32_t type" "uint32_t peerid" \
|
||||
"pid_t pid" "struct ibuf *buf"
|
||||
.Ft "struct ibuf *"
|
||||
.Fn imsg_create "struct imsgbuf *ibuf" "uint32_t type" "uint32_t peerid" \
|
||||
"pid_t pid" "uint16_t datalen"
|
||||
|
@ -81,28 +99,57 @@
|
|||
.Fn ibuf_dynamic "size_t len" "size_t max"
|
||||
.Ft int
|
||||
.Fn ibuf_add "struct ibuf *buf" "const void *data" "size_t len"
|
||||
.Ft int
|
||||
.Fn ibuf_add_buf "struct ibuf *buf" "const struct ibuf *from"
|
||||
.Ft int
|
||||
.Fn ibuf_add_n8 "struct ibuf *buf" "uint64_t value"
|
||||
.Ft int
|
||||
.Fn ibuf_add_n16 "struct ibuf *buf" "uint64_t value"
|
||||
.Ft int
|
||||
.Fn ibuf_add_n32 "struct ibuf *buf" "uint64_t value"
|
||||
.Ft int
|
||||
.Fn ibuf_add_n64 "struct ibuf *buf" "uint64_t value"
|
||||
.Ft int
|
||||
.Fn ibuf_add_zero "struct ibuf *buf" "size_t len"
|
||||
.Ft "void *"
|
||||
.Fn ibuf_reserve "struct ibuf *buf" "size_t len"
|
||||
.Ft "void *"
|
||||
.Fn ibuf_seek "struct ibuf *buf" "size_t pos" "size_t len"
|
||||
.Ft int
|
||||
.Fn ibuf_set "struct ibuf *buf" "size_t pos" "const void *data" \
|
||||
"size_t len"
|
||||
.Ft int
|
||||
.Fn ibuf_set_n8 "struct ibuf *buf" "size_t pos" "uint64_t value"
|
||||
.Ft int
|
||||
.Fn ibuf_set_n16 "struct ibuf *buf" "size_t pos" "uint64_t value"
|
||||
.Ft int
|
||||
.Fn ibuf_set_n32 "struct ibuf *buf" "size_t pos" "uint64_t value"
|
||||
.Ft int
|
||||
.Fn ibuf_set_n64 "struct ibuf *buf" "size_t pos" "uint64_t value"
|
||||
.Ft "void *"
|
||||
.Fn ibuf_data "struct ibuf *buf"
|
||||
.Ft size_t
|
||||
.Fn ibuf_size "struct ibuf *buf"
|
||||
.Ft size_t
|
||||
.Fn ibuf_left "struct ibuf *buf"
|
||||
.Ft void
|
||||
.Fn ibuf_close "struct msgbuf *msgbuf" "struct ibuf *buf"
|
||||
.Ft int
|
||||
.Fn ibuf_write "struct msgbuf *msgbuf"
|
||||
.Ft void
|
||||
.Fn ibuf_free "struct ibuf *buf"
|
||||
.Ft int
|
||||
.Fn ibuf_fd_avail "struct ibuf *buf"
|
||||
.Ft int
|
||||
.Fn ibuf_fd_get "struct ibuf *buf"
|
||||
.Ft void
|
||||
.Fn ibuf_fd_set "struct ibuf *buf" "int fd"
|
||||
.Ft int
|
||||
.Fn ibuf_write "struct msgbuf *msgbuf"
|
||||
.Ft void
|
||||
.Fn msgbuf_init "struct msgbuf *msgbuf"
|
||||
.Ft void
|
||||
.Fn msgbuf_clear "struct msgbuf *msgbuf"
|
||||
.Ft int
|
||||
.Fn msgbuf_write "struct msgbuf *msgbuf"
|
||||
.Ft void
|
||||
.Fn msgbuf_drain "struct msgbuf *msgbuf" "size_t n"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm imsg
|
||||
|
@ -133,7 +180,7 @@ struct imsgbuf {
|
|||
.Ed
|
||||
.Pp
|
||||
.Fn imsg_init
|
||||
is a routine which initializes
|
||||
initializes
|
||||
.Fa ibuf
|
||||
as one side of a channel associated with
|
||||
.Fa fd .
|
||||
|
@ -199,7 +246,7 @@ by adding it to
|
|||
output buffer.
|
||||
.Pp
|
||||
.Fn imsg_compose
|
||||
is a routine which is used to quickly create and queue an imsg.
|
||||
is used to quickly create and queue an imsg.
|
||||
It takes the same parameters as the
|
||||
.Fn imsg_create ,
|
||||
.Fn imsg_add
|
||||
|
@ -223,8 +270,19 @@ It takes the same parameters, except that the ancillary data buffer is specified
|
|||
by
|
||||
.Fa iovec .
|
||||
.Pp
|
||||
.Fn imsg_compose_ibuf
|
||||
is similar to
|
||||
.Fn imsg_compose .
|
||||
It takes the same parameters, except that the ancillary data buffer is specified
|
||||
by an ibuf
|
||||
.Fa buf .
|
||||
This routine returns 1 if it succeeds, \-1 otherwise.
|
||||
In either case the buffer
|
||||
.Fa buf
|
||||
is consumed by the function.
|
||||
.Pp
|
||||
.Fn imsg_flush
|
||||
is a function which calls
|
||||
calls
|
||||
.Fn msgbuf_write
|
||||
in a loop until all imsgs in the output buffer are sent.
|
||||
It returns 0 if it succeeds, \-1 otherwise.
|
||||
|
@ -357,7 +415,34 @@ Buffers allocated with
|
|||
are automatically grown if necessary when data is added.
|
||||
.Pp
|
||||
.Fn ibuf_add
|
||||
is a routine which appends a block of data to
|
||||
appends a block of data to
|
||||
.Fa buf .
|
||||
0 is returned on success and \-1 on failure.
|
||||
.Pp
|
||||
.Fn ibuf_add_buf
|
||||
appends the buffer
|
||||
.Fa from
|
||||
to
|
||||
.Fa buf .
|
||||
0 is returned on success and \-1 on failure.
|
||||
.Pp
|
||||
.Fn ibuf_add_n8 ,
|
||||
.Fn ibuf_add_n16 ,
|
||||
.Fn ibuf_add_n32 ,
|
||||
and
|
||||
.Fn ibuf_add_n64
|
||||
add a 1-byte, 2-byte, 4-byte, and 8-byte
|
||||
.Fa value
|
||||
to
|
||||
.Fa buf
|
||||
in network byte order.
|
||||
This function checks
|
||||
.Fa value
|
||||
to not overflow.
|
||||
0 is returned on success and \-1 on failure.
|
||||
.Pp
|
||||
.Fn ibuf_add_zero
|
||||
appends a block of zeros to
|
||||
.Fa buf .
|
||||
0 is returned on success and \-1 on failure.
|
||||
.Pp
|
||||
|
@ -369,13 +454,45 @@ bytes in
|
|||
A pointer to the start of the reserved space is returned, or NULL on error.
|
||||
.Pp
|
||||
.Fn ibuf_seek
|
||||
is a function which returns a pointer to the part of the buffer at offset
|
||||
returns a pointer to the part of the buffer at offset
|
||||
.Fa pos
|
||||
and of extent
|
||||
.Fa len .
|
||||
NULL is returned if the requested range is outside the part of the buffer
|
||||
in use.
|
||||
.Pp
|
||||
.Fn ibuf_set
|
||||
replaces a part of
|
||||
.Fa buf
|
||||
at offset
|
||||
.Fa pos
|
||||
with the data of extent
|
||||
.Fa len .
|
||||
0 is returned on success and \-1 on failure.
|
||||
.Pp
|
||||
.Fn ibuf_set_n8 ,
|
||||
.Fn ibuf_set_n16 ,
|
||||
.Fn ibuf_seek_set_n32
|
||||
and
|
||||
.Fn ibuf_seek_set_n64
|
||||
replace a 1-byte, 2-byte, 4-byte or 8-byte
|
||||
.Fa value
|
||||
at offset
|
||||
.Fa pos
|
||||
in the buffer
|
||||
.Fa buf
|
||||
in network byte order.
|
||||
This function checks
|
||||
.Fa value
|
||||
to not overflow.
|
||||
0 is returned on success and \-1 on failure.
|
||||
.Pp
|
||||
.Fn ibuf_data
|
||||
returns the pointer to the internal buffer.
|
||||
This function should only be used together with
|
||||
.Fn ibuf_size
|
||||
to process a previously generated buffer.
|
||||
.Pp
|
||||
.Fn ibuf_size
|
||||
and
|
||||
.Fn ibuf_left
|
||||
|
@ -390,6 +507,35 @@ to
|
|||
.Fa msgbuf
|
||||
ready to be sent.
|
||||
.Pp
|
||||
.Fn ibuf_fd_avail ,
|
||||
.Fn ibuf_fd_get
|
||||
and
|
||||
.Fn ibuf_fd_set
|
||||
are functions to check, get and set the file descriptor assigned to
|
||||
.Fa buf .
|
||||
After calling
|
||||
.Fn ibuf_fd_set
|
||||
the file descriptor is part of the
|
||||
.Fa buf
|
||||
and will be transmitted or closed by the ibuf API.
|
||||
Any previously set file descriptor will be closed before assigning a
|
||||
new descriptor.
|
||||
.Fn ibuf_fd_get
|
||||
returns the file descriptor and passes the responsibility to track the
|
||||
descriptor back to the program.
|
||||
.Fn ibuf_fd_avail
|
||||
returns true if there is a file descriptor set on
|
||||
.Fa buf .
|
||||
.Pp
|
||||
.Fn ibuf_free
|
||||
frees
|
||||
.Fa buf
|
||||
and any associated storage, and closes any file descriptor set with
|
||||
.Fn ibuf_fd_set .
|
||||
If
|
||||
.Fa buf
|
||||
is a NULL pointer, no action occurs.
|
||||
.Pp
|
||||
The
|
||||
.Fn ibuf_write
|
||||
routine transmits as many pending buffers as possible from
|
||||
|
@ -402,14 +548,6 @@ Temporary resource shortages are returned with errno
|
|||
.Er EAGAIN
|
||||
and require the application to retry again in the future.
|
||||
.Pp
|
||||
.Fn ibuf_free
|
||||
frees
|
||||
.Fa buf
|
||||
and any associated storage.
|
||||
If
|
||||
.Fa buf
|
||||
is a NULL pointer, no action occurs.
|
||||
.Pp
|
||||
The
|
||||
.Fn msgbuf_init
|
||||
function initializes
|
||||
|
@ -435,15 +573,6 @@ or an EOF condition on the socket is detected.
|
|||
Temporary resource shortages are returned with errno
|
||||
.Er EAGAIN
|
||||
and require the application to retry again in the future.
|
||||
.Pp
|
||||
.Fn msgbuf_drain
|
||||
discards data from buffers queued in
|
||||
.Fa msgbuf
|
||||
until
|
||||
.Fa n
|
||||
bytes have been removed or
|
||||
.Fa msgbuf
|
||||
is empty.
|
||||
.Sh EXAMPLES
|
||||
In a typical program, a channel between two processes is created with
|
||||
.Xr socketpair 2 ,
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
major=16
|
||||
major=17
|
||||
minor=0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: bn_unit.c,v 1.4 2023/03/31 19:40:08 tb Exp $ */
|
||||
/* $OpenBSD: bn_unit.c,v 1.6 2023/06/20 06:46:07 tb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
|
||||
|
@ -69,6 +69,39 @@ test_bn_print_null_derefs(void)
|
|||
return failed;
|
||||
}
|
||||
|
||||
static int
|
||||
test_bn_num_bits(void)
|
||||
{
|
||||
BIGNUM *bn;
|
||||
int i, num_bits;
|
||||
int failed = 0;
|
||||
|
||||
if ((bn = BN_new()) == NULL)
|
||||
errx(1, "BN_new");
|
||||
|
||||
if ((num_bits = BN_num_bits(bn)) != 0) {
|
||||
warnx("BN_num_bits(0): want 0, got %d", num_bits);
|
||||
failed |= 1;
|
||||
}
|
||||
|
||||
if (!BN_set_word(bn, 1))
|
||||
errx(1, "BN_set_word");
|
||||
|
||||
for (i = 0; i <= 5 * BN_BITS2; i++) {
|
||||
if ((num_bits = BN_num_bits(bn)) != i + 1) {
|
||||
warnx("BN_num_bits(1 << %d): want %d, got %d",
|
||||
i, i + 1, num_bits);
|
||||
failed |= 1;
|
||||
}
|
||||
if (!BN_lshift1(bn, bn))
|
||||
errx(1, "BN_lshift1");
|
||||
}
|
||||
|
||||
BN_free(bn);
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
static int
|
||||
test_bn_num_bits_word(void)
|
||||
{
|
||||
|
@ -255,6 +288,7 @@ main(void)
|
|||
int failed = 0;
|
||||
|
||||
failed |= test_bn_print_null_derefs();
|
||||
failed |= test_bn_num_bits();
|
||||
failed |= test_bn_num_bits_word();
|
||||
failed |= test_bn_copy_copies_flags();
|
||||
failed |= test_bn_copy_consttime_is_sticky();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: enginetest.c,v 1.9 2022/09/05 21:06:31 tb Exp $ */
|
||||
/* $OpenBSD: enginetest.c,v 1.10 2023/06/19 18:52:29 tb Exp $ */
|
||||
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
|
||||
* project 2000.
|
||||
*/
|
||||
|
@ -61,6 +61,7 @@
|
|||
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/crypto.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
|
@ -242,3 +243,11 @@ end:
|
|||
CRYPTO_mem_leaks_fp(stderr);
|
||||
return to_return;
|
||||
}
|
||||
#else
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("ENGINE support is disabled\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: gost2814789t.c,v 1.8 2022/09/12 04:20:59 tb Exp $ */
|
||||
/* $OpenBSD: gost2814789t.c,v 1.9 2023/06/19 18:51:47 tb Exp $ */
|
||||
/* vim: set fileencoding=ascii : Charset: ASCII */
|
||||
/* test/gostr2814789t.c */
|
||||
/* ====================================================================
|
||||
|
@ -24,7 +24,9 @@ int main(int argc, char *argv[])
|
|||
#include <inttypes.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/crypto.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
@ -1287,7 +1289,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE_load_builtin_engines();
|
||||
#endif
|
||||
OPENSSL_load_builtin_modules();
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ibuf_test.c,v 1.3 2023/06/13 10:39:46 tb Exp $ */
|
||||
/* $OpenBSD: ibuf_test.c,v 1.4 2023/06/19 17:22:46 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) Tobias Stoeckmann <tobias@openbsd.org>
|
||||
*
|
||||
|
@ -92,44 +92,6 @@ test_ibuf_seek(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
test_msgbuf_drain(void)
|
||||
{
|
||||
struct msgbuf msgbuf;
|
||||
struct ibuf *buf;
|
||||
|
||||
msgbuf_init(&msgbuf);
|
||||
|
||||
if ((buf = ibuf_open(4)) == NULL)
|
||||
return 1;
|
||||
if (ibuf_add(buf, "test", 4) != 0) {
|
||||
ibuf_free(buf);
|
||||
return 1;
|
||||
}
|
||||
ibuf_close(&msgbuf, buf);
|
||||
|
||||
if (msgbuf.queued != 1) {
|
||||
ibuf_free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
msgbuf_drain(&msgbuf, 1);
|
||||
|
||||
if (msgbuf.queued != 1) {
|
||||
ibuf_free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
msgbuf_drain(&msgbuf, SIZE_MAX);
|
||||
|
||||
if (msgbuf.queued != 0) {
|
||||
ibuf_free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@ -161,12 +123,6 @@ main(void)
|
|||
} else
|
||||
printf("SUCCESS: test_ibuf_seek\n");
|
||||
|
||||
if (test_msgbuf_drain() != 0) {
|
||||
printf("FAILED: test_msgbuf_drain\n");
|
||||
ret = 1;
|
||||
} else
|
||||
printf("SUCCESS: test_msgbuf_drain\n");
|
||||
|
||||
if (ret != 0) {
|
||||
printf("FAILED: %s\n", __progname);
|
||||
return 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $OpenBSD: Makefile.inc,v 1.32 2023/05/30 15:56:47 job Exp $
|
||||
# $OpenBSD: Makefile.inc,v 1.33 2023/06/20 12:52:32 job Exp $
|
||||
|
||||
.PATH: ${.CURDIR}/../../../../usr.sbin/rpki-client
|
||||
|
||||
|
@ -40,7 +40,7 @@ run-regress-test-cert: test-cert
|
|||
./test-cert -vt ${TALARGS:S,,${.CURDIR}/../&,}
|
||||
|
||||
SRCS_test-mft+= test-mft.c mft.c crl.c cms.c x509.c ip.c io.c log.c validate.c \
|
||||
encoding.c print.c dummy.c json.c
|
||||
encoding.c print.c json.c cert.c as.c
|
||||
run-regress-test-mft: test-mft
|
||||
./test-mft -v ${.CURDIR}/../mft/*.mft
|
||||
|
||||
|
@ -64,8 +64,8 @@ SRCS_test-geofeed+= test-geofeed.c geofeed.c cms.c x509.c ip.c io.c log.c \
|
|||
run-regress-test-geofeed: test-geofeed
|
||||
./test-geofeed -v ${.CURDIR}/../geofeed/*.csv
|
||||
|
||||
SRCS_test-tal+= test-tal.c tal.c ip.c io.c log.c validate.c \
|
||||
encoding.c print.c crl.c dummy.c x509.c json.c
|
||||
SRCS_test-tal+= test-tal.c tal.c ip.c io.c log.c validate.c cms.c \
|
||||
encoding.c print.c crl.c x509.c json.c cert.c as.c mft.c
|
||||
run-regress-test-tal: test-tal
|
||||
./test-tal -v ${.CURDIR}/../tal/*.tal
|
||||
|
||||
|
@ -80,9 +80,9 @@ SRCS_test-tak+= test-tak.c tak.c cms.c x509.c ip.c as.c io.c log.c \
|
|||
run-regress-test-tak: test-tak
|
||||
./test-tak -v ${.CURDIR}/../tak/*.tak
|
||||
|
||||
SRCS_test-rrdp+= test-rrdp.c rrdp_delta.c rrdp_notification.c \
|
||||
rrdp_snapshot.c rrdp_util.c \
|
||||
log.c encoding.c ip.c validate.c dummy.c crl.c x509.c
|
||||
SRCS_test-rrdp+= test-rrdp.c rrdp_delta.c rrdp_notification.c cms.c \
|
||||
rrdp_snapshot.c rrdp_util.c cert.c as.c mft.c io.c \
|
||||
log.c encoding.c ip.c validate.c crl.c x509.c
|
||||
LDADD_test-rrdp+= -lexpat ${LDADD}
|
||||
DPADD_test-rrdp+= ${LIBEXPAT} ${DPADD}
|
||||
run-regress-test-rrdp: test-rrdp
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* Public domain
|
||||
* dummy shim for some tests.
|
||||
*/
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
struct auth *
|
||||
auth_find(struct auth_tree *auths, const char *aki)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
as_check_covered(uint32_t min, uint32_t max,
|
||||
const struct cert_as *as, size_t asz)
|
||||
{
|
||||
return -1;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: test-mft.c,v 1.25 2023/05/30 12:14:48 claudio Exp $ */
|
||||
/* $Id: test-mft.c,v 1.26 2023/06/20 12:52:32 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
|
@ -35,6 +35,7 @@
|
|||
|
||||
int outformats;
|
||||
int verbose;
|
||||
int filemode;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: test-rrdp.c,v 1.6 2023/05/30 12:14:48 claudio Exp $ */
|
||||
/* $OpenBSD: test-rrdp.c,v 1.7 2023/06/20 12:52:32 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
|
||||
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -36,6 +36,7 @@
|
|||
#include "rrdp.h"
|
||||
|
||||
int verbose;
|
||||
int filemode;
|
||||
|
||||
#define REGRESS_NOTIFY_URI "https://rpki.example.com/notify.xml"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: test-tal.c,v 1.12 2023/05/30 12:14:48 claudio Exp $ */
|
||||
/* $Id: test-tal.c,v 1.13 2023/06/20 12:52:32 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
|
@ -31,6 +31,7 @@
|
|||
|
||||
int outformats;
|
||||
int verbose;
|
||||
int filemode;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: gpt.c,v 1.91 2023/05/17 12:59:37 krw Exp $ */
|
||||
/* $OpenBSD: gpt.c,v 1.93 2023/06/20 11:52:08 krw Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
|
||||
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
|
||||
|
@ -77,10 +77,9 @@ name_to_string(const unsigned int pn)
|
|||
static char name[GPTPARTNAMESIZE + 1];
|
||||
unsigned int i;
|
||||
|
||||
memset(name, 0, sizeof(name));
|
||||
|
||||
for (i = 0; i < sizeof(name) && gp[pn].gp_name[i] != 0; i++)
|
||||
for (i = 0; i < GPTPARTNAMESIZE && gp[pn].gp_name[i] != 0; i++)
|
||||
name[i] = letoh16(gp[pn].gp_name[i]) & 0x7F;
|
||||
name[i] = '\0';
|
||||
|
||||
return name;
|
||||
}
|
||||
|
@ -455,7 +454,7 @@ GPT_print_part(const unsigned int pn, const char *units, const int verbosity)
|
|||
printf(" <invalid partition guid> ");
|
||||
else
|
||||
printf(" %-36s ", guidstr);
|
||||
printf("%-36s\n", name_to_string(pn));
|
||||
printf("%s\n", name_to_string(pn));
|
||||
free(guidstr);
|
||||
attrs = gp[pn].gp_attrs;
|
||||
if (attrs) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: part.c,v 1.163 2023/05/21 17:29:33 krw Exp $ */
|
||||
/* $OpenBSD: part.c,v 1.164 2023/06/19 23:11:57 krw Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Tobias Weingartner
|
||||
|
@ -1047,14 +1047,13 @@ PRT_print_part(const int num, const struct prt *prt, const char *units)
|
|||
const char *desc;
|
||||
struct chs start, end;
|
||||
double size;
|
||||
unsigned int i;
|
||||
|
||||
size = units_size(units, prt->prt_ns, &ut);
|
||||
PRT_lba_to_chs(prt, &start, &end);
|
||||
desc = find_mbr_desc(find_mbr_type(prt->prt_id));
|
||||
|
||||
printf("%c%1d: %.2X %6llu %3u %3u - %6llu %3u %3u [%12llu:%12.0f%s] "
|
||||
"%-15s\n", (prt->prt_flag == DOSACTIVE) ? '*' : ' ', num,
|
||||
"%s\n", (prt->prt_flag == DOSACTIVE) ? '*' : ' ', num,
|
||||
prt->prt_id, start.chs_cyl, start.chs_head, start.chs_sect,
|
||||
end.chs_cyl, end.chs_head, end.chs_sect,
|
||||
prt->prt_bs, size, ut->ut_abbr, desc ? desc : "<Unknown ID>");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: iked.h,v 1.217 2023/06/16 10:28:43 tb Exp $ */
|
||||
/* $OpenBSD: iked.h,v 1.218 2023/06/19 17:19:50 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
|
||||
|
@ -1270,7 +1270,6 @@ struct ibuf *
|
|||
int ibuf_cat(struct ibuf *, struct ibuf *);
|
||||
size_t ibuf_length(struct ibuf *);
|
||||
int ibuf_setsize(struct ibuf *, size_t);
|
||||
void *ibuf_data(struct ibuf *);
|
||||
void *ibuf_getdata(struct ibuf *, size_t);
|
||||
struct ibuf *
|
||||
ibuf_get(struct ibuf *, size_t);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: imsg_util.c,v 1.18 2023/06/12 09:02:32 claudio Exp $ */
|
||||
/* $OpenBSD: imsg_util.c,v 1.19 2023/06/19 17:19:50 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
|
||||
|
@ -83,12 +83,6 @@ ibuf_length(struct ibuf *buf)
|
|||
return (ibuf_size(buf));
|
||||
}
|
||||
|
||||
void *
|
||||
ibuf_data(struct ibuf *buf)
|
||||
{
|
||||
return (ibuf_seek(buf, 0, 0));
|
||||
}
|
||||
|
||||
void *
|
||||
ibuf_getdata(struct ibuf *buf, size_t len)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $OpenBSD: rt_timer_add.9,v 1.4 2014/03/26 14:50:30 mpi Exp $
|
||||
.\" $OpenBSD: rt_timer_add.9,v 1.5 2023/06/20 10:59:47 kn Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org>
|
||||
.\" All rights reserved.
|
||||
|
@ -15,83 +15,90 @@
|
|||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.Dd $Mdocdate: March 26 2014 $
|
||||
.Dd $Mdocdate: June 20 2023 $
|
||||
.Dt RT_TIMER_ADD 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm rt_timer_add ,
|
||||
.Nm rt_timer_remove_all ,
|
||||
.Nm rt_timer_queue_create ,
|
||||
.Nm rt_timer_queue_count ,
|
||||
.Nm rt_timer_get_expire ,
|
||||
.Nm rt_timer_queue_init ,
|
||||
.Nm rt_timer_queue_change ,
|
||||
.Nm rt_timer_queue_destroy
|
||||
.Nm rt_timer_queue_flush ,
|
||||
.Nm rt_timer_queue_count
|
||||
.Nd route timer queues interface
|
||||
.Sh SYNOPSIS
|
||||
.In net/route.h
|
||||
.Ft int
|
||||
.Fn rt_timer_add "struct rtentry *rt" \
|
||||
"void (*func)(struct rtentry *, struct rttimer *)" \
|
||||
"struct rttimer_queue *queue" "u_int rtableid"
|
||||
.Ft void
|
||||
.Fn rt_timer_remove_all "struct rtentry *rt"
|
||||
.Ft struct rttimer_queue *
|
||||
.Fn rt_timer_queue_create "u_int timeout"
|
||||
.Ft time_t
|
||||
.Fn rt_timer_get_expire "const struct rtentry *rt"
|
||||
.Ft void
|
||||
.Fn rt_timer_queue_init "struct rttimer_queue *rtq" "int timeout" \
|
||||
"void (*func)(struct rtentry *, u_int)"
|
||||
.Ft void
|
||||
.Fn rt_timer_queue_change "struct rttimer_queue *rtq" "int timeout"
|
||||
.Ft void
|
||||
.Fn rt_timer_queue_flush "struct rttimer_queue *rtq"
|
||||
.Ft unsigned long
|
||||
.Fn rt_timer_queue_count "struct rttimer_queue *rtq"
|
||||
.Ft void
|
||||
.Fn rt_timer_queue_change "struct rttimer_queue *rtq" "long timeout"
|
||||
.Ft void
|
||||
.Fn rt_timer_queue_destroy "struct rttimer_queue *rtq"
|
||||
.Sh DESCRIPTION
|
||||
Route timer queues provide a method of queueing routing-related actions to be
|
||||
triggered once per second.
|
||||
.Bl -tag -width Ds
|
||||
.It Fn rt_timer_add "struct rtentry *rt" \
|
||||
"void (*func)(struct rtentry *, struct rttimer *)" \
|
||||
"struct rttimer_queue *queue" "u_int rtableid"
|
||||
Schedule
|
||||
.Fa func
|
||||
The
|
||||
.Nm rt_timer
|
||||
subsystem queues routing-related functions for asynchronous execution
|
||||
in the future.
|
||||
.Pp
|
||||
.Fn rt_timer_add
|
||||
allocates an rttimer_queue
|
||||
.Fa rtq
|
||||
to be called on
|
||||
.Fa rt
|
||||
using the timeout of
|
||||
.Fa queue .
|
||||
If
|
||||
.Fa rt
|
||||
already has a call to
|
||||
.Fa func
|
||||
scheduled on any timer queue, it will be replaced with the new invocation.
|
||||
.It Fn rt_timer_remove_all "struct rtentry *rt"
|
||||
Remove all timeouts associated with
|
||||
If an action already exists, it will be replaced with the new one.
|
||||
.Pp
|
||||
.Fn rt_timer_remove_all
|
||||
removes all timeouts associated with
|
||||
.Fa rt
|
||||
from all routing timer queues.
|
||||
.It Fn rt_timer_queue_create "u_int timeout"
|
||||
Create a timer queue with a timeout of
|
||||
.Pp
|
||||
.Fn rt_timer_get_expire
|
||||
returns the current expiry time in seconds.
|
||||
.Pp
|
||||
.Fn rt_timer_queue_init
|
||||
creates a timer queue with a timeout of
|
||||
.Fa timeout
|
||||
seconds.
|
||||
.It Fn rt_timer_queue_count "struct rtentry *rt"
|
||||
Return the number of timers present in the queue
|
||||
.Fa rtq .
|
||||
.It Fn rt_timer_queue_change "struct rttimer_queue *rtq" "long timeout"
|
||||
Set timeout for
|
||||
.Pp
|
||||
.Fn rt_timer_queue_change
|
||||
sets the timeout for
|
||||
.Fa rtq
|
||||
to
|
||||
.Fa timeout
|
||||
seconds.
|
||||
.It Fn rt_timer_queue_destroy "struct rttimer_queue *rtq"
|
||||
Remove all timeouts from the routing timer queue
|
||||
.Pp
|
||||
.Fn rt_timer_queue_flush
|
||||
removes all timeouts from the routing timer queue
|
||||
.Fa rtq ,
|
||||
execute their associated callback and destroy it.
|
||||
.El
|
||||
executes their associated callback and destroys it.
|
||||
.Pp
|
||||
.Fn rt_timer_queue_count
|
||||
returns the number of timers present in the queue
|
||||
.Fa rtq .
|
||||
.Sh CONTEXT
|
||||
.Fn rt_timer_add ,
|
||||
.Fn rt_timer_remove_all ,
|
||||
.Fn rt_timer_queue_create ,
|
||||
.Fn rt_timer_queue_count ,
|
||||
.Fn rt_timer_get_expire ,
|
||||
.Fn rt_timer_queue_init ,
|
||||
.Fn rt_timer_queue_change ,
|
||||
.Fn rt_timer_queue_flush
|
||||
and
|
||||
.Fn rt_timer_queue_destroy
|
||||
.Fn rt_timer_queue_count
|
||||
can be called during autoconf, from process context, or from interrupt context.
|
||||
.Sh RETURN VALUES
|
||||
.Sh ERRORS
|
||||
.Fn rt_timer_add
|
||||
may fail with
|
||||
.Er ENOBUFS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $OpenBSD: uvm_init.9,v 1.5 2023/05/21 05:11:38 jmc Exp $
|
||||
.\" $OpenBSD: uvm_init.9,v 1.6 2023/06/20 16:30:30 cheloha Exp $
|
||||
.\" $NetBSD: uvm.9,v 1.14 2000/06/29 06:08:44 mrg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 Matthew R. Green
|
||||
|
@ -28,7 +28,7 @@
|
|||
.\" XXX this manual sets nS to 1 or 0 in the description, to obtain
|
||||
.\" synopsis-like function prototypes. any better way?
|
||||
.\"
|
||||
.Dd $Mdocdate: May 21 2023 $
|
||||
.Dd $Mdocdate: June 20 2023 $
|
||||
.Dt UVM_INIT 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -168,7 +168,7 @@ argument is ignored.
|
|||
.Ft void
|
||||
.Fn uvm_kernacc "caddr_t addr" "size_t len" "int rw"
|
||||
.Ft void
|
||||
.Fn uvm_meter
|
||||
.Fn uvm_meter "void *"
|
||||
.Ft int
|
||||
.Fn uvm_sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp " "size_t newlen" "struct proc *p"
|
||||
.Ft int
|
||||
|
@ -212,7 +212,7 @@ access, in the kernel address space.
|
|||
.Pp
|
||||
The
|
||||
.Fn uvm_meter
|
||||
function calculates the load average and wakes up the swapper if necessary.
|
||||
function periodically recomputes the load average.
|
||||
.Pp
|
||||
The
|
||||
.Fn uvm_sysctl
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: dwmshc.c,v 1.4 2023/04/19 02:01:02 dlg Exp $ */
|
||||
/* $OpenBSD: dwmshc.c,v 1.5 2023/06/20 09:26:36 kettenis Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2023 David Gwynne <dlg@openbsd.org>
|
||||
|
@ -98,7 +98,7 @@
|
|||
#define EMMC_DLL_RXCLK_RX_CLK_OUT_SEL (1U << 27)
|
||||
#define EMMC_DLL_RXCLK_RX_CLK_CHANGE_WINDOW (1U << 28)
|
||||
#define EMMC_DLL_RXCLK_RX_CLK_SRC_SEL (1U << 29)
|
||||
#define EMMC_DLL_TXCLK 0x804
|
||||
#define EMMC_DLL_TXCLK 0x808
|
||||
#define EMMC_DLL_TXCLK_TX_TAP_NUM_SHIFT 0
|
||||
#define EMMC_DLL_TXCLK_TX_TAP_NUM_MASK 0x1f
|
||||
#define EMMC_DLL_TXCLK_TX_TAP_VALUE_SHIFT 8
|
||||
|
|
|
@ -553,7 +553,7 @@ aic_poll(struct aic_softc *sc, struct scsi_xfer *xs, int count)
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* LOW LEVEL SCSI UTILITIES
|
||||
*/
|
||||
|
@ -684,7 +684,7 @@ abort:
|
|||
aic_sched_msgout(sc, SEND_ABORT);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Schedule a SCSI operation. This has now been pulled out of the interrupt
|
||||
* handler so that we may call it from aic_scsi_cmd and aic_done. This may
|
||||
|
@ -726,7 +726,7 @@ aic_sched(struct aic_softc *sc)
|
|||
bus_space_write_1(iot, ioh, SIMODE1, ENSCSIRST);
|
||||
bus_space_write_1(iot, ioh, SCSISEQ, ENRESELI);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
aic_sense(struct aic_softc *sc, struct aic_acb *acb)
|
||||
{
|
||||
|
@ -831,7 +831,7 @@ aic_dequeue(struct aic_softc *sc, struct aic_acb *acb)
|
|||
TAILQ_REMOVE(&sc->ready_list, acb, chain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* INTERRUPT/PROTOCOL ENGINE
|
||||
*/
|
||||
|
@ -1305,7 +1305,7 @@ out:
|
|||
/* Disable REQ/ACK protocol. */
|
||||
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN);
|
||||
}
|
||||
|
||||
|
||||
/* aic_dataout_pio: perform a data transfer using the FIFO datapath in the aic6360
|
||||
* Precondition: The SCSI bus should be in the DOUT phase, with REQ asserted
|
||||
* and ACK deasserted (i.e. waiting for a data byte).
|
||||
|
@ -1446,7 +1446,7 @@ phasechange:
|
|||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/* aic_datain_pio: perform data transfers using the FIFO datapath in the aic6360
|
||||
* Precondition: The SCSI bus should be in the DIN phase, with REQ asserted
|
||||
* and ACK deasserted (i.e. at least one byte is ready).
|
||||
|
@ -1569,7 +1569,7 @@ phasechange:
|
|||
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This is the workhorse routine of the driver.
|
||||
* Deficiencies (for now):
|
||||
|
@ -1992,7 +1992,7 @@ aic_timeout(void *arg)
|
|||
|
||||
splx(s);
|
||||
}
|
||||
|
||||
|
||||
#ifdef AIC_DEBUG
|
||||
/*
|
||||
* The following functions are mostly used for debugging purposes, either
|
||||
|
|
|
@ -80,9 +80,10 @@ static void amdgpu_bo_user_destroy(struct ttm_buffer_object *tbo)
|
|||
static void amdgpu_bo_vm_destroy(struct ttm_buffer_object *tbo)
|
||||
{
|
||||
struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
|
||||
struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo);
|
||||
struct amdgpu_bo *shadow_bo = ttm_to_amdgpu_bo(tbo), *bo;
|
||||
struct amdgpu_bo_vm *vmbo;
|
||||
|
||||
bo = shadow_bo->parent;
|
||||
vmbo = to_amdgpu_bo_vm(bo);
|
||||
/* in case amdgpu_device_recover_vram got NULL of bo->parent */
|
||||
if (!list_empty(&vmbo->shadow_list)) {
|
||||
|
@ -693,11 +694,6 @@ int amdgpu_bo_create_vm(struct amdgpu_device *adev,
|
|||
return r;
|
||||
|
||||
*vmbo_ptr = to_amdgpu_bo_vm(bo_ptr);
|
||||
INIT_LIST_HEAD(&(*vmbo_ptr)->shadow_list);
|
||||
/* Set destroy callback to amdgpu_bo_vm_destroy after vmbo->shadow_list
|
||||
* is initialized.
|
||||
*/
|
||||
bo_ptr->tbo.destroy = &amdgpu_bo_vm_destroy;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -714,6 +710,8 @@ void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo_vm *vmbo)
|
|||
|
||||
mutex_lock(&adev->shadow_list_lock);
|
||||
list_add_tail(&vmbo->shadow_list, &adev->shadow_list);
|
||||
vmbo->shadow->parent = amdgpu_bo_ref(&vmbo->bo);
|
||||
vmbo->shadow->tbo.destroy = &amdgpu_bo_vm_destroy;
|
||||
mutex_unlock(&adev->shadow_list_lock);
|
||||
}
|
||||
|
||||
|
|
|
@ -564,7 +564,6 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
|||
return r;
|
||||
}
|
||||
|
||||
(*vmbo)->shadow->parent = amdgpu_bo_ref(bo);
|
||||
amdgpu_bo_add_to_shadow_list(*vmbo);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -806,7 +806,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_resource_manager *man,
|
|||
{
|
||||
struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
|
||||
struct drm_buddy *mm = &mgr->mm;
|
||||
struct drm_buddy_block *block;
|
||||
struct amdgpu_vram_reservation *rsv;
|
||||
|
||||
drm_printf(printer, " vis usage:%llu\n",
|
||||
amdgpu_vram_mgr_vis_usage(mgr));
|
||||
|
@ -818,8 +818,9 @@ static void amdgpu_vram_mgr_debug(struct ttm_resource_manager *man,
|
|||
drm_buddy_print(mm, printer);
|
||||
|
||||
drm_printf(printer, "reserved:\n");
|
||||
list_for_each_entry(block, &mgr->reserved_pages, link)
|
||||
drm_buddy_block_print(mm, block, printer);
|
||||
list_for_each_entry(rsv, &mgr->reserved_pages, blocks)
|
||||
drm_printf(printer, "%#018llx-%#018llx: %llu\n",
|
||||
rsv->start, rsv->start + rsv->size, rsv->size);
|
||||
mutex_unlock(&mgr->lock);
|
||||
}
|
||||
|
||||
|
|
|
@ -542,8 +542,15 @@ static u32 vi_get_xclk(struct amdgpu_device *adev)
|
|||
u32 reference_clock = adev->clock.spll.reference_freq;
|
||||
u32 tmp;
|
||||
|
||||
if (adev->flags & AMD_IS_APU)
|
||||
if (adev->flags & AMD_IS_APU) {
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_STONEY:
|
||||
/* vbios says 48Mhz, but the actual freq is 100Mhz */
|
||||
return 10000;
|
||||
default:
|
||||
return reference_clock;
|
||||
}
|
||||
}
|
||||
|
||||
tmp = RREG32_SMC(ixCG_CLKPIN_CNTL_2);
|
||||
if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL_2, MUX_TCLK_TO_XCLK))
|
||||
|
|
|
@ -137,7 +137,7 @@ struct _vcs_dpi_soc_bounding_box_st dcn3_2_soc = {
|
|||
.urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
|
||||
.urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
|
||||
.urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
|
||||
.pct_ideal_sdp_bw_after_urgent = 100.0,
|
||||
.pct_ideal_sdp_bw_after_urgent = 90.0,
|
||||
.pct_ideal_fabric_bw_after_urgent = 67.0,
|
||||
.pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 20.0,
|
||||
.pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0, // N/A, for now keep as is until DML implemented
|
||||
|
|
|
@ -2067,33 +2067,96 @@ static int sienna_cichlid_display_disable_memory_clock_switch(struct smu_context
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void sienna_cichlid_get_override_pcie_settings(struct smu_context *smu,
|
||||
uint32_t *gen_speed_override,
|
||||
uint32_t *lane_width_override)
|
||||
{
|
||||
struct amdgpu_device *adev = smu->adev;
|
||||
|
||||
*gen_speed_override = 0xff;
|
||||
*lane_width_override = 0xff;
|
||||
|
||||
switch (adev->pdev->device) {
|
||||
case 0x73A0:
|
||||
case 0x73A1:
|
||||
case 0x73A2:
|
||||
case 0x73A3:
|
||||
case 0x73AB:
|
||||
case 0x73AE:
|
||||
/* Bit 7:0: PCIE lane width, 1 to 7 corresponds is x1 to x32 */
|
||||
*lane_width_override = 6;
|
||||
break;
|
||||
case 0x73E0:
|
||||
case 0x73E1:
|
||||
case 0x73E3:
|
||||
*lane_width_override = 4;
|
||||
break;
|
||||
case 0x7420:
|
||||
case 0x7421:
|
||||
case 0x7422:
|
||||
case 0x7423:
|
||||
case 0x7424:
|
||||
*lane_width_override = 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static int sienna_cichlid_update_pcie_parameters(struct smu_context *smu,
|
||||
uint32_t pcie_gen_cap,
|
||||
uint32_t pcie_width_cap)
|
||||
{
|
||||
struct smu_11_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context;
|
||||
|
||||
uint32_t smu_pcie_arg;
|
||||
struct smu_11_0_pcie_table *pcie_table = &dpm_context->dpm_tables.pcie_table;
|
||||
uint32_t gen_speed_override, lane_width_override;
|
||||
uint8_t *table_member1, *table_member2;
|
||||
uint32_t min_gen_speed, max_gen_speed;
|
||||
uint32_t min_lane_width, max_lane_width;
|
||||
uint32_t smu_pcie_arg;
|
||||
int ret, i;
|
||||
|
||||
GET_PPTABLE_MEMBER(PcieGenSpeed, &table_member1);
|
||||
GET_PPTABLE_MEMBER(PcieLaneCount, &table_member2);
|
||||
|
||||
/* lclk dpm table setup */
|
||||
for (i = 0; i < MAX_PCIE_CONF; i++) {
|
||||
dpm_context->dpm_tables.pcie_table.pcie_gen[i] = table_member1[i];
|
||||
dpm_context->dpm_tables.pcie_table.pcie_lane[i] = table_member2[i];
|
||||
sienna_cichlid_get_override_pcie_settings(smu,
|
||||
&gen_speed_override,
|
||||
&lane_width_override);
|
||||
|
||||
/* PCIE gen speed override */
|
||||
if (gen_speed_override != 0xff) {
|
||||
min_gen_speed = MIN(pcie_gen_cap, gen_speed_override);
|
||||
max_gen_speed = MIN(pcie_gen_cap, gen_speed_override);
|
||||
} else {
|
||||
min_gen_speed = MAX(0, table_member1[0]);
|
||||
max_gen_speed = MIN(pcie_gen_cap, table_member1[1]);
|
||||
min_gen_speed = min_gen_speed > max_gen_speed ?
|
||||
max_gen_speed : min_gen_speed;
|
||||
}
|
||||
pcie_table->pcie_gen[0] = min_gen_speed;
|
||||
pcie_table->pcie_gen[1] = max_gen_speed;
|
||||
|
||||
/* PCIE lane width override */
|
||||
if (lane_width_override != 0xff) {
|
||||
min_lane_width = MIN(pcie_width_cap, lane_width_override);
|
||||
max_lane_width = MIN(pcie_width_cap, lane_width_override);
|
||||
} else {
|
||||
min_lane_width = MAX(1, table_member2[0]);
|
||||
max_lane_width = MIN(pcie_width_cap, table_member2[1]);
|
||||
min_lane_width = min_lane_width > max_lane_width ?
|
||||
max_lane_width : min_lane_width;
|
||||
}
|
||||
pcie_table->pcie_lane[0] = min_lane_width;
|
||||
pcie_table->pcie_lane[1] = max_lane_width;
|
||||
|
||||
for (i = 0; i < NUM_LINK_LEVELS; i++) {
|
||||
smu_pcie_arg = (i << 16) |
|
||||
((table_member1[i] <= pcie_gen_cap) ?
|
||||
(table_member1[i] << 8) :
|
||||
(pcie_gen_cap << 8)) |
|
||||
((table_member2[i] <= pcie_width_cap) ?
|
||||
table_member2[i] :
|
||||
pcie_width_cap);
|
||||
smu_pcie_arg = (i << 16 |
|
||||
pcie_table->pcie_gen[i] << 8 |
|
||||
pcie_table->pcie_lane[i]);
|
||||
|
||||
ret = smu_cmn_send_smc_msg_with_param(smu,
|
||||
SMU_MSG_OverridePcieParameters,
|
||||
|
@ -2101,11 +2164,6 @@ static int sienna_cichlid_update_pcie_parameters(struct smu_context *smu,
|
|||
NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (table_member1[i] > pcie_gen_cap)
|
||||
dpm_context->dpm_tables.pcie_table.pcie_gen[i] = pcie_gen_cap;
|
||||
if (table_member2[i] > pcie_width_cap)
|
||||
dpm_context->dpm_tables.pcie_table.pcie_lane[i] = pcie_width_cap;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -582,11 +582,11 @@ int smu_v13_0_init_power(struct smu_context *smu)
|
|||
if (smu_power->power_context || smu_power->power_context_size != 0)
|
||||
return -EINVAL;
|
||||
|
||||
smu_power->power_context = kzalloc(sizeof(struct smu_13_0_dpm_context),
|
||||
smu_power->power_context = kzalloc(sizeof(struct smu_13_0_power_context),
|
||||
GFP_KERNEL);
|
||||
if (!smu_power->power_context)
|
||||
return -ENOMEM;
|
||||
smu_power->power_context_size = sizeof(struct smu_13_0_dpm_context);
|
||||
smu_power->power_context_size = sizeof(struct smu_13_0_power_context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -119,6 +119,32 @@ static u32 skl_get_aux_clock_divider(struct intel_dp *intel_dp, int index)
|
|||
return index ? 0 : 1;
|
||||
}
|
||||
|
||||
static int intel_dp_aux_sync_len(void)
|
||||
{
|
||||
int precharge = 16; /* 10-16 */
|
||||
int preamble = 16;
|
||||
|
||||
return precharge + preamble;
|
||||
}
|
||||
|
||||
static int intel_dp_aux_fw_sync_len(void)
|
||||
{
|
||||
int precharge = 10; /* 10-16 */
|
||||
int preamble = 8;
|
||||
|
||||
return precharge + preamble;
|
||||
}
|
||||
|
||||
static int g4x_dp_aux_precharge_len(void)
|
||||
{
|
||||
int precharge_min = 10;
|
||||
int preamble = 16;
|
||||
|
||||
/* HW wants the length of the extra precharge in 2us units */
|
||||
return (intel_dp_aux_sync_len() -
|
||||
precharge_min - preamble) / 2;
|
||||
}
|
||||
|
||||
static u32 g4x_get_aux_send_ctl(struct intel_dp *intel_dp,
|
||||
int send_bytes,
|
||||
u32 aux_clock_divider)
|
||||
|
@ -141,7 +167,7 @@ static u32 g4x_get_aux_send_ctl(struct intel_dp *intel_dp,
|
|||
timeout |
|
||||
DP_AUX_CH_CTL_RECEIVE_ERROR |
|
||||
(send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) |
|
||||
(3 << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) |
|
||||
(g4x_dp_aux_precharge_len() << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) |
|
||||
(aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT);
|
||||
}
|
||||
|
||||
|
@ -165,8 +191,8 @@ static u32 skl_get_aux_send_ctl(struct intel_dp *intel_dp,
|
|||
DP_AUX_CH_CTL_TIME_OUT_MAX |
|
||||
DP_AUX_CH_CTL_RECEIVE_ERROR |
|
||||
(send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) |
|
||||
DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(24) |
|
||||
DP_AUX_CH_CTL_SYNC_PULSE_SKL(32);
|
||||
DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(intel_dp_aux_fw_sync_len()) |
|
||||
DP_AUX_CH_CTL_SYNC_PULSE_SKL(intel_dp_aux_sync_len());
|
||||
|
||||
if (intel_tc_port_in_tbt_alt_mode(dig_port))
|
||||
ret |= DP_AUX_CH_CTL_TBT_IO;
|
||||
|
|
|
@ -179,97 +179,108 @@ out_file:
|
|||
}
|
||||
|
||||
struct parallel_switch {
|
||||
struct task_struct *tsk;
|
||||
struct kthread_worker *worker;
|
||||
struct kthread_work work;
|
||||
struct intel_context *ce[2];
|
||||
int result;
|
||||
};
|
||||
|
||||
static int __live_parallel_switch1(void *data)
|
||||
static void __live_parallel_switch1(struct kthread_work *work)
|
||||
{
|
||||
struct parallel_switch *arg = data;
|
||||
struct parallel_switch *arg =
|
||||
container_of(work, typeof(*arg), work);
|
||||
IGT_TIMEOUT(end_time);
|
||||
unsigned long count;
|
||||
|
||||
count = 0;
|
||||
arg->result = 0;
|
||||
do {
|
||||
struct i915_request *rq = NULL;
|
||||
int err, n;
|
||||
int n;
|
||||
|
||||
err = 0;
|
||||
for (n = 0; !err && n < ARRAY_SIZE(arg->ce); n++) {
|
||||
for (n = 0; !arg->result && n < ARRAY_SIZE(arg->ce); n++) {
|
||||
struct i915_request *prev = rq;
|
||||
|
||||
rq = i915_request_create(arg->ce[n]);
|
||||
if (IS_ERR(rq)) {
|
||||
i915_request_put(prev);
|
||||
return PTR_ERR(rq);
|
||||
arg->result = PTR_ERR(rq);
|
||||
break;
|
||||
}
|
||||
|
||||
i915_request_get(rq);
|
||||
if (prev) {
|
||||
err = i915_request_await_dma_fence(rq, &prev->fence);
|
||||
arg->result =
|
||||
i915_request_await_dma_fence(rq,
|
||||
&prev->fence);
|
||||
i915_request_put(prev);
|
||||
}
|
||||
|
||||
i915_request_add(rq);
|
||||
}
|
||||
|
||||
if (IS_ERR_OR_NULL(rq))
|
||||
break;
|
||||
|
||||
if (i915_request_wait(rq, 0, HZ) < 0)
|
||||
err = -ETIME;
|
||||
arg->result = -ETIME;
|
||||
|
||||
i915_request_put(rq);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
count++;
|
||||
} while (!__igt_timeout(end_time, NULL));
|
||||
} while (!arg->result && !__igt_timeout(end_time, NULL));
|
||||
|
||||
pr_info("%s: %lu switches (sync)\n", arg->ce[0]->engine->name, count);
|
||||
return 0;
|
||||
pr_info("%s: %lu switches (sync) <%d>\n",
|
||||
arg->ce[0]->engine->name, count, arg->result);
|
||||
}
|
||||
|
||||
static int __live_parallel_switchN(void *data)
|
||||
static void __live_parallel_switchN(struct kthread_work *work)
|
||||
{
|
||||
struct parallel_switch *arg = data;
|
||||
struct parallel_switch *arg =
|
||||
container_of(work, typeof(*arg), work);
|
||||
struct i915_request *rq = NULL;
|
||||
IGT_TIMEOUT(end_time);
|
||||
unsigned long count;
|
||||
int n;
|
||||
|
||||
count = 0;
|
||||
arg->result = 0;
|
||||
do {
|
||||
for (n = 0; n < ARRAY_SIZE(arg->ce); n++) {
|
||||
for (n = 0; !arg->result && n < ARRAY_SIZE(arg->ce); n++) {
|
||||
struct i915_request *prev = rq;
|
||||
int err = 0;
|
||||
|
||||
rq = i915_request_create(arg->ce[n]);
|
||||
if (IS_ERR(rq)) {
|
||||
i915_request_put(prev);
|
||||
return PTR_ERR(rq);
|
||||
arg->result = PTR_ERR(rq);
|
||||
break;
|
||||
}
|
||||
|
||||
i915_request_get(rq);
|
||||
if (prev) {
|
||||
err = i915_request_await_dma_fence(rq, &prev->fence);
|
||||
arg->result =
|
||||
i915_request_await_dma_fence(rq,
|
||||
&prev->fence);
|
||||
i915_request_put(prev);
|
||||
}
|
||||
|
||||
i915_request_add(rq);
|
||||
if (err) {
|
||||
i915_request_put(rq);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
} while (!__igt_timeout(end_time, NULL));
|
||||
} while (!arg->result && !__igt_timeout(end_time, NULL));
|
||||
|
||||
if (!IS_ERR_OR_NULL(rq))
|
||||
i915_request_put(rq);
|
||||
|
||||
pr_info("%s: %lu switches (many)\n", arg->ce[0]->engine->name, count);
|
||||
return 0;
|
||||
pr_info("%s: %lu switches (many) <%d>\n",
|
||||
arg->ce[0]->engine->name, count, arg->result);
|
||||
}
|
||||
|
||||
static int live_parallel_switch(void *arg)
|
||||
{
|
||||
struct drm_i915_private *i915 = arg;
|
||||
static int (* const func[])(void *arg) = {
|
||||
static void (* const func[])(struct kthread_work *) = {
|
||||
__live_parallel_switch1,
|
||||
__live_parallel_switchN,
|
||||
NULL,
|
||||
|
@ -277,7 +288,7 @@ static int live_parallel_switch(void *arg)
|
|||
struct parallel_switch *data = NULL;
|
||||
struct i915_gem_engines *engines;
|
||||
struct i915_gem_engines_iter it;
|
||||
int (* const *fn)(void *arg);
|
||||
void (* const *fn)(struct kthread_work *);
|
||||
struct i915_gem_context *ctx;
|
||||
struct intel_context *ce;
|
||||
struct file *file;
|
||||
|
@ -335,8 +346,10 @@ static int live_parallel_switch(void *arg)
|
|||
continue;
|
||||
|
||||
ce = intel_context_create(data[m].ce[0]->engine);
|
||||
if (IS_ERR(ce))
|
||||
if (IS_ERR(ce)) {
|
||||
err = PTR_ERR(ce);
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = intel_context_pin(ce);
|
||||
if (err) {
|
||||
|
@ -348,9 +361,24 @@ static int live_parallel_switch(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
for (n = 0; n < count; n++) {
|
||||
struct kthread_worker *worker;
|
||||
|
||||
if (!data[n].ce[0])
|
||||
continue;
|
||||
|
||||
worker = kthread_create_worker(0, "igt/parallel:%s",
|
||||
data[n].ce[0]->engine->name);
|
||||
if (IS_ERR(worker)) {
|
||||
err = PTR_ERR(worker);
|
||||
goto out;
|
||||
}
|
||||
|
||||
data[n].worker = worker;
|
||||
}
|
||||
|
||||
for (fn = func; !err && *fn; fn++) {
|
||||
struct igt_live_test t;
|
||||
int n;
|
||||
|
||||
err = igt_live_test_begin(&t, i915, __func__, "");
|
||||
if (err)
|
||||
|
@ -360,34 +388,23 @@ static int live_parallel_switch(void *arg)
|
|||
if (!data[n].ce[0])
|
||||
continue;
|
||||
|
||||
data[n].tsk = kthread_run(*fn, &data[n],
|
||||
"igt/parallel:%s",
|
||||
data[n].ce[0]->engine->name);
|
||||
if (IS_ERR(data[n].tsk)) {
|
||||
err = PTR_ERR(data[n].tsk);
|
||||
break;
|
||||
data[n].result = 0;
|
||||
kthread_init_work(&data[n].work, *fn);
|
||||
kthread_queue_work(data[n].worker, &data[n].work);
|
||||
}
|
||||
get_task_struct(data[n].tsk);
|
||||
}
|
||||
|
||||
yield(); /* start all threads before we kthread_stop() */
|
||||
|
||||
for (n = 0; n < count; n++) {
|
||||
int status;
|
||||
|
||||
if (IS_ERR_OR_NULL(data[n].tsk))
|
||||
continue;
|
||||
|
||||
status = kthread_stop(data[n].tsk);
|
||||
if (status && !err)
|
||||
err = status;
|
||||
|
||||
put_task_struct(data[n].tsk);
|
||||
data[n].tsk = NULL;
|
||||
if (data[n].ce[0]) {
|
||||
kthread_flush_work(&data[n].work);
|
||||
if (data[n].result && !err)
|
||||
err = data[n].result;
|
||||
}
|
||||
}
|
||||
|
||||
if (igt_live_test_end(&t))
|
||||
err = -EIO;
|
||||
if (igt_live_test_end(&t)) {
|
||||
err = err ?: -EIO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -399,6 +416,9 @@ out:
|
|||
intel_context_unpin(data[n].ce[m]);
|
||||
intel_context_put(data[n].ce[m]);
|
||||
}
|
||||
|
||||
if (data[n].worker)
|
||||
kthread_destroy_worker(data[n].worker);
|
||||
}
|
||||
kfree(data);
|
||||
out_file:
|
||||
|
|
|
@ -1532,8 +1532,8 @@ static int live_busywait_preempt(void *arg)
|
|||
struct drm_i915_gem_object *obj;
|
||||
struct i915_vma *vma;
|
||||
enum intel_engine_id id;
|
||||
int err = -ENOMEM;
|
||||
u32 *map;
|
||||
int err;
|
||||
|
||||
/*
|
||||
* Verify that even without HAS_LOGICAL_RING_PREEMPTION, we can
|
||||
|
@ -1541,13 +1541,17 @@ static int live_busywait_preempt(void *arg)
|
|||
*/
|
||||
|
||||
ctx_hi = kernel_context(gt->i915, NULL);
|
||||
if (!ctx_hi)
|
||||
return -ENOMEM;
|
||||
if (IS_ERR(ctx_hi))
|
||||
return PTR_ERR(ctx_hi);
|
||||
|
||||
ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
|
||||
|
||||
ctx_lo = kernel_context(gt->i915, NULL);
|
||||
if (!ctx_lo)
|
||||
if (IS_ERR(ctx_lo)) {
|
||||
err = PTR_ERR(ctx_lo);
|
||||
goto err_ctx_hi;
|
||||
}
|
||||
|
||||
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
|
||||
|
||||
obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
|
||||
|
@ -3475,12 +3479,14 @@ static int random_priority(struct rnd_state *rnd)
|
|||
|
||||
struct preempt_smoke {
|
||||
struct intel_gt *gt;
|
||||
struct kthread_work work;
|
||||
struct i915_gem_context **contexts;
|
||||
struct intel_engine_cs *engine;
|
||||
struct drm_i915_gem_object *batch;
|
||||
unsigned int ncontext;
|
||||
struct rnd_state prng;
|
||||
unsigned long count;
|
||||
int result;
|
||||
};
|
||||
|
||||
static struct i915_gem_context *smoke_context(struct preempt_smoke *smoke)
|
||||
|
@ -3540,34 +3546,31 @@ unpin:
|
|||
return err;
|
||||
}
|
||||
|
||||
static int smoke_crescendo_thread(void *arg)
|
||||
static void smoke_crescendo_work(struct kthread_work *work)
|
||||
{
|
||||
struct preempt_smoke *smoke = arg;
|
||||
struct preempt_smoke *smoke = container_of(work, typeof(*smoke), work);
|
||||
IGT_TIMEOUT(end_time);
|
||||
unsigned long count;
|
||||
|
||||
count = 0;
|
||||
do {
|
||||
struct i915_gem_context *ctx = smoke_context(smoke);
|
||||
int err;
|
||||
|
||||
err = smoke_submit(smoke,
|
||||
ctx, count % I915_PRIORITY_MAX,
|
||||
smoke->result = smoke_submit(smoke, ctx,
|
||||
count % I915_PRIORITY_MAX,
|
||||
smoke->batch);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
count++;
|
||||
} while (count < smoke->ncontext && !__igt_timeout(end_time, NULL));
|
||||
} while (!smoke->result && count < smoke->ncontext &&
|
||||
!__igt_timeout(end_time, NULL));
|
||||
|
||||
smoke->count = count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags)
|
||||
#define BATCH BIT(0)
|
||||
{
|
||||
struct task_struct *tsk[I915_NUM_ENGINES] = {};
|
||||
struct kthread_worker *worker[I915_NUM_ENGINES] = {};
|
||||
struct preempt_smoke *arg;
|
||||
struct intel_engine_cs *engine;
|
||||
enum intel_engine_id id;
|
||||
|
@ -3578,6 +3581,8 @@ static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags)
|
|||
if (!arg)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(arg, 0, I915_NUM_ENGINES * sizeof(*arg));
|
||||
|
||||
for_each_engine(engine, smoke->gt, id) {
|
||||
arg[id] = *smoke;
|
||||
arg[id].engine = engine;
|
||||
|
@ -3585,31 +3590,28 @@ static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags)
|
|||
arg[id].batch = NULL;
|
||||
arg[id].count = 0;
|
||||
|
||||
tsk[id] = kthread_run(smoke_crescendo_thread, arg,
|
||||
"igt/smoke:%d", id);
|
||||
if (IS_ERR(tsk[id])) {
|
||||
err = PTR_ERR(tsk[id]);
|
||||
worker[id] = kthread_create_worker(0, "igt/smoke:%d", id);
|
||||
if (IS_ERR(worker[id])) {
|
||||
err = PTR_ERR(worker[id]);
|
||||
break;
|
||||
}
|
||||
get_task_struct(tsk[id]);
|
||||
}
|
||||
|
||||
yield(); /* start all threads before we kthread_stop() */
|
||||
kthread_init_work(&arg[id].work, smoke_crescendo_work);
|
||||
kthread_queue_work(worker[id], &arg[id].work);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for_each_engine(engine, smoke->gt, id) {
|
||||
int status;
|
||||
|
||||
if (IS_ERR_OR_NULL(tsk[id]))
|
||||
if (IS_ERR_OR_NULL(worker[id]))
|
||||
continue;
|
||||
|
||||
status = kthread_stop(tsk[id]);
|
||||
if (status && !err)
|
||||
err = status;
|
||||
kthread_flush_work(&arg[id].work);
|
||||
if (arg[id].result && !err)
|
||||
err = arg[id].result;
|
||||
|
||||
count += arg[id].count;
|
||||
|
||||
put_task_struct(tsk[id]);
|
||||
kthread_destroy_worker(worker[id]);
|
||||
}
|
||||
|
||||
pr_info("Submitted %lu crescendo:%x requests across %d engines and %d contexts\n",
|
||||
|
|
|
@ -866,10 +866,13 @@ static int igt_reset_active_engine(void *arg)
|
|||
}
|
||||
|
||||
struct active_engine {
|
||||
struct task_struct *task;
|
||||
struct kthread_worker *worker;
|
||||
struct kthread_work work;
|
||||
struct intel_engine_cs *engine;
|
||||
unsigned long resets;
|
||||
unsigned int flags;
|
||||
bool stop;
|
||||
int result;
|
||||
};
|
||||
|
||||
#define TEST_ACTIVE BIT(0)
|
||||
|
@ -900,10 +903,10 @@ static int active_request_put(struct i915_request *rq)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int active_engine(void *data)
|
||||
static void active_engine(struct kthread_work *work)
|
||||
{
|
||||
I915_RND_STATE(prng);
|
||||
struct active_engine *arg = data;
|
||||
struct active_engine *arg = container_of(work, typeof(*arg), work);
|
||||
struct intel_engine_cs *engine = arg->engine;
|
||||
struct i915_request *rq[8] = {};
|
||||
struct intel_context *ce[ARRAY_SIZE(rq)];
|
||||
|
@ -913,16 +916,17 @@ static int active_engine(void *data)
|
|||
for (count = 0; count < ARRAY_SIZE(ce); count++) {
|
||||
ce[count] = intel_context_create(engine);
|
||||
if (IS_ERR(ce[count])) {
|
||||
err = PTR_ERR(ce[count]);
|
||||
pr_err("[%s] Create context #%ld failed: %d!\n", engine->name, count, err);
|
||||
arg->result = PTR_ERR(ce[count]);
|
||||
pr_err("[%s] Create context #%ld failed: %d!\n",
|
||||
engine->name, count, arg->result);
|
||||
while (--count)
|
||||
intel_context_put(ce[count]);
|
||||
return err;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
while (!kthread_should_stop()) {
|
||||
while (!READ_ONCE(arg->stop)) {
|
||||
unsigned int idx = count++ & (ARRAY_SIZE(rq) - 1);
|
||||
struct i915_request *old = rq[idx];
|
||||
struct i915_request *new;
|
||||
|
@ -967,7 +971,7 @@ static int active_engine(void *data)
|
|||
intel_context_put(ce[count]);
|
||||
}
|
||||
|
||||
return err;
|
||||
arg->result = err;
|
||||
}
|
||||
|
||||
static int __igt_reset_engines(struct intel_gt *gt,
|
||||
|
@ -1022,7 +1026,7 @@ static int __igt_reset_engines(struct intel_gt *gt,
|
|||
|
||||
memset(threads, 0, sizeof(*threads) * I915_NUM_ENGINES);
|
||||
for_each_engine(other, gt, tmp) {
|
||||
struct task_struct *tsk;
|
||||
struct kthread_worker *worker;
|
||||
|
||||
threads[tmp].resets =
|
||||
i915_reset_engine_count(global, other);
|
||||
|
@ -1036,19 +1040,21 @@ static int __igt_reset_engines(struct intel_gt *gt,
|
|||
threads[tmp].engine = other;
|
||||
threads[tmp].flags = flags;
|
||||
|
||||
tsk = kthread_run(active_engine, &threads[tmp],
|
||||
"igt/%s", other->name);
|
||||
if (IS_ERR(tsk)) {
|
||||
err = PTR_ERR(tsk);
|
||||
pr_err("[%s] Thread spawn failed: %d!\n", engine->name, err);
|
||||
worker = kthread_create_worker(0, "igt/%s",
|
||||
other->name);
|
||||
if (IS_ERR(worker)) {
|
||||
err = PTR_ERR(worker);
|
||||
pr_err("[%s] Worker create failed: %d!\n",
|
||||
engine->name, err);
|
||||
goto unwind;
|
||||
}
|
||||
|
||||
threads[tmp].task = tsk;
|
||||
get_task_struct(tsk);
|
||||
}
|
||||
threads[tmp].worker = worker;
|
||||
|
||||
yield(); /* start all threads before we begin */
|
||||
kthread_init_work(&threads[tmp].work, active_engine);
|
||||
kthread_queue_work(threads[tmp].worker,
|
||||
&threads[tmp].work);
|
||||
}
|
||||
|
||||
st_engine_heartbeat_disable_no_pm(engine);
|
||||
GEM_BUG_ON(test_and_set_bit(I915_RESET_ENGINE + id,
|
||||
|
@ -1197,17 +1203,20 @@ unwind:
|
|||
for_each_engine(other, gt, tmp) {
|
||||
int ret;
|
||||
|
||||
if (!threads[tmp].task)
|
||||
if (!threads[tmp].worker)
|
||||
continue;
|
||||
|
||||
ret = kthread_stop(threads[tmp].task);
|
||||
WRITE_ONCE(threads[tmp].stop, true);
|
||||
kthread_flush_work(&threads[tmp].work);
|
||||
ret = READ_ONCE(threads[tmp].result);
|
||||
if (ret) {
|
||||
pr_err("kthread for other engine %s failed, err=%d\n",
|
||||
other->name, ret);
|
||||
if (!err)
|
||||
err = ret;
|
||||
}
|
||||
put_task_struct(threads[tmp].task);
|
||||
|
||||
kthread_destroy_worker(threads[tmp].worker);
|
||||
|
||||
/* GuC based resets are not logged per engine */
|
||||
if (!using_guc) {
|
||||
|
|
|
@ -299,9 +299,18 @@ __live_request_alloc(struct intel_context *ce)
|
|||
return intel_context_create_request(ce);
|
||||
}
|
||||
|
||||
static int __igt_breadcrumbs_smoketest(void *arg)
|
||||
struct smoke_thread {
|
||||
struct kthread_worker *worker;
|
||||
struct kthread_work work;
|
||||
struct smoketest *t;
|
||||
bool stop;
|
||||
int result;
|
||||
};
|
||||
|
||||
static void __igt_breadcrumbs_smoketest(struct kthread_work *work)
|
||||
{
|
||||
struct smoketest *t = arg;
|
||||
struct smoke_thread *thread = container_of(work, typeof(*thread), work);
|
||||
struct smoketest *t = thread->t;
|
||||
const unsigned int max_batch = min(t->ncontexts, t->max_batch) - 1;
|
||||
const unsigned int total = 4 * t->ncontexts + 1;
|
||||
unsigned int num_waits = 0, num_fences = 0;
|
||||
|
@ -320,8 +329,10 @@ static int __igt_breadcrumbs_smoketest(void *arg)
|
|||
*/
|
||||
|
||||
requests = kcalloc(total, sizeof(*requests), GFP_KERNEL);
|
||||
if (!requests)
|
||||
return -ENOMEM;
|
||||
if (!requests) {
|
||||
thread->result = -ENOMEM;
|
||||
return;
|
||||
}
|
||||
|
||||
order = i915_random_order(total, &prng);
|
||||
if (!order) {
|
||||
|
@ -329,7 +340,7 @@ static int __igt_breadcrumbs_smoketest(void *arg)
|
|||
goto out_requests;
|
||||
}
|
||||
|
||||
while (!kthread_should_stop()) {
|
||||
while (!READ_ONCE(thread->stop)) {
|
||||
struct i915_sw_fence *submit, *wait;
|
||||
unsigned int n, count;
|
||||
|
||||
|
@ -437,7 +448,7 @@ static int __igt_breadcrumbs_smoketest(void *arg)
|
|||
kfree(order);
|
||||
out_requests:
|
||||
kfree(requests);
|
||||
return err;
|
||||
thread->result = err;
|
||||
}
|
||||
|
||||
static int mock_breadcrumbs_smoketest(void *arg)
|
||||
|
@ -450,7 +461,7 @@ static int mock_breadcrumbs_smoketest(void *arg)
|
|||
.request_alloc = __mock_request_alloc
|
||||
};
|
||||
unsigned int ncpus = num_online_cpus();
|
||||
struct task_struct **threads;
|
||||
struct smoke_thread *threads;
|
||||
unsigned int n;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -479,28 +490,37 @@ static int mock_breadcrumbs_smoketest(void *arg)
|
|||
}
|
||||
|
||||
for (n = 0; n < ncpus; n++) {
|
||||
threads[n] = kthread_run(__igt_breadcrumbs_smoketest,
|
||||
&t, "igt/%d", n);
|
||||
if (IS_ERR(threads[n])) {
|
||||
ret = PTR_ERR(threads[n]);
|
||||
struct kthread_worker *worker;
|
||||
|
||||
worker = kthread_create_worker(0, "igt/%d", n);
|
||||
if (IS_ERR(worker)) {
|
||||
ret = PTR_ERR(worker);
|
||||
ncpus = n;
|
||||
break;
|
||||
}
|
||||
|
||||
get_task_struct(threads[n]);
|
||||
threads[n].worker = worker;
|
||||
threads[n].t = &t;
|
||||
threads[n].stop = false;
|
||||
threads[n].result = 0;
|
||||
|
||||
kthread_init_work(&threads[n].work,
|
||||
__igt_breadcrumbs_smoketest);
|
||||
kthread_queue_work(worker, &threads[n].work);
|
||||
}
|
||||
|
||||
yield(); /* start all threads before we begin */
|
||||
drm_msleep(jiffies_to_msecs(i915_selftest.timeout_jiffies));
|
||||
|
||||
for (n = 0; n < ncpus; n++) {
|
||||
int err;
|
||||
|
||||
err = kthread_stop(threads[n]);
|
||||
WRITE_ONCE(threads[n].stop, true);
|
||||
kthread_flush_work(&threads[n].work);
|
||||
err = READ_ONCE(threads[n].result);
|
||||
if (err < 0 && !ret)
|
||||
ret = err;
|
||||
|
||||
put_task_struct(threads[n]);
|
||||
kthread_destroy_worker(threads[n].worker);
|
||||
}
|
||||
pr_info("Completed %lu waits for %lu fence across %d cpus\n",
|
||||
atomic_long_read(&t.num_waits),
|
||||
|
@ -1419,9 +1439,18 @@ out_free:
|
|||
return err;
|
||||
}
|
||||
|
||||
static int __live_parallel_engine1(void *arg)
|
||||
struct parallel_thread {
|
||||
struct kthread_worker *worker;
|
||||
struct kthread_work work;
|
||||
struct intel_engine_cs *engine;
|
||||
int result;
|
||||
};
|
||||
|
||||
static void __live_parallel_engine1(struct kthread_work *work)
|
||||
{
|
||||
struct intel_engine_cs *engine = arg;
|
||||
struct parallel_thread *thread =
|
||||
container_of(work, typeof(*thread), work);
|
||||
struct intel_engine_cs *engine = thread->engine;
|
||||
IGT_TIMEOUT(end_time);
|
||||
unsigned long count;
|
||||
int err = 0;
|
||||
|
@ -1452,12 +1481,14 @@ static int __live_parallel_engine1(void *arg)
|
|||
intel_engine_pm_put(engine);
|
||||
|
||||
pr_info("%s: %lu request + sync\n", engine->name, count);
|
||||
return err;
|
||||
thread->result = err;
|
||||
}
|
||||
|
||||
static int __live_parallel_engineN(void *arg)
|
||||
static void __live_parallel_engineN(struct kthread_work *work)
|
||||
{
|
||||
struct intel_engine_cs *engine = arg;
|
||||
struct parallel_thread *thread =
|
||||
container_of(work, typeof(*thread), work);
|
||||
struct intel_engine_cs *engine = thread->engine;
|
||||
IGT_TIMEOUT(end_time);
|
||||
unsigned long count;
|
||||
int err = 0;
|
||||
|
@ -1479,7 +1510,7 @@ static int __live_parallel_engineN(void *arg)
|
|||
intel_engine_pm_put(engine);
|
||||
|
||||
pr_info("%s: %lu requests\n", engine->name, count);
|
||||
return err;
|
||||
thread->result = err;
|
||||
}
|
||||
|
||||
static bool wake_all(struct drm_i915_private *i915)
|
||||
|
@ -1505,9 +1536,11 @@ static int wait_for_all(struct drm_i915_private *i915)
|
|||
return -ETIME;
|
||||
}
|
||||
|
||||
static int __live_parallel_spin(void *arg)
|
||||
static void __live_parallel_spin(struct kthread_work *work)
|
||||
{
|
||||
struct intel_engine_cs *engine = arg;
|
||||
struct parallel_thread *thread =
|
||||
container_of(work, typeof(*thread), work);
|
||||
struct intel_engine_cs *engine = thread->engine;
|
||||
struct igt_spinner spin;
|
||||
struct i915_request *rq;
|
||||
int err = 0;
|
||||
|
@ -1520,7 +1553,8 @@ static int __live_parallel_spin(void *arg)
|
|||
|
||||
if (igt_spinner_init(&spin, engine->gt)) {
|
||||
wake_all(engine->i915);
|
||||
return -ENOMEM;
|
||||
thread->result = -ENOMEM;
|
||||
return;
|
||||
}
|
||||
|
||||
intel_engine_pm_get(engine);
|
||||
|
@ -1553,22 +1587,22 @@ static int __live_parallel_spin(void *arg)
|
|||
|
||||
out_spin:
|
||||
igt_spinner_fini(&spin);
|
||||
return err;
|
||||
thread->result = err;
|
||||
}
|
||||
|
||||
static int live_parallel_engines(void *arg)
|
||||
{
|
||||
struct drm_i915_private *i915 = arg;
|
||||
static int (* const func[])(void *arg) = {
|
||||
static void (* const func[])(struct kthread_work *) = {
|
||||
__live_parallel_engine1,
|
||||
__live_parallel_engineN,
|
||||
__live_parallel_spin,
|
||||
NULL,
|
||||
};
|
||||
const unsigned int nengines = num_uabi_engines(i915);
|
||||
struct parallel_thread *threads;
|
||||
struct intel_engine_cs *engine;
|
||||
int (* const *fn)(void *arg);
|
||||
struct task_struct **tsk;
|
||||
void (* const *fn)(struct kthread_work *);
|
||||
int err = 0;
|
||||
|
||||
/*
|
||||
|
@ -1576,8 +1610,8 @@ static int live_parallel_engines(void *arg)
|
|||
* tests that we load up the system maximally.
|
||||
*/
|
||||
|
||||
tsk = kcalloc(nengines, sizeof(*tsk), GFP_KERNEL);
|
||||
if (!tsk)
|
||||
threads = kcalloc(nengines, sizeof(*threads), GFP_KERNEL);
|
||||
if (!threads)
|
||||
return -ENOMEM;
|
||||
|
||||
for (fn = func; !err && *fn; fn++) {
|
||||
|
@ -1594,37 +1628,44 @@ static int live_parallel_engines(void *arg)
|
|||
|
||||
idx = 0;
|
||||
for_each_uabi_engine(engine, i915) {
|
||||
tsk[idx] = kthread_run(*fn, engine,
|
||||
"igt/parallel:%s",
|
||||
struct kthread_worker *worker;
|
||||
|
||||
worker = kthread_create_worker(0, "igt/parallel:%s",
|
||||
engine->name);
|
||||
if (IS_ERR(tsk[idx])) {
|
||||
err = PTR_ERR(tsk[idx]);
|
||||
if (IS_ERR(worker)) {
|
||||
err = PTR_ERR(worker);
|
||||
break;
|
||||
}
|
||||
get_task_struct(tsk[idx++]);
|
||||
}
|
||||
|
||||
yield(); /* start all threads before we kthread_stop() */
|
||||
threads[idx].worker = worker;
|
||||
threads[idx].result = 0;
|
||||
threads[idx].engine = engine;
|
||||
|
||||
kthread_init_work(&threads[idx].work, *fn);
|
||||
kthread_queue_work(worker, &threads[idx].work);
|
||||
idx++;
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
for_each_uabi_engine(engine, i915) {
|
||||
int status;
|
||||
|
||||
if (IS_ERR(tsk[idx]))
|
||||
if (!threads[idx].worker)
|
||||
break;
|
||||
|
||||
status = kthread_stop(tsk[idx]);
|
||||
kthread_flush_work(&threads[idx].work);
|
||||
status = READ_ONCE(threads[idx].result);
|
||||
if (status && !err)
|
||||
err = status;
|
||||
|
||||
put_task_struct(tsk[idx++]);
|
||||
kthread_destroy_worker(threads[idx++].worker);
|
||||
}
|
||||
|
||||
if (igt_live_test_end(&t))
|
||||
err = -EIO;
|
||||
}
|
||||
|
||||
kfree(tsk);
|
||||
kfree(threads);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1672,7 +1713,7 @@ static int live_breadcrumbs_smoketest(void *arg)
|
|||
const unsigned int ncpus = num_online_cpus();
|
||||
unsigned long num_waits, num_fences;
|
||||
struct intel_engine_cs *engine;
|
||||
struct task_struct **threads;
|
||||
struct smoke_thread *threads;
|
||||
struct igt_live_test live;
|
||||
intel_wakeref_t wakeref;
|
||||
struct smoketest *smoke;
|
||||
|
@ -1746,23 +1787,26 @@ static int live_breadcrumbs_smoketest(void *arg)
|
|||
smoke[idx].max_batch, engine->name);
|
||||
|
||||
for (n = 0; n < ncpus; n++) {
|
||||
struct task_struct *tsk;
|
||||
unsigned int i = idx * ncpus + n;
|
||||
struct kthread_worker *worker;
|
||||
|
||||
tsk = kthread_run(__igt_breadcrumbs_smoketest,
|
||||
&smoke[idx], "igt/%d.%d", idx, n);
|
||||
if (IS_ERR(tsk)) {
|
||||
ret = PTR_ERR(tsk);
|
||||
worker = kthread_create_worker(0, "igt/%d.%d", idx, n);
|
||||
if (IS_ERR(worker)) {
|
||||
ret = PTR_ERR(worker);
|
||||
goto out_flush;
|
||||
}
|
||||
|
||||
get_task_struct(tsk);
|
||||
threads[idx * ncpus + n] = tsk;
|
||||
threads[i].worker = worker;
|
||||
threads[i].t = &smoke[idx];
|
||||
|
||||
kthread_init_work(&threads[i].work,
|
||||
__igt_breadcrumbs_smoketest);
|
||||
kthread_queue_work(worker, &threads[i].work);
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
yield(); /* start all threads before we begin */
|
||||
drm_msleep(jiffies_to_msecs(i915_selftest.timeout_jiffies));
|
||||
|
||||
out_flush:
|
||||
|
@ -1771,17 +1815,19 @@ out_flush:
|
|||
num_fences = 0;
|
||||
for_each_uabi_engine(engine, i915) {
|
||||
for (n = 0; n < ncpus; n++) {
|
||||
struct task_struct *tsk = threads[idx * ncpus + n];
|
||||
unsigned int i = idx * ncpus + n;
|
||||
int err;
|
||||
|
||||
if (!tsk)
|
||||
if (!threads[i].worker)
|
||||
continue;
|
||||
|
||||
err = kthread_stop(tsk);
|
||||
WRITE_ONCE(threads[i].stop, true);
|
||||
kthread_flush_work(&threads[i].work);
|
||||
err = READ_ONCE(threads[i].result);
|
||||
if (err < 0 && !ret)
|
||||
ret = err;
|
||||
|
||||
put_task_struct(tsk);
|
||||
kthread_destroy_worker(threads[i].worker);
|
||||
}
|
||||
|
||||
num_waits += atomic_long_read(&smoke[idx].num_waits);
|
||||
|
@ -2891,9 +2937,18 @@ out:
|
|||
return err;
|
||||
}
|
||||
|
||||
static int p_sync0(void *arg)
|
||||
struct p_thread {
|
||||
struct perf_stats p;
|
||||
struct kthread_worker *worker;
|
||||
struct kthread_work work;
|
||||
struct intel_engine_cs *engine;
|
||||
int result;
|
||||
};
|
||||
|
||||
static void p_sync0(struct kthread_work *work)
|
||||
{
|
||||
struct perf_stats *p = arg;
|
||||
struct p_thread *thread = container_of(work, typeof(*thread), work);
|
||||
struct perf_stats *p = &thread->p;
|
||||
struct intel_engine_cs *engine = p->engine;
|
||||
struct intel_context *ce;
|
||||
IGT_TIMEOUT(end_time);
|
||||
|
@ -2902,13 +2957,16 @@ static int p_sync0(void *arg)
|
|||
int err = 0;
|
||||
|
||||
ce = intel_context_create(engine);
|
||||
if (IS_ERR(ce))
|
||||
return PTR_ERR(ce);
|
||||
if (IS_ERR(ce)) {
|
||||
thread->result = PTR_ERR(ce);
|
||||
return;
|
||||
}
|
||||
|
||||
err = intel_context_pin(ce);
|
||||
if (err) {
|
||||
intel_context_put(ce);
|
||||
return err;
|
||||
thread->result = err;
|
||||
return;
|
||||
}
|
||||
|
||||
if (intel_engine_supports_stats(engine)) {
|
||||
|
@ -2958,12 +3016,13 @@ static int p_sync0(void *arg)
|
|||
|
||||
intel_context_unpin(ce);
|
||||
intel_context_put(ce);
|
||||
return err;
|
||||
thread->result = err;
|
||||
}
|
||||
|
||||
static int p_sync1(void *arg)
|
||||
static void p_sync1(struct kthread_work *work)
|
||||
{
|
||||
struct perf_stats *p = arg;
|
||||
struct p_thread *thread = container_of(work, typeof(*thread), work);
|
||||
struct perf_stats *p = &thread->p;
|
||||
struct intel_engine_cs *engine = p->engine;
|
||||
struct i915_request *prev = NULL;
|
||||
struct intel_context *ce;
|
||||
|
@ -2973,13 +3032,16 @@ static int p_sync1(void *arg)
|
|||
int err = 0;
|
||||
|
||||
ce = intel_context_create(engine);
|
||||
if (IS_ERR(ce))
|
||||
return PTR_ERR(ce);
|
||||
if (IS_ERR(ce)) {
|
||||
thread->result = PTR_ERR(ce);
|
||||
return;
|
||||
}
|
||||
|
||||
err = intel_context_pin(ce);
|
||||
if (err) {
|
||||
intel_context_put(ce);
|
||||
return err;
|
||||
thread->result = err;
|
||||
return;
|
||||
}
|
||||
|
||||
if (intel_engine_supports_stats(engine)) {
|
||||
|
@ -3031,12 +3093,13 @@ static int p_sync1(void *arg)
|
|||
|
||||
intel_context_unpin(ce);
|
||||
intel_context_put(ce);
|
||||
return err;
|
||||
thread->result = err;
|
||||
}
|
||||
|
||||
static int p_many(void *arg)
|
||||
static void p_many(struct kthread_work *work)
|
||||
{
|
||||
struct perf_stats *p = arg;
|
||||
struct p_thread *thread = container_of(work, typeof(*thread), work);
|
||||
struct perf_stats *p = &thread->p;
|
||||
struct intel_engine_cs *engine = p->engine;
|
||||
struct intel_context *ce;
|
||||
IGT_TIMEOUT(end_time);
|
||||
|
@ -3045,13 +3108,16 @@ static int p_many(void *arg)
|
|||
bool busy;
|
||||
|
||||
ce = intel_context_create(engine);
|
||||
if (IS_ERR(ce))
|
||||
return PTR_ERR(ce);
|
||||
if (IS_ERR(ce)) {
|
||||
thread->result = PTR_ERR(ce);
|
||||
return;
|
||||
}
|
||||
|
||||
err = intel_context_pin(ce);
|
||||
if (err) {
|
||||
intel_context_put(ce);
|
||||
return err;
|
||||
thread->result = err;
|
||||
return;
|
||||
}
|
||||
|
||||
if (intel_engine_supports_stats(engine)) {
|
||||
|
@ -3092,26 +3158,23 @@ static int p_many(void *arg)
|
|||
|
||||
intel_context_unpin(ce);
|
||||
intel_context_put(ce);
|
||||
return err;
|
||||
thread->result = err;
|
||||
}
|
||||
|
||||
static int perf_parallel_engines(void *arg)
|
||||
{
|
||||
struct drm_i915_private *i915 = arg;
|
||||
static int (* const func[])(void *arg) = {
|
||||
static void (* const func[])(struct kthread_work *) = {
|
||||
p_sync0,
|
||||
p_sync1,
|
||||
p_many,
|
||||
NULL,
|
||||
};
|
||||
const unsigned int nengines = num_uabi_engines(i915);
|
||||
void (* const *fn)(struct kthread_work *);
|
||||
struct intel_engine_cs *engine;
|
||||
int (* const *fn)(void *arg);
|
||||
struct pm_qos_request qos;
|
||||
struct {
|
||||
struct perf_stats p;
|
||||
struct task_struct *tsk;
|
||||
} *engines;
|
||||
struct p_thread *engines;
|
||||
int err = 0;
|
||||
|
||||
engines = kcalloc(nengines, sizeof(*engines), GFP_KERNEL);
|
||||
|
@ -3134,36 +3197,45 @@ static int perf_parallel_engines(void *arg)
|
|||
|
||||
idx = 0;
|
||||
for_each_uabi_engine(engine, i915) {
|
||||
struct kthread_worker *worker;
|
||||
|
||||
intel_engine_pm_get(engine);
|
||||
|
||||
memset(&engines[idx].p, 0, sizeof(engines[idx].p));
|
||||
engines[idx].p.engine = engine;
|
||||
|
||||
engines[idx].tsk = kthread_run(*fn, &engines[idx].p,
|
||||
"igt:%s", engine->name);
|
||||
if (IS_ERR(engines[idx].tsk)) {
|
||||
err = PTR_ERR(engines[idx].tsk);
|
||||
worker = kthread_create_worker(0, "igt:%s",
|
||||
engine->name);
|
||||
if (IS_ERR(worker)) {
|
||||
err = PTR_ERR(worker);
|
||||
intel_engine_pm_put(engine);
|
||||
break;
|
||||
}
|
||||
get_task_struct(engines[idx++].tsk);
|
||||
}
|
||||
engines[idx].worker = worker;
|
||||
engines[idx].result = 0;
|
||||
engines[idx].p.engine = engine;
|
||||
engines[idx].engine = engine;
|
||||
|
||||
yield(); /* start all threads before we kthread_stop() */
|
||||
kthread_init_work(&engines[idx].work, *fn);
|
||||
kthread_queue_work(worker, &engines[idx].work);
|
||||
idx++;
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
for_each_uabi_engine(engine, i915) {
|
||||
int status;
|
||||
|
||||
if (IS_ERR(engines[idx].tsk))
|
||||
if (!engines[idx].worker)
|
||||
break;
|
||||
|
||||
status = kthread_stop(engines[idx].tsk);
|
||||
kthread_flush_work(&engines[idx].work);
|
||||
status = READ_ONCE(engines[idx].result);
|
||||
if (status && !err)
|
||||
err = status;
|
||||
|
||||
intel_engine_pm_put(engine);
|
||||
put_task_struct(engines[idx++].tsk);
|
||||
|
||||
kthread_destroy_worker(engines[idx].worker);
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (igt_live_test_end(&t))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sched_bsd.c,v 1.74 2023/02/04 19:33:03 cheloha Exp $ */
|
||||
/* $OpenBSD: sched_bsd.c,v 1.75 2023/06/20 16:30:30 cheloha Exp $ */
|
||||
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -234,7 +234,6 @@ schedcpu(void *arg)
|
|||
}
|
||||
SCHED_UNLOCK(s);
|
||||
}
|
||||
uvm_meter();
|
||||
wakeup(&lbolt);
|
||||
timeout_add_sec(to, 1);
|
||||
}
|
||||
|
@ -669,6 +668,7 @@ scheduler_start(void)
|
|||
|
||||
rrticks_init = hz / 10;
|
||||
schedcpu(&schedcpu_to);
|
||||
uvm_meter(NULL);
|
||||
|
||||
#ifndef SMALL_KERNEL
|
||||
if (perfpolicy == PERFPOL_AUTO)
|
||||
|
|
|
@ -76,7 +76,7 @@ struct bootp {
|
|||
*/
|
||||
#define VM_RFC1048 { 99, 130, 83, 99 }
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* RFC1048 tag values used to specify what information is being supplied in
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: uvm_extern.h,v 1.168 2023/05/30 08:30:01 jsg Exp $ */
|
||||
/* $OpenBSD: uvm_extern.h,v 1.169 2023/06/20 16:30:30 cheloha Exp $ */
|
||||
/* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -414,7 +414,7 @@ void uvmspace_free(struct vmspace *);
|
|||
struct vmspace *uvmspace_share(struct process *);
|
||||
int uvm_share(vm_map_t, vaddr_t, vm_prot_t,
|
||||
vm_map_t, vaddr_t, vsize_t);
|
||||
void uvm_meter(void);
|
||||
void uvm_meter(void *);
|
||||
int uvm_sysctl(int *, u_int, void *, size_t *,
|
||||
void *, size_t, struct proc *);
|
||||
struct vm_page *uvm_pagealloc(struct uvm_object *,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: uvm_meter.c,v 1.42 2020/12/28 14:01:23 mpi Exp $ */
|
||||
/* $OpenBSD: uvm_meter.c,v 1.43 2023/06/20 16:30:30 cheloha Exp $ */
|
||||
/* $NetBSD: uvm_meter.c,v 1.21 2001/07/14 06:36:03 matt Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -65,6 +65,9 @@
|
|||
int maxslp = MAXSLP; /* patchable ... */
|
||||
struct loadavg averunnable;
|
||||
|
||||
#define UVM_METER_INTVL 5
|
||||
struct timeout uvm_meter_to = TIMEOUT_INITIALIZER(uvm_meter, NULL);
|
||||
|
||||
/*
|
||||
* constants for averages over 1, 5, and 15 minutes when sampling at
|
||||
* 5 second intervals.
|
||||
|
@ -82,15 +85,13 @@ void uvm_total(struct vmtotal *);
|
|||
void uvmexp_read(struct uvmexp *);
|
||||
|
||||
/*
|
||||
* uvm_meter: calculate load average and wake up the swapper (if needed)
|
||||
* uvm_meter: recompute load averages
|
||||
*/
|
||||
void
|
||||
uvm_meter(void)
|
||||
uvm_meter(void *unused)
|
||||
{
|
||||
if ((gettime() % 5) == 0)
|
||||
timeout_add_sec(&uvm_meter_to, UVM_METER_INTVL);
|
||||
uvm_loadav(&averunnable);
|
||||
if (proc0.p_slptime > (maxslp / 2))
|
||||
wakeup(&proc0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ssh-keygen.c,v 1.467 2023/04/12 08:53:54 jsg Exp $ */
|
||||
/* $OpenBSD: ssh-keygen.c,v 1.468 2023/06/20 00:05:09 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -976,6 +976,7 @@ do_fingerprint(struct passwd *pw)
|
|||
* accept a public key prefixed with a hostname or options.
|
||||
* Try a bare key first, otherwise skip the leading stuff.
|
||||
*/
|
||||
comment = NULL;
|
||||
if ((public = try_read_key(&cp)) == NULL) {
|
||||
i = strtol(cp, &ep, 10);
|
||||
if (i == 0 || ep == NULL ||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: auth.c,v 1.20 2015/05/05 01:26:37 jsg Exp $ */
|
||||
/* $OpenBSD: auth.c,v 1.21 2023/06/20 15:19:55 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
|
||||
|
@ -141,36 +141,45 @@ auth_gen(struct ibuf *buf, struct iface *iface)
|
|||
{
|
||||
MD5_CTX hash;
|
||||
u_int8_t digest[MD5_DIGEST_LENGTH];
|
||||
struct ospf_hdr *ospf_hdr;
|
||||
struct crypt crypt;
|
||||
struct auth_md *md;
|
||||
|
||||
if ((ospf_hdr = ibuf_seek(buf, 0, sizeof(*ospf_hdr))) == NULL)
|
||||
fatalx("auth_gen: buf_seek failed");
|
||||
u_int16_t chksum;
|
||||
|
||||
/* update length */
|
||||
if (ibuf_size(buf) > USHRT_MAX)
|
||||
fatalx("auth_gen: resulting ospf packet too big");
|
||||
ospf_hdr->len = htons(ibuf_size(buf));
|
||||
/* clear auth_key field */
|
||||
bzero(ospf_hdr->auth_key.simple, sizeof(ospf_hdr->auth_key.simple));
|
||||
if (ibuf_set_n16(buf, offsetof(struct ospf_hdr, len),
|
||||
ibuf_size(buf)) == -1)
|
||||
fatalx("auth_gen: ibuf_set_n16 failed");
|
||||
|
||||
switch (iface->auth_type) {
|
||||
case AUTH_NONE:
|
||||
ospf_hdr->chksum = in_cksum(buf->buf, ibuf_size(buf));
|
||||
chksum = in_cksum(buf->buf, ibuf_size(buf));
|
||||
if (ibuf_set(buf, offsetof(struct ospf_hdr, chksum),
|
||||
&chksum, sizeof(chksum)) == -1)
|
||||
fatalx("auth_gen: ibuf_set failed");
|
||||
break;
|
||||
case AUTH_SIMPLE:
|
||||
ospf_hdr->chksum = in_cksum(buf->buf, ibuf_size(buf));
|
||||
chksum = in_cksum(buf->buf, ibuf_size(buf));
|
||||
if (ibuf_set(buf, offsetof(struct ospf_hdr, chksum),
|
||||
&chksum, sizeof(chksum)) == -1)
|
||||
fatalx("auth_gen: ibuf_set failed");
|
||||
|
||||
strncpy(ospf_hdr->auth_key.simple, iface->auth_key,
|
||||
sizeof(ospf_hdr->auth_key.simple));
|
||||
if (ibuf_set(buf, offsetof(struct ospf_hdr, auth_key),
|
||||
iface->auth_key, strlen(iface->auth_key)) == -1)
|
||||
fatalx("auth_gen: ibuf_set failed");
|
||||
break;
|
||||
case AUTH_CRYPT:
|
||||
ospf_hdr->chksum = 0;
|
||||
ospf_hdr->auth_key.crypt.keyid = iface->auth_keyid;
|
||||
ospf_hdr->auth_key.crypt.seq_num = htonl(iface->crypt_seq_num);
|
||||
ospf_hdr->auth_key.crypt.len = MD5_DIGEST_LENGTH;
|
||||
bzero(&crypt, sizeof(crypt));
|
||||
crypt.keyid = iface->auth_keyid;
|
||||
crypt.seq_num = htonl(iface->crypt_seq_num);
|
||||
crypt.len = MD5_DIGEST_LENGTH;
|
||||
iface->crypt_seq_num++;
|
||||
|
||||
if (ibuf_set(buf, offsetof(struct ospf_hdr, auth_key),
|
||||
&crypt, sizeof(crypt)) == -1)
|
||||
fatalx("auth_gen: ibuf_set failed");
|
||||
|
||||
/* insert plaintext key */
|
||||
if ((md = md_list_find(&iface->auth_md_list,
|
||||
iface->auth_keyid)) == NULL) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: database.c,v 1.36 2023/03/08 04:43:14 guenther Exp $ */
|
||||
/* $OpenBSD: database.c,v 1.37 2023/06/20 15:19:55 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -53,7 +53,7 @@ send_db_description(struct nbr *nbr)
|
|||
goto fail;
|
||||
|
||||
/* reserve space for database description header */
|
||||
if (ibuf_reserve(buf, sizeof(dd_hdr)) == NULL)
|
||||
if (ibuf_add_zero(buf, sizeof(dd_hdr)) == -1)
|
||||
goto fail;
|
||||
|
||||
switch (nbr->state) {
|
||||
|
@ -140,8 +140,9 @@ send_db_description(struct nbr *nbr)
|
|||
dd_hdr.bits = bits;
|
||||
dd_hdr.dd_seq_num = htonl(nbr->dd_seq_num);
|
||||
|
||||
memcpy(ibuf_seek(buf, sizeof(struct ospf_hdr), sizeof(dd_hdr)),
|
||||
&dd_hdr, sizeof(dd_hdr));
|
||||
if (ibuf_set(buf, sizeof(struct ospf_hdr), &dd_hdr,
|
||||
sizeof(dd_hdr)) == -1)
|
||||
goto fail;
|
||||
|
||||
/* update authentication and calculate checksum */
|
||||
if (auth_gen(buf, nbr->iface))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: lsupdate.c,v 1.51 2023/03/08 04:43:14 guenther Exp $ */
|
||||
/* $OpenBSD: lsupdate.c,v 1.52 2023/06/20 15:19:55 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -158,7 +158,7 @@ prepare_ls_update(struct iface *iface)
|
|||
goto fail;
|
||||
|
||||
/* reserve space for number of lsa field */
|
||||
if (ibuf_reserve(buf, sizeof(u_int32_t)) == NULL)
|
||||
if (ibuf_add_zero(buf, sizeof(u_int32_t)) == -1)
|
||||
goto fail;
|
||||
|
||||
return (buf);
|
||||
|
@ -194,8 +194,10 @@ add_ls_update(struct ibuf *buf, struct iface *iface, void *data, u_int16_t len,
|
|||
age = ntohs(age);
|
||||
if ((age += older + iface->transmit_delay) >= MAX_AGE)
|
||||
age = MAX_AGE;
|
||||
age = htons(age);
|
||||
memcpy(ibuf_seek(buf, ageoff, sizeof(age)), &age, sizeof(age));
|
||||
if (ibuf_set_n16(buf, ageoff, age) == -1) {
|
||||
log_warn("add_ls_update");
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
@ -208,9 +210,8 @@ send_ls_update(struct ibuf *buf, struct iface *iface, struct in_addr addr,
|
|||
{
|
||||
struct sockaddr_in dst;
|
||||
|
||||
nlsa = htonl(nlsa);
|
||||
memcpy(ibuf_seek(buf, sizeof(struct ospf_hdr), sizeof(nlsa)),
|
||||
&nlsa, sizeof(nlsa));
|
||||
if (ibuf_set_n32(buf, sizeof(struct ospf_hdr), nlsa) == -1)
|
||||
goto fail;
|
||||
/* update authentication and calculate checksum */
|
||||
if (auth_gen(buf, iface))
|
||||
goto fail;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ospfe.c,v 1.111 2023/03/08 04:43:14 guenther Exp $ */
|
||||
/* $OpenBSD: ospfe.c,v 1.112 2023/06/20 15:19:55 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -842,11 +842,11 @@ orig_rtr_lsa(struct area *area)
|
|||
fatal("orig_rtr_lsa");
|
||||
|
||||
/* reserve space for LSA header and LSA Router header */
|
||||
if (ibuf_reserve(buf, sizeof(lsa_hdr)) == NULL)
|
||||
fatal("orig_rtr_lsa: ibuf_reserve failed");
|
||||
if (ibuf_add_zero(buf, sizeof(lsa_hdr)) == -1)
|
||||
fatal("orig_rtr_lsa: ibuf_add_zero failed");
|
||||
|
||||
if (ibuf_reserve(buf, sizeof(lsa_rtr)) == NULL)
|
||||
fatal("orig_rtr_lsa: ibuf_reserve failed");
|
||||
if (ibuf_add_zero(buf, sizeof(lsa_rtr)) == -1)
|
||||
fatal("orig_rtr_lsa: ibuf_add_zero failed");
|
||||
|
||||
/* links */
|
||||
LIST_FOREACH(iface, &area->iface_list, entry) {
|
||||
|
@ -1083,8 +1083,9 @@ orig_rtr_lsa(struct area *area)
|
|||
|
||||
lsa_rtr.dummy = 0;
|
||||
lsa_rtr.nlinks = htons(num_links);
|
||||
memcpy(ibuf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_rtr)),
|
||||
&lsa_rtr, sizeof(lsa_rtr));
|
||||
if (ibuf_set(buf, sizeof(lsa_hdr), &lsa_rtr, sizeof(lsa_rtr)) ==
|
||||
-1)
|
||||
fatal("orig_rtr_lsa: ibuf_set failed");
|
||||
|
||||
/* LSA header */
|
||||
lsa_hdr.age = htons(DEFAULT_AGE);
|
||||
|
@ -1095,11 +1096,12 @@ orig_rtr_lsa(struct area *area)
|
|||
lsa_hdr.seq_num = htonl(INIT_SEQ_NUM);
|
||||
lsa_hdr.len = htons(ibuf_size(buf));
|
||||
lsa_hdr.ls_chksum = 0; /* updated later */
|
||||
memcpy(ibuf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
|
||||
if (ibuf_set(buf, 0, &lsa_hdr, sizeof(lsa_hdr)) == -1)
|
||||
fatal("orig_rtr_lsa: ibuf_set failed");
|
||||
|
||||
chksum = htons(iso_cksum(buf->buf, ibuf_size(buf), LS_CKSUM_OFFSET));
|
||||
memcpy(ibuf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
|
||||
&chksum, sizeof(chksum));
|
||||
chksum = iso_cksum(buf->buf, ibuf_size(buf), LS_CKSUM_OFFSET);
|
||||
if (ibuf_set_n16(buf, LS_CKSUM_OFFSET, chksum) == -1)
|
||||
fatal("orig_rtr_lsa: ibuf_set_n16 failed");
|
||||
|
||||
if (self && num_links)
|
||||
imsg_compose_event(iev_rde, IMSG_LS_UPD, self->peerid, 0,
|
||||
|
@ -1126,8 +1128,8 @@ orig_net_lsa(struct iface *iface)
|
|||
fatal("orig_net_lsa");
|
||||
|
||||
/* reserve space for LSA header and LSA Router header */
|
||||
if (ibuf_reserve(buf, sizeof(lsa_hdr)) == NULL)
|
||||
fatal("orig_net_lsa: ibuf_reserve failed");
|
||||
if (ibuf_add_zero(buf, sizeof(lsa_hdr)) == -1)
|
||||
fatal("orig_net_lsa: ibuf_add_zero failed");
|
||||
|
||||
/* LSA net mask and then all fully adjacent routers */
|
||||
if (ibuf_add(buf, &iface->mask, sizeof(iface->mask)))
|
||||
|
@ -1160,11 +1162,12 @@ orig_net_lsa(struct iface *iface)
|
|||
lsa_hdr.seq_num = htonl(INIT_SEQ_NUM);
|
||||
lsa_hdr.len = htons(ibuf_size(buf));
|
||||
lsa_hdr.ls_chksum = 0; /* updated later */
|
||||
memcpy(ibuf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
|
||||
if (ibuf_set(buf, 0, &lsa_hdr, sizeof(lsa_hdr)) == -1)
|
||||
fatal("orig_net_lsa: ibuf_set failed");
|
||||
|
||||
chksum = htons(iso_cksum(buf->buf, ibuf_size(buf), LS_CKSUM_OFFSET));
|
||||
memcpy(ibuf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
|
||||
&chksum, sizeof(chksum));
|
||||
chksum = iso_cksum(buf->buf, ibuf_size(buf), LS_CKSUM_OFFSET);
|
||||
if (ibuf_set_n16(buf, LS_CKSUM_OFFSET, chksum) == -1)
|
||||
fatal("orig_net_lsa: ibuf_set_n16 failed");
|
||||
|
||||
imsg_compose_event(iev_rde, IMSG_LS_UPD, iface->self->peerid, 0,
|
||||
-1, buf->buf, ibuf_size(buf));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#! /usr/bin/perl
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: PkgCreate.pm,v 1.191 2023/06/13 09:07:17 espie Exp $
|
||||
# $OpenBSD: PkgCreate.pm,v 1.192 2023/06/20 14:50:05 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
|
@ -1125,10 +1125,10 @@ sub print($self)
|
|||
package OpenBSD::PkgCreate;
|
||||
our @ISA = qw(OpenBSD::AddCreateDelete);
|
||||
|
||||
sub handle_fragment($self, $state, $old, $not, $frag, $, $, $msg)
|
||||
sub handle_fragment($self, $state, $old, $not, $frag, $location)
|
||||
{
|
||||
my $def = $frag;
|
||||
if ($state->{subst}->has_fragment($def, $frag, $msg)) {
|
||||
if ($state->{subst}->has_fragment($state, $def, $frag, $location)) {
|
||||
return undef if defined $not;
|
||||
} else {
|
||||
return undef unless defined $not;
|
||||
|
@ -1185,7 +1185,7 @@ sub read_fragments($self, $state, $plist, $filename)
|
|||
if ($l =~ m/^(\!)?\%\%(.*)\%\%$/) {
|
||||
$self->record_fragment($plist, $1, $2,
|
||||
$file);
|
||||
if (my $f2 = $self->handle_fragment($state, $file, $1, $2, $l, $cont, $filename)) {
|
||||
if (my $f2 = $self->handle_fragment($state, $file, $1, $2, $filename)) {
|
||||
push(@$stack, $file);
|
||||
$file = $f2;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Subst.pm,v 1.20 2023/06/13 09:07:17 espie Exp $
|
||||
# $OpenBSD: Subst.pm,v 1.21 2023/06/20 14:50:06 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2008 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
|
@ -91,18 +91,19 @@ sub copy($self, $srcname, $destname)
|
|||
return $dest;
|
||||
}
|
||||
|
||||
sub has_fragment($self, $def, $frag, $msg)
|
||||
sub has_fragment($self, $state, $def, $frag, $location)
|
||||
{
|
||||
my $v = $self->value($def);
|
||||
|
||||
if (!defined $v) {
|
||||
die "Error: unknown fragment $frag in $msg";
|
||||
$state->fatal("Unknown fragment #1 in #2",
|
||||
$frag, $location);
|
||||
} elsif ($v == 1) {
|
||||
return 1;
|
||||
} elsif ($v == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
die "Incorrect define for $frag in $msg";
|
||||
$state->fatal("Invalid fragment define #1=#2", $frag, $v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: check_tcp.c,v 1.58 2021/09/18 19:44:46 claudio Exp $ */
|
||||
/* $OpenBSD: check_tcp.c,v 1.59 2023/06/20 09:54:57 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
|
||||
|
@ -344,17 +344,14 @@ check_http_code(struct ctl_tcp_event *cte)
|
|||
char *head;
|
||||
char scode[4];
|
||||
const char *estr;
|
||||
u_char *b;
|
||||
int code;
|
||||
struct host *host;
|
||||
|
||||
/*
|
||||
* ensure string is nul-terminated.
|
||||
*/
|
||||
b = ibuf_reserve(cte->buf, 1);
|
||||
if (b == NULL)
|
||||
if (ibuf_add_zero(cte->buf, 1) == -1)
|
||||
fatal("out of memory");
|
||||
*b = '\0';
|
||||
|
||||
head = cte->buf->buf;
|
||||
host = cte->host;
|
||||
|
@ -398,17 +395,14 @@ int
|
|||
check_http_digest(struct ctl_tcp_event *cte)
|
||||
{
|
||||
char *head;
|
||||
u_char *b;
|
||||
char digest[SHA1_DIGEST_STRING_LENGTH];
|
||||
struct host *host;
|
||||
|
||||
/*
|
||||
* ensure string is nul-terminated.
|
||||
*/
|
||||
b = ibuf_reserve(cte->buf, 1);
|
||||
if (b == NULL)
|
||||
if (ibuf_add_zero(cte->buf, 1) == -1)
|
||||
fatal("out of memory");
|
||||
*b = '\0';
|
||||
|
||||
head = cte->buf->buf;
|
||||
host = cte->host;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cert.c,v 1.108 2023/05/09 10:34:32 tb Exp $ */
|
||||
/* $OpenBSD: cert.c,v 1.109 2023/06/20 12:28:08 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
|
||||
* Copyright (c) 2021 Job Snijders <job@openbsd.org>
|
||||
|
@ -596,6 +596,11 @@ cert_parse_ee_cert(const char *fn, X509 *x)
|
|||
if ((p.res = calloc(1, sizeof(struct cert))) == NULL)
|
||||
err(1, NULL);
|
||||
|
||||
if (X509_get_version(x) != 2) {
|
||||
warnx("%s: RFC 6487 4.1: X.509 version must be v3", fn);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (X509_get_key_usage(x) != KU_DIGITAL_SIGNATURE) {
|
||||
warnx("%s: RFC 6487 section 4.8.4: KU must be digitalSignature",
|
||||
fn);
|
||||
|
@ -680,6 +685,11 @@ cert_parse_pre(const char *fn, const unsigned char *der, size_t len)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (X509_get_version(x) != 2) {
|
||||
warnx("%s: RFC 6487 4.1: X.509 version must be v3", fn);
|
||||
goto out;
|
||||
}
|
||||
|
||||
X509_get0_signature(NULL, &palg, x);
|
||||
if (palg == NULL) {
|
||||
cryptowarnx("%s: X509_get0_signature", p.fn);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cms.c,v 1.36 2023/06/17 04:46:11 job Exp $ */
|
||||
/* $OpenBSD: cms.c,v 1.37 2023/06/20 02:46:18 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
|
@ -276,7 +276,7 @@ cms_parse_validate_internal(X509 **xp, const char *fn, const unsigned char *der,
|
|||
assert(octype != NULL);
|
||||
if (OBJ_cmp(obj, octype) != 0) {
|
||||
OBJ_obj2txt(buf, sizeof(buf), obj, 1);
|
||||
OBJ_obj2txt(obuf, sizeof(obuf), oid, 1);
|
||||
OBJ_obj2txt(obuf, sizeof(obuf), octype, 1);
|
||||
warnx("%s: RFC 6488: eContentType does not match Content-Type "
|
||||
"OID: %s, want %s", fn, buf, obuf);
|
||||
goto out;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: crl.c,v 1.25 2023/05/22 15:07:02 tb Exp $ */
|
||||
/* $OpenBSD: crl.c,v 1.26 2023/06/20 12:48:32 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
|
@ -51,6 +51,11 @@ crl_parse(const char *fn, const unsigned char *der, size_t len)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (X509_CRL_get_version(crl->x509_crl) != 1) {
|
||||
warnx("%s: RFC 6487 section 5: version 2 expected", fn);
|
||||
goto out;
|
||||
}
|
||||
|
||||
X509_CRL_get0_signature(crl->x509_crl, NULL, &palg);
|
||||
if (palg == NULL) {
|
||||
cryptowarnx("%s: X509_CRL_get0_signature", fn);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: gbr.c,v 1.26 2023/03/12 11:46:35 tb Exp $ */
|
||||
/* $OpenBSD: gbr.c,v 1.27 2023/06/20 12:39:50 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
|
||||
*
|
||||
|
@ -43,6 +43,7 @@ struct gbr *
|
|||
gbr_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
|
||||
{
|
||||
struct parse p;
|
||||
struct cert *cert = NULL;
|
||||
size_t cmsz;
|
||||
unsigned char *cms;
|
||||
time_t signtime = 0;
|
||||
|
@ -86,12 +87,16 @@ gbr_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if ((cert = cert_parse_ee_cert(fn, *x509)) == NULL)
|
||||
goto out;
|
||||
|
||||
return p.res;
|
||||
|
||||
out:
|
||||
gbr_free(p.res);
|
||||
X509_free(*x509);
|
||||
*x509 = NULL;
|
||||
cert_free(cert);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: http.c,v 1.76 2023/06/12 15:27:52 claudio Exp $ */
|
||||
/* $OpenBSD: http.c,v 1.77 2023/06/20 15:15:14 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
|
||||
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -2150,7 +2150,7 @@ proc_http(char *bind_addr, int fd)
|
|||
io_read_str(b, &mod);
|
||||
|
||||
/* queue up new requests */
|
||||
http_req_new(id, uri, mod, 0, b->fd);
|
||||
http_req_new(id, uri, mod, 0, ibuf_fd_get(b));
|
||||
ibuf_free(b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: io.c,v 1.22 2022/12/14 15:19:16 claudio Exp $ */
|
||||
/* $OpenBSD: io.c,v 1.23 2023/06/20 15:15:14 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
|
@ -41,7 +41,7 @@ io_new_buffer(void)
|
|||
|
||||
if ((b = ibuf_dynamic(64, INT32_MAX)) == NULL)
|
||||
err(1, NULL);
|
||||
ibuf_reserve(b, sizeof(size_t)); /* can not fail */
|
||||
ibuf_add_zero(b, sizeof(size_t)); /* can not fail */
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ io_close_buffer(struct msgbuf *msgbuf, struct ibuf *b)
|
|||
size_t len;
|
||||
|
||||
len = ibuf_size(b) - sizeof(len);
|
||||
memcpy(ibuf_seek(b, 0, sizeof(len)), &len, sizeof(len));
|
||||
ibuf_set(b, 0, &len, sizeof(len));
|
||||
ibuf_close(msgbuf, b);
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ io_buf_recvfd(int fd, struct ibuf **ib)
|
|||
for (i = 0; i < j; i++) {
|
||||
f = ((int *)CMSG_DATA(cmsg))[i];
|
||||
if (i == 0)
|
||||
b->fd = f;
|
||||
ibuf_fd_set(b, f);
|
||||
else
|
||||
close(f);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: main.c,v 1.241 2023/05/30 16:02:28 job Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.242 2023/06/20 15:15:14 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
|
@ -341,7 +341,7 @@ http_fetch(unsigned int id, const char *uri, const char *last_mod, int fd)
|
|||
io_str_buffer(b, uri);
|
||||
io_str_buffer(b, last_mod);
|
||||
/* pass file as fd */
|
||||
b->fd = fd;
|
||||
ibuf_fd_set(b, fd);
|
||||
io_close_buffer(&httpq, b);
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ rrdp_http_fetch(unsigned int id, const char *uri, const char *last_mod)
|
|||
b = io_new_buffer();
|
||||
io_simple_buffer(b, &type, sizeof(type));
|
||||
io_simple_buffer(b, &id, sizeof(id));
|
||||
b->fd = pi[0];
|
||||
ibuf_fd_set(b, pi[0]);
|
||||
io_close_buffer(&rrdpq, b);
|
||||
|
||||
http_fetch(id, uri, last_mod, pi[1]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: mft.c,v 1.94 2023/06/07 10:46:34 job Exp $ */
|
||||
/* $OpenBSD: mft.c,v 1.95 2023/06/20 12:39:50 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
|
@ -353,6 +353,7 @@ struct mft *
|
|||
mft_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
|
||||
{
|
||||
struct parse p;
|
||||
struct cert *cert = NULL;
|
||||
int rc = 0;
|
||||
size_t cmsz;
|
||||
unsigned char *cms;
|
||||
|
@ -418,6 +419,9 @@ mft_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
|
|||
if (mft_parse_econtent(cms, cmsz, &p) == 0)
|
||||
goto out;
|
||||
|
||||
if ((cert = cert_parse_ee_cert(fn, *x509)) == NULL)
|
||||
goto out;
|
||||
|
||||
if (p.res->signtime > p.res->nextupdate) {
|
||||
warnx("%s: dating issue: CMS signing-time after MFT nextUpdate",
|
||||
fn);
|
||||
|
@ -433,6 +437,7 @@ out:
|
|||
*x509 = NULL;
|
||||
}
|
||||
free(crldp);
|
||||
cert_free(cert);
|
||||
free(cms);
|
||||
return p.res;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: rrdp.c,v 1.30 2023/05/03 07:51:08 claudio Exp $ */
|
||||
/* $OpenBSD: rrdp.c,v 1.31 2023/06/20 15:15:14 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
|
||||
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -431,20 +431,20 @@ rrdp_input_handler(int fd)
|
|||
io_read_str(b, &session_id);
|
||||
io_read_buf(b, &serial, sizeof(serial));
|
||||
io_read_str(b, &last_mod);
|
||||
if (b->fd != -1)
|
||||
if (ibuf_fd_avail(b))
|
||||
errx(1, "received unexpected fd");
|
||||
|
||||
rrdp_new(id, local, notify, session_id, serial, last_mod);
|
||||
break;
|
||||
case RRDP_HTTP_INI:
|
||||
if (b->fd == -1)
|
||||
errx(1, "expected fd not received");
|
||||
s = rrdp_get(id);
|
||||
if (s == NULL)
|
||||
errx(1, "http ini, rrdp session %u does not exist", id);
|
||||
if (s->state != RRDP_STATE_WAIT)
|
||||
errx(1, "%s: bad internal state", s->local);
|
||||
s->infd = b->fd;
|
||||
s->infd = ibuf_fd_get(b);
|
||||
if (s->infd == -1)
|
||||
errx(1, "expected fd not received");
|
||||
s->state = RRDP_STATE_PARSE;
|
||||
if (s->aborted) {
|
||||
rrdp_abort_req(s);
|
||||
|
@ -454,7 +454,7 @@ rrdp_input_handler(int fd)
|
|||
case RRDP_HTTP_FIN:
|
||||
io_read_buf(b, &res, sizeof(res));
|
||||
io_read_str(b, &last_mod);
|
||||
if (b->fd != -1)
|
||||
if (ibuf_fd_avail(b))
|
||||
errx(1, "received unexpected fd");
|
||||
|
||||
s = rrdp_get(id);
|
||||
|
@ -472,7 +472,7 @@ rrdp_input_handler(int fd)
|
|||
s = rrdp_get(id);
|
||||
if (s == NULL)
|
||||
errx(1, "file, rrdp session %u does not exist", id);;
|
||||
if (b->fd != -1)
|
||||
if (ibuf_fd_avail(b))
|
||||
errx(1, "received unexpected fd");
|
||||
io_read_buf(b, &ok, sizeof(ok));
|
||||
if (ok != 1)
|
||||
|
@ -482,7 +482,7 @@ rrdp_input_handler(int fd)
|
|||
rrdp_finished(s);
|
||||
break;
|
||||
case RRDP_ABORT:
|
||||
if (b->fd != -1)
|
||||
if (ibuf_fd_avail(b))
|
||||
errx(1, "received unexpected fd");
|
||||
s = rrdp_get(id);
|
||||
if (s != NULL)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tak.c,v 1.9 2023/06/07 10:46:34 job Exp $ */
|
||||
/* $OpenBSD: tak.c,v 1.10 2023/06/20 12:39:50 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Job Snijders <job@fastly.com>
|
||||
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
|
||||
|
@ -228,6 +228,7 @@ struct tak *
|
|||
tak_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
|
||||
{
|
||||
struct parse p;
|
||||
struct cert *cert = NULL;
|
||||
unsigned char *cms;
|
||||
size_t cmsz;
|
||||
time_t signtime = 0;
|
||||
|
@ -272,6 +273,9 @@ tak_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
|
|||
if (!tak_parse_econtent(cms, cmsz, &p))
|
||||
goto out;
|
||||
|
||||
if ((cert = cert_parse_ee_cert(fn, *x509)) == NULL)
|
||||
goto out;
|
||||
|
||||
if (strcmp(p.res->aki, p.res->current->ski) != 0) {
|
||||
warnx("%s: current TAKey's SKI does not match EE AKI", fn);
|
||||
goto out;
|
||||
|
@ -285,6 +289,7 @@ tak_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
|
|||
X509_free(*x509);
|
||||
*x509 = NULL;
|
||||
}
|
||||
cert_free(cert);
|
||||
free(cms);
|
||||
return p.res;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: x509.c,v 1.71 2023/05/22 15:07:02 tb Exp $ */
|
||||
/* $OpenBSD: x509.c,v 1.72 2023/06/20 11:06:47 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
|
||||
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -479,8 +479,11 @@ x509_get_sia(X509 *x, const char *fn, char **sia)
|
|||
*sia = NULL;
|
||||
}
|
||||
|
||||
if (!rsync_found)
|
||||
if (!rsync_found) {
|
||||
warnx("%s: RFC 6487 section 4.8.8.2: "
|
||||
"SIA without rsync accessLocation", fn);
|
||||
goto out;
|
||||
}
|
||||
|
||||
AUTHORITY_INFO_ACCESS_free(info);
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue