sync with OpenBSD -current
This commit is contained in:
parent
029e4bda60
commit
125fcc4eee
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: conf_api.c,v 1.16 2023/07/08 08:26:26 beck Exp $ */
|
||||
/* $OpenBSD: conf_api.c,v 1.17 2024/01/24 14:05:10 jsing Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -205,9 +205,6 @@ _CONF_free_data(CONF *conf)
|
||||
if (conf == NULL || conf->data == NULL)
|
||||
return;
|
||||
|
||||
lh_CONF_VALUE_down_load(conf->data) = 0; /* evil thing to make
|
||||
* sure the 'free()' works as
|
||||
* expected */
|
||||
lh_CONF_VALUE_doall_arg(conf->data,
|
||||
LHASH_DOALL_ARG_FN(value_free_hash),
|
||||
LHASH_OF(CONF_VALUE), conf->data);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: lhash.c,v 1.20 2023/07/07 13:40:44 beck Exp $ */
|
||||
/* $OpenBSD: lhash.c,v 1.21 2024/01/24 14:02:52 jsing Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -250,12 +250,21 @@ static void
|
||||
doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
|
||||
LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
|
||||
{
|
||||
int i;
|
||||
LHASH_NODE *a, *n;
|
||||
int down_load;
|
||||
int i;
|
||||
|
||||
if (lh == NULL)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Disable contraction of the hash while walking, as some consumers use
|
||||
* it to delete hash entries. A better option would be to snapshot the
|
||||
* hash, making it insert safe as well.
|
||||
*/
|
||||
down_load = lh->down_load;
|
||||
lh->down_load = 0;
|
||||
|
||||
/* reverse the order so we search from 'top to bottom'
|
||||
* We were having memory leaks otherwise */
|
||||
for (i = lh->num_nodes - 1; i >= 0; i--) {
|
||||
@ -273,6 +282,10 @@ doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
|
||||
a = n;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore down load factor and trigger contraction. */
|
||||
lh->down_load = down_load;
|
||||
contract(lh);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: lh_new.3,v 1.9 2022/03/31 17:27:17 naddy Exp $
|
||||
.\" $OpenBSD: lh_new.3,v 1.10 2024/01/24 14:02:52 jsing Exp $
|
||||
.\" full merge up to:
|
||||
.\" OpenSSL doc/crypto/lhash.pod 1bc74519 May 20 08:11:46 2016 -0400
|
||||
.\" selective merge up to:
|
||||
@ -118,7 +118,7 @@
|
||||
.\" copied and put under another distribution licence
|
||||
.\" [including the GNU Public Licence.]
|
||||
.\"
|
||||
.Dd $Mdocdate: March 31 2022 $
|
||||
.Dd $Mdocdate: January 24 2024 $
|
||||
.Dt LH_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -342,15 +342,8 @@ lh_STUFF_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup));
|
||||
lh_STUFF_free(hashtable);
|
||||
.Ed
|
||||
.Pp
|
||||
When doing this, be careful if you delete entries from the hash table in
|
||||
your callbacks: the table may decrease in size, moving the item that you
|
||||
are currently on down lower in the hash table \(em this could cause some
|
||||
entries to be skipped during the iteration.
|
||||
The second best solution to this problem is to set hash->down_load=0
|
||||
before you start (which will stop the hash table ever decreasing in
|
||||
size).
|
||||
The best solution is probably to avoid deleting items from the hash
|
||||
table inside a doall callback!
|
||||
A callback may delete entries from the hash table, however, it is
|
||||
not safe to insert new entries.
|
||||
.Pp
|
||||
.Fn lh_<type>_doall_arg
|
||||
is the same as
|
||||
|
@ -714,7 +714,7 @@ sub mmx_loop() {
|
||||
}
|
||||
|
||||
&mov (&LB($nlo),&LB($dat));
|
||||
&mov ($dat,&DWP(528+$j,"esp")) if (--$j%4==0);
|
||||
&mov ($dat,&DWP(528+$j,"esp")) if (--$j%4==0 && $j>=0);
|
||||
|
||||
&movd ($rem[0],$Zlo);
|
||||
&movz ($rem[1],&LB($rem[1])) if ($i>0);
|
||||
|
@ -285,7 +285,7 @@ $code.=".align 16\n.Louter_loop:\n";
|
||||
&shr ($Zlo,8);
|
||||
|
||||
&movz ($rem[0],&LB($rem[0]));
|
||||
&mov ($dat,"$j($Xi)") if (--$j%4==0);
|
||||
&mov ($dat,"$j($Xi)") if (--$j%4==0 && $j>=0);
|
||||
&shr ($Zhi,8);
|
||||
|
||||
&xor ($Zlo,"-128($Hshr4,$nhi[0],8)");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: obj_dat.c,v 1.84 2024/01/13 11:57:51 tb Exp $ */
|
||||
/* $OpenBSD: obj_dat.c,v 1.85 2024/01/24 14:05:10 jsing Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -188,7 +188,7 @@ OBJ_cleanup(void)
|
||||
{
|
||||
if (added == NULL)
|
||||
return;
|
||||
lh_ADDED_OBJ_down_load(added) = 0;
|
||||
|
||||
lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */
|
||||
lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */
|
||||
lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssl_sess.c,v 1.123 2023/11/19 15:51:49 tb Exp $ */
|
||||
/* $OpenBSD: ssl_sess.c,v 1.124 2024/01/24 14:05:10 jsing Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -1159,7 +1159,6 @@ timeout_LHASH_DOALL_ARG(void *arg1, void *arg2)
|
||||
void
|
||||
SSL_CTX_flush_sessions(SSL_CTX *s, long t)
|
||||
{
|
||||
unsigned long i;
|
||||
TIMEOUT_PARAM tp;
|
||||
|
||||
tp.ctx = s;
|
||||
@ -1167,12 +1166,10 @@ SSL_CTX_flush_sessions(SSL_CTX *s, long t)
|
||||
if (tp.cache == NULL)
|
||||
return;
|
||||
tp.time = t;
|
||||
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
|
||||
i = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;
|
||||
CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0;
|
||||
lh_SSL_SESSION_doall_arg(tp.cache, timeout_LHASH_DOALL_ARG,
|
||||
TIMEOUT_PARAM, &tp);
|
||||
CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i;
|
||||
TIMEOUT_PARAM, &tp);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
|
||||
}
|
||||
LSSL_ALIAS(SSL_CTX_flush_sessions);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rde_community_test.c,v 1.9 2023/10/11 07:05:11 claudio Exp $ */
|
||||
/* $OpenBSD: rde_community_test.c,v 1.10 2024/01/24 14:51:56 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
|
||||
@ -43,9 +43,9 @@ dump(uint8_t *b, size_t len)
|
||||
}
|
||||
|
||||
static int
|
||||
test_parsing(size_t num, uint8_t *in, size_t inlen, uint8_t *out, size_t outlen)
|
||||
test_parsing(size_t num, struct ibuf *in, struct ibuf *out)
|
||||
{
|
||||
struct ibuf *buf;
|
||||
struct ibuf *buf, abuf;
|
||||
uint8_t flags, type, attr[256];
|
||||
size_t skip;
|
||||
uint16_t attr_len;
|
||||
@ -54,42 +54,40 @@ test_parsing(size_t num, uint8_t *in, size_t inlen, uint8_t *out, size_t outlen)
|
||||
communities_clean(&comm);
|
||||
|
||||
do {
|
||||
flags = in[0];
|
||||
type = in[1];
|
||||
skip = 2;
|
||||
if (ibuf_get_n8(in, &flags) == -1 ||
|
||||
ibuf_get_n8(in, &type) == -1)
|
||||
goto bad;
|
||||
if (flags & ATTR_EXTLEN) {
|
||||
memcpy(&attr_len, in + 2, sizeof(attr_len));
|
||||
attr_len = ntohs(attr_len);
|
||||
skip += 2;
|
||||
if (ibuf_get_n16(in, &attr_len) == -1)
|
||||
goto bad;
|
||||
} else {
|
||||
attr_len = in[2];
|
||||
skip += 1;
|
||||
uint8_t tmp;
|
||||
if (ibuf_get_n8(in, &tmp) == -1)
|
||||
goto bad;
|
||||
attr_len = tmp;
|
||||
}
|
||||
if (skip + attr_len > inlen) {
|
||||
if (ibuf_get_ibuf(in, attr_len, &abuf) == -1) {
|
||||
bad:
|
||||
printf("Test %zu: attribute parse failure\n", num);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case ATTR_COMMUNITIES:
|
||||
r = community_add(&comm, flags, in + skip, attr_len);
|
||||
r = community_add(&comm, flags, &abuf);
|
||||
break;
|
||||
case ATTR_EXT_COMMUNITIES:
|
||||
r = community_ext_add(&comm, flags, 0, in + skip,
|
||||
attr_len);
|
||||
r = community_ext_add(&comm, flags, 0, &abuf);
|
||||
break;
|
||||
case ATTR_LARGE_COMMUNITIES:
|
||||
r = community_large_add(&comm, flags, in + skip,
|
||||
attr_len);
|
||||
r = community_large_add(&comm, flags, &abuf);
|
||||
break;
|
||||
}
|
||||
if (r == -1) {
|
||||
printf("Test %zu: community_add failed\n", num);
|
||||
return -1;
|
||||
}
|
||||
in += skip + attr_len;
|
||||
inlen -= (skip + attr_len);
|
||||
} while (inlen > 0);
|
||||
} while (ibuf_size(in) > 0);
|
||||
|
||||
if ((buf = ibuf_dynamic(0, 4096)) == NULL) {
|
||||
printf("Test %zu: ibuf_dynamic failed\n", num);
|
||||
@ -109,19 +107,19 @@ test_parsing(size_t num, uint8_t *in, size_t inlen, uint8_t *out, size_t outlen)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ibuf_size(buf) != outlen) {
|
||||
if (ibuf_size(buf) != ibuf_size(out)) {
|
||||
printf("Test %zu: ibuf size value %zd != %zd:",
|
||||
num, ibuf_size(buf), outlen);
|
||||
num, ibuf_size(buf), ibuf_size(out));
|
||||
dump(ibuf_data(buf), ibuf_size(buf));
|
||||
printf("expected: ");
|
||||
dump(out, outlen);
|
||||
dump(ibuf_data(out), ibuf_size(out));
|
||||
return -1;
|
||||
}
|
||||
if (memcmp(ibuf_data(buf), out, outlen) != 0) {
|
||||
if (memcmp(ibuf_data(buf), ibuf_data(out), ibuf_size(out)) != 0) {
|
||||
printf("Test %zu: unexpected encoding: ", num);
|
||||
dump(ibuf_data(buf), ibuf_size(buf));
|
||||
printf("expected: ");
|
||||
dump(out, outlen);
|
||||
dump(ibuf_data(out), ibuf_size(out));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -206,16 +204,17 @@ main(int argc, char *argv[])
|
||||
int error = 0;
|
||||
|
||||
for (t = 0; t < sizeof(vectors) / sizeof(*vectors); t++) {
|
||||
size_t outlen = vectors[t].expsize;
|
||||
uint8_t *out = vectors[t].expected;
|
||||
struct ibuf in, out;
|
||||
|
||||
if (vectors[t].expected == NULL) {
|
||||
outlen = vectors[t].size;
|
||||
out = vectors[t].data;
|
||||
}
|
||||
ibuf_from_buffer(&in, vectors[t].data, vectors[t].size);
|
||||
if (vectors[t].expected == NULL)
|
||||
ibuf_from_buffer(&out,
|
||||
vectors[t].data, vectors[t].size);
|
||||
else
|
||||
ibuf_from_buffer(&out,
|
||||
vectors[t].expected, vectors[t].expsize);
|
||||
|
||||
if (test_parsing(t, vectors[t].data, vectors[t].size,
|
||||
out, outlen) == -1)
|
||||
if (test_parsing(t, &in, &out) == -1)
|
||||
error = 1;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ca.c,v 1.98 2024/01/15 15:29:00 tobhe Exp $ */
|
||||
/* $OpenBSD: ca.c,v 1.99 2024/01/24 10:09:07 tobhe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
|
||||
@ -76,7 +76,7 @@ int ca_x509_subjectaltname_get(X509 *cert, struct iked_id *);
|
||||
int ca_dispatch_parent(int, struct privsep_proc *, struct imsg *);
|
||||
int ca_dispatch_ikev2(int, struct privsep_proc *, struct imsg *);
|
||||
int ca_dispatch_control(int, struct privsep_proc *, struct imsg *);
|
||||
void ca_store_info(struct iked *, const char *, X509_STORE *);
|
||||
void ca_store_info(struct iked *, struct imsg *, const char *, X509_STORE *);
|
||||
|
||||
static struct privsep_proc procs[] = {
|
||||
{ "parent", PROC_PARENT, ca_dispatch_parent },
|
||||
@ -391,11 +391,12 @@ ca_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
case IMSG_CTL_SHOW_CERTSTORE:
|
||||
ca_store_info(env, "CA", store->ca_cas);
|
||||
ca_store_info(env, "CERT", store->ca_certs);
|
||||
ca_store_info(env, imsg, "CA", store->ca_cas);
|
||||
ca_store_info(env, imsg, "CERT", store->ca_certs);
|
||||
/* Send empty reply to indicate end of information. */
|
||||
proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_CERTSTORE,
|
||||
NULL, 0);
|
||||
proc_compose_imsg(&env->sc_ps, PROC_CONTROL, -1,
|
||||
IMSG_CTL_SHOW_CERTSTORE, imsg->hdr.peerid,
|
||||
-1, NULL, 0);
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
@ -1333,7 +1334,7 @@ ca_subjectpubkey_digest(X509 *x509, uint8_t *md, unsigned int *size)
|
||||
}
|
||||
|
||||
void
|
||||
ca_store_info(struct iked *env, const char *msg, X509_STORE *ctx)
|
||||
ca_store_info(struct iked *env, struct imsg *imsg, const char *msg, X509_STORE *ctx)
|
||||
{
|
||||
STACK_OF(X509_OBJECT) *h;
|
||||
X509_OBJECT *xo;
|
||||
@ -1357,8 +1358,9 @@ ca_store_info(struct iked *env, const char *msg, X509_STORE *ctx)
|
||||
OPENSSL_free(name);
|
||||
if (buflen == -1)
|
||||
continue;
|
||||
proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_CERTSTORE,
|
||||
buf, buflen + 1);
|
||||
proc_compose_imsg(&env->sc_ps, PROC_CONTROL, -1,
|
||||
IMSG_CTL_SHOW_CERTSTORE, imsg->hdr.peerid,
|
||||
-1, buf, buflen + 1);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: control.c,v 1.37 2023/03/08 04:43:06 guenther Exp $ */
|
||||
/* $OpenBSD: control.c,v 1.38 2024/01/24 10:09:07 tobhe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
|
||||
@ -36,6 +36,7 @@
|
||||
#define CONTROL_BACKLOG 5
|
||||
|
||||
struct ctl_connlist ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns);
|
||||
uint32_t ctl_peerid;
|
||||
|
||||
void
|
||||
control_accept(int, short, void *);
|
||||
@ -45,6 +46,7 @@ void control_close(int, struct control_sock *);
|
||||
void control_dispatch_imsg(int, short, void *);
|
||||
void control_dispatch_parent(int, short, void *);
|
||||
void control_imsg_forward(struct imsg *);
|
||||
void control_imsg_forward_peerid(struct imsg *);
|
||||
void control_run(struct privsep *, struct privsep_proc *, void *);
|
||||
int control_dispatch_ikev2(int, struct privsep_proc *, struct imsg *);
|
||||
int control_dispatch_ca(int, struct privsep_proc *, struct imsg *);
|
||||
@ -160,6 +162,7 @@ control_accept(int listenfd, short event, void *arg)
|
||||
socklen_t len;
|
||||
struct sockaddr_un s_un;
|
||||
struct ctl_conn *c;
|
||||
struct ctl_conn *other;
|
||||
|
||||
event_add(&cs->cs_ev, NULL);
|
||||
if ((event & EV_TIMEOUT))
|
||||
@ -197,6 +200,12 @@ control_accept(int listenfd, short event, void *arg)
|
||||
c->iev.handler, c->iev.data);
|
||||
event_add(&c->iev.ev, NULL);
|
||||
|
||||
/* O(n^2), but n is small */
|
||||
c->peerid = ctl_peerid++;
|
||||
TAILQ_FOREACH(other, &ctl_conns, entry)
|
||||
if (c->peerid == other->peerid)
|
||||
c->peerid = ctl_peerid++;
|
||||
|
||||
TAILQ_INSERT_TAIL(&ctl_conns, c, entry);
|
||||
}
|
||||
|
||||
@ -277,6 +286,9 @@ control_dispatch_imsg(int fd, short event, void *arg)
|
||||
|
||||
control_imsg_forward(&imsg);
|
||||
|
||||
/* record peerid of connection for reply */
|
||||
imsg.hdr.peerid = c->peerid;
|
||||
|
||||
switch (imsg.hdr.type) {
|
||||
case IMSG_CTL_NOTIFY:
|
||||
if (c->flags & CTL_CONN_NOTIFY) {
|
||||
@ -311,11 +323,9 @@ control_dispatch_imsg(int fd, short event, void *arg)
|
||||
case IMSG_CTL_SHOW_SA:
|
||||
case IMSG_CTL_SHOW_STATS:
|
||||
proc_forward_imsg(&env->sc_ps, &imsg, PROC_IKEV2, -1);
|
||||
c->flags |= CTL_CONN_NOTIFY;
|
||||
break;
|
||||
case IMSG_CTL_SHOW_CERTSTORE:
|
||||
proc_forward_imsg(&env->sc_ps, &imsg, PROC_CERT, -1);
|
||||
c->flags |= CTL_CONN_NOTIFY;
|
||||
break;
|
||||
default:
|
||||
log_debug("%s: error handling imsg %d",
|
||||
@ -340,13 +350,25 @@ control_imsg_forward(struct imsg *imsg)
|
||||
imsg->hdr.len - IMSG_HEADER_SIZE);
|
||||
}
|
||||
|
||||
void
|
||||
control_imsg_forward_peerid(struct imsg *imsg)
|
||||
{
|
||||
struct ctl_conn *c;
|
||||
|
||||
TAILQ_FOREACH(c, &ctl_conns, entry)
|
||||
if (c->peerid == imsg->hdr.peerid)
|
||||
imsg_compose_event(&c->iev, imsg->hdr.type,
|
||||
0, imsg->hdr.pid, -1, imsg->data,
|
||||
imsg->hdr.len - IMSG_HEADER_SIZE);
|
||||
}
|
||||
|
||||
int
|
||||
control_dispatch_ikev2(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
{
|
||||
switch (imsg->hdr.type) {
|
||||
case IMSG_CTL_SHOW_SA:
|
||||
case IMSG_CTL_SHOW_STATS:
|
||||
control_imsg_forward(imsg);
|
||||
control_imsg_forward_peerid(imsg);
|
||||
return (0);
|
||||
default:
|
||||
break;
|
||||
@ -360,7 +382,7 @@ control_dispatch_ca(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
{
|
||||
switch (imsg->hdr.type) {
|
||||
case IMSG_CTL_SHOW_CERTSTORE:
|
||||
control_imsg_forward(imsg);
|
||||
control_imsg_forward_peerid(imsg);
|
||||
return (0);
|
||||
default:
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: iked.h,v 1.225 2024/01/15 15:29:00 tobhe Exp $ */
|
||||
/* $OpenBSD: iked.h,v 1.226 2024/01/24 10:09:07 tobhe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
|
||||
@ -99,6 +99,7 @@ struct ctl_conn {
|
||||
uint8_t flags;
|
||||
#define CTL_CONN_NOTIFY 0x01
|
||||
struct imsgev iev;
|
||||
uint32_t peerid;
|
||||
};
|
||||
TAILQ_HEAD(ctl_connlist, ctl_conn);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ikev2.c,v 1.382 2024/01/15 21:37:58 jan Exp $ */
|
||||
/* $OpenBSD: ikev2.c,v 1.383 2024/01/24 10:09:07 tobhe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
|
||||
@ -48,10 +48,13 @@
|
||||
#include "chap_ms.h"
|
||||
#include "version.h"
|
||||
|
||||
void ikev2_info(struct iked *, int);
|
||||
void ikev2_info_sa(struct iked *, int, const char *, struct iked_sa *);
|
||||
void ikev2_info_csa(struct iked *, int, const char *, struct iked_childsa *);
|
||||
void ikev2_info_flow(struct iked *, int, const char *, struct iked_flow *);
|
||||
void ikev2_info(struct iked *, struct imsg *, int);
|
||||
void ikev2_info_sa(struct iked *, struct imsg *, int, const char *,
|
||||
struct iked_sa *);
|
||||
void ikev2_info_csa(struct iked *, struct imsg *, int, const char *,
|
||||
struct iked_childsa *);
|
||||
void ikev2_info_flow(struct iked *, struct imsg *, int, const char *,
|
||||
struct iked_flow *);
|
||||
void ikev2_log_established(struct iked_sa *);
|
||||
void ikev2_log_proposal(struct iked_sa *, struct iked_proposals *);
|
||||
void ikev2_log_cert_info(const char *, struct iked_id *);
|
||||
@ -188,8 +191,8 @@ int ikev2_resp_informational(struct iked *, struct iked_sa *,
|
||||
struct iked_message *);
|
||||
|
||||
void ikev2_ctl_reset_id(struct iked *, struct imsg *, unsigned int);
|
||||
void ikev2_ctl_show_sa(struct iked *);
|
||||
void ikev2_ctl_show_stats(struct iked *);
|
||||
void ikev2_ctl_show_sa(struct iked *, struct imsg *);
|
||||
void ikev2_ctl_show_stats(struct iked *, struct imsg *);
|
||||
|
||||
static struct privsep_proc procs[] = {
|
||||
{ "parent", PROC_PARENT, ikev2_dispatch_parent },
|
||||
@ -512,10 +515,10 @@ ikev2_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
ikev2_ctl_reset_id(env, imsg, imsg->hdr.type);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_SA:
|
||||
ikev2_ctl_show_sa(env);
|
||||
ikev2_ctl_show_sa(env, imsg);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_STATS:
|
||||
ikev2_ctl_show_stats(env);
|
||||
ikev2_ctl_show_stats(env, imsg);
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
@ -572,15 +575,16 @@ ikev2_ctl_reset_id(struct iked *env, struct imsg *imsg, unsigned int type)
|
||||
}
|
||||
|
||||
void
|
||||
ikev2_ctl_show_sa(struct iked *env)
|
||||
ikev2_ctl_show_sa(struct iked *env, struct imsg *imsg)
|
||||
{
|
||||
ikev2_info(env, 0);
|
||||
ikev2_info(env, imsg, 0);
|
||||
}
|
||||
|
||||
void
|
||||
ikev2_ctl_show_stats(struct iked *env)
|
||||
ikev2_ctl_show_stats(struct iked *env, struct imsg *imsg)
|
||||
{
|
||||
proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_STATS,
|
||||
proc_compose_imsg(&env->sc_ps, PROC_CONTROL, -1,
|
||||
IMSG_CTL_SHOW_STATS, imsg->hdr.peerid, -1,
|
||||
&env->sc_stats, sizeof(env->sc_stats));
|
||||
}
|
||||
|
||||
@ -7444,7 +7448,8 @@ ikev2_update_sa_addresses(struct iked *env, struct iked_sa *sa)
|
||||
}
|
||||
|
||||
void
|
||||
ikev2_info_sa(struct iked *env, int dolog, const char *msg, struct iked_sa *sa)
|
||||
ikev2_info_sa(struct iked *env, struct imsg *imsg, int dolog, const char *msg,
|
||||
struct iked_sa *sa)
|
||||
{
|
||||
char idstr[IKED_ID_SIZE];
|
||||
char *buf;
|
||||
@ -7476,13 +7481,15 @@ ikev2_info_sa(struct iked *env, int dolog, const char *msg, struct iked_sa *sa)
|
||||
buf[buflen - 1] = '\0';
|
||||
log_debug("%s", buf);
|
||||
} else
|
||||
proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_SA,
|
||||
proc_compose_imsg(&env->sc_ps, PROC_CONTROL, -1,
|
||||
IMSG_CTL_SHOW_SA, imsg->hdr.peerid, -1,
|
||||
buf, buflen + 1);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
ikev2_info_csa(struct iked *env, int dolog, const char *msg, struct iked_childsa *csa)
|
||||
ikev2_info_csa(struct iked *env, struct imsg *imsg, int dolog, const char *msg,
|
||||
struct iked_childsa *csa)
|
||||
{
|
||||
char *buf;
|
||||
int buflen;
|
||||
@ -7510,13 +7517,15 @@ ikev2_info_csa(struct iked *env, int dolog, const char *msg, struct iked_childsa
|
||||
buf[buflen - 1] = '\0';
|
||||
log_debug("%s", buf);
|
||||
} else
|
||||
proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_SA,
|
||||
proc_compose_imsg(&env->sc_ps, PROC_CONTROL, -1,
|
||||
IMSG_CTL_SHOW_SA, imsg->hdr.peerid, -1,
|
||||
buf, buflen + 1);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
ikev2_info_flow(struct iked *env, int dolog, const char *msg, struct iked_flow *flow)
|
||||
ikev2_info_flow(struct iked *env, struct imsg *imsg, int dolog, const char *msg,
|
||||
struct iked_flow *flow)
|
||||
{
|
||||
char prenat_mask[10];
|
||||
char *buf;
|
||||
@ -7555,13 +7564,14 @@ ikev2_info_flow(struct iked *env, int dolog, const char *msg, struct iked_flow *
|
||||
buf[buflen - 1] = '\0';
|
||||
log_debug("%s", buf);
|
||||
} else
|
||||
proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_SA,
|
||||
proc_compose_imsg(&env->sc_ps, PROC_CONTROL, -1,
|
||||
IMSG_CTL_SHOW_SA, imsg->hdr.peerid, -1,
|
||||
buf, buflen + 1);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
ikev2_info(struct iked *env, int dolog)
|
||||
ikev2_info(struct iked *env, struct imsg *imsg, int dolog)
|
||||
{
|
||||
struct iked_sa *sa;
|
||||
struct iked_childsa *csa, *ipcomp;
|
||||
@ -7570,32 +7580,33 @@ ikev2_info(struct iked *env, int dolog)
|
||||
log_debug("%s: called", __func__);
|
||||
|
||||
RB_FOREACH(sa, iked_sas, &env->sc_sas) {
|
||||
ikev2_info_sa(env, dolog, "iked_sas", sa);
|
||||
ikev2_info_sa(env, imsg, dolog, "iked_sas", sa);
|
||||
TAILQ_FOREACH(csa, &sa->sa_childsas, csa_entry) {
|
||||
ikev2_info_csa(env, dolog, " sa_childsas", csa);
|
||||
ikev2_info_csa(env, imsg, dolog, " sa_childsas", csa);
|
||||
if ((ipcomp = csa->csa_bundled) != NULL)
|
||||
ikev2_info_csa(env, dolog, " ",
|
||||
ikev2_info_csa(env, imsg, dolog, " ",
|
||||
ipcomp);
|
||||
}
|
||||
TAILQ_FOREACH(flow, &sa->sa_flows, flow_entry) {
|
||||
ikev2_info_flow(env, dolog, " sa_flows", flow);
|
||||
ikev2_info_flow(env, imsg, dolog, " sa_flows", flow);
|
||||
}
|
||||
}
|
||||
RB_FOREACH(csa, iked_activesas, &env->sc_activesas) {
|
||||
ikev2_info_csa(env, dolog, "iked_activesas", csa);
|
||||
ikev2_info_csa(env, imsg, dolog, "iked_activesas", csa);
|
||||
if ((ipcomp = csa->csa_bundled) != NULL)
|
||||
ikev2_info_csa(env, dolog, " ", ipcomp);
|
||||
ikev2_info_csa(env, imsg, dolog, " ", ipcomp);
|
||||
}
|
||||
RB_FOREACH(flow, iked_flows, &env->sc_activeflows) {
|
||||
ikev2_info_flow(env, dolog, "iked_flows", flow);
|
||||
ikev2_info_flow(env, imsg, dolog, "iked_flows", flow);
|
||||
}
|
||||
RB_FOREACH(sa, iked_dstid_sas, &env->sc_dstid_sas) {
|
||||
ikev2_info_sa(env, dolog, "iked_dstid_sas", sa);
|
||||
ikev2_info_sa(env, imsg, dolog, "iked_dstid_sas", sa);
|
||||
}
|
||||
if (dolog)
|
||||
return;
|
||||
/* Send empty reply to indicate end of information. */
|
||||
proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_SA, NULL, 0);
|
||||
proc_compose_imsg(&env->sc_ps, PROC_CONTROL, -1, IMSG_CTL_SHOW_SA,
|
||||
imsg->hdr.peerid, -1, NULL, 0);
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: apldcp.4,v 1.1 2024/01/22 18:56:18 kettenis Exp $
|
||||
.\" $OpenBSD: apldcp.4,v 1.2 2024/01/24 14:17:37 kettenis Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2024 Mark Kettenis <kettenis@openbsd.org>
|
||||
.\"
|
||||
@ -14,7 +14,7 @@
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.Dd $Mdocdate: January 22 2024 $
|
||||
.Dd $Mdocdate: January 24 2024 $
|
||||
.Dt APLDCP 4 arm64
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -40,9 +40,11 @@ device driver first appeared in
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Alyssa Rosenzweig
|
||||
.An Alyssa Rosenzweig ,
|
||||
.An Janne Grunau ,
|
||||
.An Martin Povi\[u0161]er
|
||||
and
|
||||
.An Janne Grunau
|
||||
.An Sven Peter
|
||||
for Linux and ported to
|
||||
.Ox
|
||||
by
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.159 2023/08/23 01:55:46 cheloha Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.160 2024/01/24 19:23:39 cheloha Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
|
||||
|
||||
/*-
|
||||
@ -208,7 +208,7 @@ struct cpu_info {
|
||||
u_int64_t ci_hz_aperf;
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
struct clockintr ci_gmonclock;
|
||||
#endif
|
||||
u_int32_t ci_vmm_flags;
|
||||
#define CI_VMM_VMX (1 << 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.64 2023/08/23 01:55:46 cheloha Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.65 2024/01/24 19:23:39 cheloha Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
|
||||
|
||||
/*
|
||||
@ -198,7 +198,7 @@ struct cpu_info {
|
||||
|
||||
#ifdef GPROF
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
struct clockintr ci_gmonclock;
|
||||
#endif
|
||||
struct clockintr_queue ci_queue;
|
||||
char ci_panicbuf[512];
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: GENERIC,v 1.281 2024/01/22 18:54:01 kettenis Exp $
|
||||
# $OpenBSD: GENERIC,v 1.282 2024/01/24 07:36:52 kevlo Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
@ -398,6 +398,7 @@ vmx* at pci? # VMware VMXNET3 virtual interface
|
||||
athn* at pci? # Atheros AR9k (802.11a/g/n)
|
||||
bwfm* at pci? # Broadcom FullMAC
|
||||
iwn* at pci? # Intel WiFi Link 4965/5000/1000/6000
|
||||
iwm* at pci? # Intel WiFi Link 7xxx
|
||||
iwx* at pci? # Intel WiFi Link 22xxx
|
||||
#qwx* at pci? # Qualcomm 802.11ax
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.41 2024/01/15 11:58:45 kettenis Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.42 2024/01/24 19:23:39 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
|
||||
*
|
||||
@ -174,7 +174,7 @@ struct cpu_info {
|
||||
|
||||
#ifdef GPROF
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
struct clockintr ci_gmonclock;
|
||||
#endif
|
||||
struct clockintr_queue ci_queue;
|
||||
char ci_panicbuf[512];
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cpu.h,v 1.183 2023/08/23 01:55:46 cheloha Exp $ */
|
||||
/* $OpenBSD: cpu.h,v 1.184 2024/01/24 19:23:39 cheloha Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
@ -168,7 +168,7 @@ struct cpu_info {
|
||||
struct ksensor ci_sensor;
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
struct gmonparam *ci_gmon;
|
||||
struct clockintr *ci_gmonclock;
|
||||
struct clockintr ci_gmonclock;
|
||||
#endif
|
||||
struct clockintr_queue ci_queue;
|
||||
char ci_panicbuf[512];
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: kern_clockintr.c,v 1.63 2024/01/15 01:15:37 cheloha Exp $ */
|
||||
/* $OpenBSD: kern_clockintr.c,v 1.64 2024/01/24 19:23:38 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2003 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
|
||||
@ -62,11 +62,9 @@ clockintr_cpu_init(const struct intrclock *ic)
|
||||
clockqueue_intrclock_install(cq, ic);
|
||||
|
||||
/* TODO: Remove this from struct clockintr_queue. */
|
||||
if (cq->cq_hardclock == NULL) {
|
||||
cq->cq_hardclock = clockintr_establish(ci, clockintr_hardclock,
|
||||
if (cq->cq_hardclock.cl_expiration == 0) {
|
||||
clockintr_bind(&cq->cq_hardclock, ci, clockintr_hardclock,
|
||||
NULL);
|
||||
if (cq->cq_hardclock == NULL)
|
||||
panic("%s: failed to establish hardclock", __func__);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -96,16 +94,16 @@ clockintr_cpu_init(const struct intrclock *ic)
|
||||
* behalf.
|
||||
*/
|
||||
if (CPU_IS_PRIMARY(ci)) {
|
||||
if (cq->cq_hardclock->cl_expiration == 0)
|
||||
clockintr_schedule(cq->cq_hardclock, 0);
|
||||
if (cq->cq_hardclock.cl_expiration == 0)
|
||||
clockintr_schedule(&cq->cq_hardclock, 0);
|
||||
else
|
||||
clockintr_advance(cq->cq_hardclock, hardclock_period);
|
||||
clockintr_advance(&cq->cq_hardclock, hardclock_period);
|
||||
} else {
|
||||
if (cq->cq_hardclock->cl_expiration == 0) {
|
||||
clockintr_stagger(cq->cq_hardclock, hardclock_period,
|
||||
if (cq->cq_hardclock.cl_expiration == 0) {
|
||||
clockintr_stagger(&cq->cq_hardclock, hardclock_period,
|
||||
multiplier, MAXCPUS);
|
||||
}
|
||||
clockintr_advance(cq->cq_hardclock, hardclock_period);
|
||||
clockintr_advance(&cq->cq_hardclock, hardclock_period);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -113,30 +111,30 @@ clockintr_cpu_init(const struct intrclock *ic)
|
||||
* stagger a randomized statclock.
|
||||
*/
|
||||
if (!statclock_is_randomized) {
|
||||
if (spc->spc_statclock->cl_expiration == 0) {
|
||||
clockintr_stagger(spc->spc_statclock, statclock_avg,
|
||||
if (spc->spc_statclock.cl_expiration == 0) {
|
||||
clockintr_stagger(&spc->spc_statclock, statclock_avg,
|
||||
multiplier, MAXCPUS);
|
||||
}
|
||||
}
|
||||
clockintr_advance(spc->spc_statclock, statclock_avg);
|
||||
clockintr_advance(&spc->spc_statclock, statclock_avg);
|
||||
|
||||
/*
|
||||
* XXX Need to find a better place to do this. We can't do it in
|
||||
* sched_init_cpu() because initclocks() runs after it.
|
||||
*/
|
||||
if (spc->spc_itimer->cl_expiration == 0) {
|
||||
clockintr_stagger(spc->spc_itimer, hardclock_period,
|
||||
if (spc->spc_itimer.cl_expiration == 0) {
|
||||
clockintr_stagger(&spc->spc_itimer, hardclock_period,
|
||||
multiplier, MAXCPUS);
|
||||
}
|
||||
if (spc->spc_profclock->cl_expiration == 0) {
|
||||
clockintr_stagger(spc->spc_profclock, profclock_period,
|
||||
if (spc->spc_profclock.cl_expiration == 0) {
|
||||
clockintr_stagger(&spc->spc_profclock, profclock_period,
|
||||
multiplier, MAXCPUS);
|
||||
}
|
||||
if (spc->spc_roundrobin->cl_expiration == 0) {
|
||||
clockintr_stagger(spc->spc_roundrobin, hardclock_period,
|
||||
if (spc->spc_roundrobin.cl_expiration == 0) {
|
||||
clockintr_stagger(&spc->spc_roundrobin, hardclock_period,
|
||||
multiplier, MAXCPUS);
|
||||
}
|
||||
clockintr_advance(spc->spc_roundrobin, roundrobin_period);
|
||||
clockintr_advance(&spc->spc_roundrobin, roundrobin_period);
|
||||
|
||||
if (reset_cq_intrclock)
|
||||
SET(cq->cq_flags, CQ_INTRCLOCK);
|
||||
@ -337,16 +335,12 @@ clockintr_cancel(struct clockintr *cl)
|
||||
mtx_leave(&cq->cq_mtx);
|
||||
}
|
||||
|
||||
struct clockintr *
|
||||
clockintr_establish(struct cpu_info *ci,
|
||||
void
|
||||
clockintr_bind(struct clockintr *cl, struct cpu_info *ci,
|
||||
void (*func)(struct clockrequest *, void *, void *), void *arg)
|
||||
{
|
||||
struct clockintr *cl;
|
||||
struct clockintr_queue *cq = &ci->ci_queue;
|
||||
|
||||
cl = malloc(sizeof *cl, M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
if (cl == NULL)
|
||||
return NULL;
|
||||
cl->cl_arg = arg;
|
||||
cl->cl_func = func;
|
||||
cl->cl_queue = cq;
|
||||
@ -354,7 +348,6 @@ clockintr_establish(struct cpu_info *ci,
|
||||
mtx_enter(&cq->cq_mtx);
|
||||
TAILQ_INSERT_TAIL(&cq->cq_all, cl, cl_alink);
|
||||
mtx_leave(&cq->cq_mtx);
|
||||
return cl;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: kern_fork.c,v 1.256 2024/01/19 01:43:26 bluhm Exp $ */
|
||||
/* $OpenBSD: kern_fork.c,v 1.257 2024/01/24 19:23:38 cheloha Exp $ */
|
||||
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
|
||||
|
||||
/*
|
||||
@ -704,11 +704,11 @@ proc_trampoline_mi(void)
|
||||
/* Start any optional clock interrupts needed by the thread. */
|
||||
if (ISSET(p->p_p->ps_flags, PS_ITIMER)) {
|
||||
atomic_setbits_int(&spc->spc_schedflags, SPCF_ITIMER);
|
||||
clockintr_advance(spc->spc_itimer, hardclock_period);
|
||||
clockintr_advance(&spc->spc_itimer, hardclock_period);
|
||||
}
|
||||
if (ISSET(p->p_p->ps_flags, PS_PROFIL)) {
|
||||
atomic_setbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
|
||||
clockintr_advance(spc->spc_profclock, profclock_period);
|
||||
clockintr_advance(&spc->spc_profclock, profclock_period);
|
||||
}
|
||||
|
||||
nanouptime(&spc->spc_runtime);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: kern_sched.c,v 1.93 2023/10/24 13:20:11 claudio Exp $ */
|
||||
/* $OpenBSD: kern_sched.c,v 1.94 2024/01/24 19:23:38 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
|
||||
*
|
||||
@ -88,18 +88,10 @@ sched_init_cpu(struct cpu_info *ci)
|
||||
|
||||
spc->spc_idleproc = NULL;
|
||||
|
||||
spc->spc_itimer = clockintr_establish(ci, itimer_update, NULL);
|
||||
if (spc->spc_itimer == NULL)
|
||||
panic("%s: clockintr_establish itimer_update", __func__);
|
||||
spc->spc_profclock = clockintr_establish(ci, profclock, NULL);
|
||||
if (spc->spc_profclock == NULL)
|
||||
panic("%s: clockintr_establish profclock", __func__);
|
||||
spc->spc_roundrobin = clockintr_establish(ci, roundrobin, NULL);
|
||||
if (spc->spc_roundrobin == NULL)
|
||||
panic("%s: clockintr_establish roundrobin", __func__);
|
||||
spc->spc_statclock = clockintr_establish(ci, statclock, NULL);
|
||||
if (spc->spc_statclock == NULL)
|
||||
panic("%s: clockintr_establish statclock", __func__);
|
||||
clockintr_bind(&spc->spc_itimer, ci, itimer_update, NULL);
|
||||
clockintr_bind(&spc->spc_profclock, ci, profclock, NULL);
|
||||
clockintr_bind(&spc->spc_roundrobin, ci, roundrobin, NULL);
|
||||
clockintr_bind(&spc->spc_statclock, ci, statclock, NULL);
|
||||
|
||||
kthread_create_deferred(sched_kthreads_create, ci);
|
||||
|
||||
@ -244,11 +236,11 @@ sched_toidle(void)
|
||||
|
||||
if (ISSET(spc->spc_schedflags, SPCF_ITIMER)) {
|
||||
atomic_clearbits_int(&spc->spc_schedflags, SPCF_ITIMER);
|
||||
clockintr_cancel(spc->spc_itimer);
|
||||
clockintr_cancel(&spc->spc_itimer);
|
||||
}
|
||||
if (ISSET(spc->spc_schedflags, SPCF_PROFCLOCK)) {
|
||||
atomic_clearbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
|
||||
clockintr_cancel(spc->spc_profclock);
|
||||
clockintr_cancel(&spc->spc_profclock);
|
||||
}
|
||||
|
||||
atomic_clearbits_int(&spc->spc_schedflags, SPCF_SWITCHCLEAR);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sched_bsd.c,v 1.89 2023/10/17 00:04:02 cheloha Exp $ */
|
||||
/* $OpenBSD: sched_bsd.c,v 1.90 2024/01/24 19:23:38 cheloha Exp $ */
|
||||
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
|
||||
|
||||
/*-
|
||||
@ -396,11 +396,11 @@ mi_switch(void)
|
||||
/* Stop any optional clock interrupts. */
|
||||
if (ISSET(spc->spc_schedflags, SPCF_ITIMER)) {
|
||||
atomic_clearbits_int(&spc->spc_schedflags, SPCF_ITIMER);
|
||||
clockintr_cancel(spc->spc_itimer);
|
||||
clockintr_cancel(&spc->spc_itimer);
|
||||
}
|
||||
if (ISSET(spc->spc_schedflags, SPCF_PROFCLOCK)) {
|
||||
atomic_clearbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
|
||||
clockintr_cancel(spc->spc_profclock);
|
||||
clockintr_cancel(&spc->spc_profclock);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -451,11 +451,11 @@ mi_switch(void)
|
||||
/* Start any optional clock interrupts needed by the thread. */
|
||||
if (ISSET(p->p_p->ps_flags, PS_ITIMER)) {
|
||||
atomic_setbits_int(&spc->spc_schedflags, SPCF_ITIMER);
|
||||
clockintr_advance(spc->spc_itimer, hardclock_period);
|
||||
clockintr_advance(&spc->spc_itimer, hardclock_period);
|
||||
}
|
||||
if (ISSET(p->p_p->ps_flags, PS_PROFIL)) {
|
||||
atomic_setbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
|
||||
clockintr_advance(spc->spc_profclock, profclock_period);
|
||||
clockintr_advance(&spc->spc_profclock, profclock_period);
|
||||
}
|
||||
|
||||
nanouptime(&spc->spc_runtime);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: subr_prof.c,v 1.40 2023/10/17 00:04:02 cheloha Exp $ */
|
||||
/* $OpenBSD: subr_prof.c,v 1.41 2024/01/24 19:23:38 cheloha Exp $ */
|
||||
/* $NetBSD: subr_prof.c,v 1.12 1996/04/22 01:38:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
@ -101,19 +101,16 @@ prof_init(void)
|
||||
|
||||
/* Allocate and initialize one profiling buffer per CPU. */
|
||||
CPU_INFO_FOREACH(cii, ci) {
|
||||
ci->ci_gmonclock = clockintr_establish(ci, gmonclock, NULL);
|
||||
if (ci->ci_gmonclock == NULL) {
|
||||
printf("%s: clockintr_establish gmonclock\n", __func__);
|
||||
return;
|
||||
}
|
||||
clockintr_stagger(ci->ci_gmonclock, profclock_period,
|
||||
CPU_INFO_UNIT(ci), MAXCPUS);
|
||||
cp = km_alloc(round_page(size), &kv_any, &kp_zero, &kd_nowait);
|
||||
if (cp == NULL) {
|
||||
printf("No memory for profiling.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
clockintr_bind(&ci->ci_gmonclock, ci, gmonclock, NULL);
|
||||
clockintr_stagger(&ci->ci_gmonclock, profclock_period,
|
||||
CPU_INFO_UNIT(ci), MAXCPUS);
|
||||
|
||||
p = (struct gmonparam *)cp;
|
||||
cp += sizeof(*p);
|
||||
p->tos = (struct tostruct *)cp;
|
||||
@ -159,7 +156,7 @@ prof_state_toggle(struct cpu_info *ci, int oldstate)
|
||||
if (error == 0) {
|
||||
if (++gmon_cpu_count == 1)
|
||||
startprofclock(&process0);
|
||||
clockintr_advance(ci->ci_gmonclock, profclock_period);
|
||||
clockintr_advance(&ci->ci_gmonclock, profclock_period);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -167,7 +164,7 @@ prof_state_toggle(struct cpu_info *ci, int oldstate)
|
||||
gp->state = GMON_PROF_OFF;
|
||||
/* FALLTHROUGH */
|
||||
case GMON_PROF_OFF:
|
||||
clockintr_cancel(ci->ci_gmonclock);
|
||||
clockintr_cancel(&ci->ci_gmonclock);
|
||||
if (--gmon_cpu_count == 0)
|
||||
stopprofclock(&process0);
|
||||
#if !defined(GPROF)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: clockintr.h,v 1.24 2024/01/15 01:15:37 cheloha Exp $ */
|
||||
/* $OpenBSD: clockintr.h,v 1.25 2024/01/24 19:23:38 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020-2022 Scott Cheloha <cheloha@openbsd.org>
|
||||
*
|
||||
@ -102,7 +102,7 @@ struct clockintr_queue {
|
||||
TAILQ_HEAD(, clockintr) cq_all; /* [m] established clockintr list */
|
||||
TAILQ_HEAD(, clockintr) cq_pend;/* [m] pending clockintr list */
|
||||
struct clockintr *cq_running; /* [m] running clockintr */
|
||||
struct clockintr *cq_hardclock; /* [o] hardclock handle */
|
||||
struct clockintr cq_hardclock; /* [o] hardclock handle */
|
||||
struct intrclock cq_intrclock; /* [I] local interrupt clock */
|
||||
struct clockintr_stat cq_stat; /* [o] dispatch statistics */
|
||||
volatile uint32_t cq_gen; /* [o] cq_stat update generation */
|
||||
@ -124,9 +124,9 @@ void clockintr_trigger(void);
|
||||
*/
|
||||
|
||||
uint64_t clockintr_advance(struct clockintr *, uint64_t);
|
||||
void clockintr_cancel(struct clockintr *);
|
||||
struct clockintr *clockintr_establish(struct cpu_info *,
|
||||
void clockintr_bind(struct clockintr *, struct cpu_info *,
|
||||
void (*)(struct clockrequest *, void *, void *), void *);
|
||||
void clockintr_cancel(struct clockintr *);
|
||||
void clockintr_schedule(struct clockintr *, uint64_t);
|
||||
void clockintr_stagger(struct clockintr *, uint64_t, uint32_t, uint32_t);
|
||||
uint64_t clockrequest_advance(struct clockrequest *, uint64_t);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sched.h,v 1.69 2024/01/14 17:23:56 cheloha Exp $ */
|
||||
/* $OpenBSD: sched.h,v 1.70 2024/01/24 19:23:38 cheloha Exp $ */
|
||||
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
|
||||
|
||||
/*-
|
||||
@ -95,11 +95,11 @@ struct cpustats {
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#include <sys/clockintr.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#define SCHED_NQS 32 /* 32 run queues. */
|
||||
|
||||
struct clockintr;
|
||||
struct smr_entry;
|
||||
|
||||
/*
|
||||
@ -115,10 +115,10 @@ struct schedstate_percpu {
|
||||
u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */
|
||||
u_char spc_curpriority; /* usrpri of curproc */
|
||||
|
||||
struct clockintr *spc_itimer; /* [o] itimer_update handle */
|
||||
struct clockintr *spc_profclock; /* [o] profclock handle */
|
||||
struct clockintr *spc_roundrobin; /* [o] roundrobin handle */
|
||||
struct clockintr *spc_statclock; /* [o] statclock handle */
|
||||
struct clockintr spc_itimer; /* [o] itimer_update handle */
|
||||
struct clockintr spc_profclock; /* [o] profclock handle */
|
||||
struct clockintr spc_roundrobin;/* [o] roundrobin handle */
|
||||
struct clockintr spc_statclock; /* [o] statclock handle */
|
||||
|
||||
u_int spc_nrun; /* procs on the run queues */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rde.c,v 1.616 2024/01/23 16:13:35 claudio Exp $ */
|
||||
/* $OpenBSD: rde.c,v 1.617 2024/01/24 14:51:11 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
||||
@ -2139,8 +2139,8 @@ rde_attr_parse(struct ibuf *buf, struct rde_peer *peer,
|
||||
if (!CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE,
|
||||
ATTR_PARTIAL))
|
||||
goto bad_flags;
|
||||
if (community_add(&state->communities, flags, p,
|
||||
attr_len) == -1) {
|
||||
if (community_add(&state->communities, flags,
|
||||
&attrbuf) == -1) {
|
||||
/*
|
||||
* mark update as bad and withdraw all routes as per
|
||||
* RFC 7606
|
||||
@ -2149,14 +2149,13 @@ rde_attr_parse(struct ibuf *buf, struct rde_peer *peer,
|
||||
log_peer_warnx(&peer->conf, "bad COMMUNITIES, "
|
||||
"path invalidated and prefix withdrawn");
|
||||
}
|
||||
plen += attr_len;
|
||||
break;
|
||||
case ATTR_LARGE_COMMUNITIES:
|
||||
if (!CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE,
|
||||
ATTR_PARTIAL))
|
||||
goto bad_flags;
|
||||
if (community_large_add(&state->communities, flags, p,
|
||||
attr_len) == -1) {
|
||||
if (community_large_add(&state->communities, flags,
|
||||
&attrbuf) == -1) {
|
||||
/*
|
||||
* mark update as bad and withdraw all routes as per
|
||||
* RFC 7606
|
||||
@ -2165,14 +2164,13 @@ rde_attr_parse(struct ibuf *buf, struct rde_peer *peer,
|
||||
log_peer_warnx(&peer->conf, "bad LARGE COMMUNITIES, "
|
||||
"path invalidated and prefix withdrawn");
|
||||
}
|
||||
plen += attr_len;
|
||||
break;
|
||||
case ATTR_EXT_COMMUNITIES:
|
||||
if (!CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE,
|
||||
ATTR_PARTIAL))
|
||||
goto bad_flags;
|
||||
if (community_ext_add(&state->communities, flags,
|
||||
peer->conf.ebgp, p, attr_len) == -1) {
|
||||
peer->conf.ebgp, &attrbuf) == -1) {
|
||||
/*
|
||||
* mark update as bad and withdraw all routes as per
|
||||
* RFC 7606
|
||||
@ -2181,7 +2179,6 @@ rde_attr_parse(struct ibuf *buf, struct rde_peer *peer,
|
||||
log_peer_warnx(&peer->conf, "bad EXT_COMMUNITIES, "
|
||||
"path invalidated and prefix withdrawn");
|
||||
}
|
||||
plen += attr_len;
|
||||
break;
|
||||
case ATTR_ORIGINATOR_ID:
|
||||
if (attr_len != 4)
|
||||
@ -2338,14 +2335,11 @@ rde_attr_add(struct filterstate *state, struct ibuf *buf)
|
||||
|
||||
switch (type) {
|
||||
case ATTR_COMMUNITIES:
|
||||
return community_add(&state->communities, flags,
|
||||
ibuf_data(buf), attr_len);
|
||||
return community_add(&state->communities, flags, buf);
|
||||
case ATTR_LARGE_COMMUNITIES:
|
||||
return community_large_add(&state->communities, flags,
|
||||
ibuf_data(buf), attr_len);
|
||||
return community_large_add(&state->communities, flags, buf);
|
||||
case ATTR_EXT_COMMUNITIES:
|
||||
return community_ext_add(&state->communities, flags, 0,
|
||||
ibuf_data(buf), attr_len);
|
||||
return community_ext_add(&state->communities, flags, 0, buf);
|
||||
}
|
||||
|
||||
if (attr_optadd(&state->aspath, flags, type, ibuf_data(buf),
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rde.h,v 1.298 2024/01/23 16:13:35 claudio Exp $ */
|
||||
/* $OpenBSD: rde.h,v 1.299 2024/01/24 14:51:12 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
|
||||
@ -435,10 +435,9 @@ int community_set(struct rde_community *, struct community *,
|
||||
void community_delete(struct rde_community *, struct community *,
|
||||
struct rde_peer *);
|
||||
|
||||
int community_add(struct rde_community *, int, void *, size_t);
|
||||
int community_large_add(struct rde_community *, int, void *, size_t);
|
||||
int community_ext_add(struct rde_community *, int, int, void *, size_t);
|
||||
|
||||
int community_add(struct rde_community *, int, struct ibuf *);
|
||||
int community_large_add(struct rde_community *, int, struct ibuf *);
|
||||
int community_ext_add(struct rde_community *, int, int, struct ibuf *);
|
||||
int community_writebuf(struct rde_community *, uint8_t, int, struct ibuf *);
|
||||
|
||||
void communities_shutdown(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rde_community.c,v 1.14 2023/10/10 14:36:28 claudio Exp $ */
|
||||
/* $OpenBSD: rde_community.c,v 1.15 2024/01/24 14:51:12 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
|
||||
@ -418,24 +418,23 @@ struct rde_peer *peer)
|
||||
* - community_ext_add for ATTR_EXT_COMMUNITIES
|
||||
*/
|
||||
int
|
||||
community_add(struct rde_community *comm, int flags, void *buf, size_t len)
|
||||
community_add(struct rde_community *comm, int flags, struct ibuf *buf)
|
||||
{
|
||||
struct community set = { .flags = COMMUNITY_TYPE_BASIC };
|
||||
uint8_t *b = buf;
|
||||
uint16_t c;
|
||||
size_t l;
|
||||
uint16_t data1, data2;
|
||||
|
||||
if (len == 0 || len % 4 != 0)
|
||||
if (ibuf_size(buf) == 0 || ibuf_size(buf) % 4 != 0)
|
||||
return -1;
|
||||
|
||||
if (flags & ATTR_PARTIAL)
|
||||
comm->flags |= PARTIAL_COMMUNITIES;
|
||||
|
||||
for (l = 0; l < len; l += 4, b += 4) {
|
||||
memcpy(&c, b, sizeof(c));
|
||||
set.data1 = ntohs(c);
|
||||
memcpy(&c, b + 2, sizeof(c));
|
||||
set.data2 = ntohs(c);
|
||||
while (ibuf_size(buf) > 0) {
|
||||
if (ibuf_get_n16(buf, &data1) == -1 ||
|
||||
ibuf_get_n16(buf, &data2) == -1)
|
||||
return -1;
|
||||
set.data1 = data1;
|
||||
set.data2 = data2;
|
||||
insert_community(comm, &set);
|
||||
}
|
||||
|
||||
@ -443,26 +442,21 @@ community_add(struct rde_community *comm, int flags, void *buf, size_t len)
|
||||
}
|
||||
|
||||
int
|
||||
community_large_add(struct rde_community *comm, int flags, void *buf,
|
||||
size_t len)
|
||||
community_large_add(struct rde_community *comm, int flags, struct ibuf *buf)
|
||||
{
|
||||
struct community set = { .flags = COMMUNITY_TYPE_LARGE };
|
||||
uint8_t *b = buf;
|
||||
size_t l;
|
||||
|
||||
if (len == 0 || len % 12 != 0)
|
||||
if (ibuf_size(buf) == 0 || ibuf_size(buf) % 12 != 0)
|
||||
return -1;
|
||||
|
||||
if (flags & ATTR_PARTIAL)
|
||||
comm->flags |= PARTIAL_LARGE_COMMUNITIES;
|
||||
|
||||
for (l = 0; l < len; l += 12, b += 12) {
|
||||
memcpy(&set.data1, b, sizeof(set.data1));
|
||||
memcpy(&set.data2, b + 4, sizeof(set.data2));
|
||||
memcpy(&set.data3, b + 8, sizeof(set.data3));
|
||||
set.data1 = ntohl(set.data1);
|
||||
set.data2 = ntohl(set.data2);
|
||||
set.data3 = ntohl(set.data3);
|
||||
while (ibuf_size(buf) > 0) {
|
||||
if (ibuf_get_n32(buf, &set.data1) == -1 ||
|
||||
ibuf_get_n32(buf, &set.data2) == -1 ||
|
||||
ibuf_get_n32(buf, &set.data3) == -1)
|
||||
return -1;
|
||||
insert_community(comm, &set);
|
||||
}
|
||||
|
||||
@ -471,23 +465,22 @@ community_large_add(struct rde_community *comm, int flags, void *buf,
|
||||
|
||||
int
|
||||
community_ext_add(struct rde_community *comm, int flags, int ebgp,
|
||||
void *buf, size_t len)
|
||||
struct ibuf *buf)
|
||||
{
|
||||
struct community set = { .flags = COMMUNITY_TYPE_EXT };
|
||||
uint8_t *b = buf, type;
|
||||
uint64_t c;
|
||||
size_t l;
|
||||
uint8_t type;
|
||||
|
||||
if (len == 0 || len % 8 != 0)
|
||||
if (ibuf_size(buf) == 0 || ibuf_size(buf) % 8 != 0)
|
||||
return -1;
|
||||
|
||||
if (flags & ATTR_PARTIAL)
|
||||
comm->flags |= PARTIAL_EXT_COMMUNITIES;
|
||||
|
||||
for (l = 0; l < len; l += 8, b += 8) {
|
||||
memcpy(&c, b, 8);
|
||||
while (ibuf_size(buf) > 0) {
|
||||
if (ibuf_get_n64(buf, &c) == -1)
|
||||
return (-1);
|
||||
|
||||
c = be64toh(c);
|
||||
type = c >> 56;
|
||||
/* filter out non-transitive ext communuties from ebgp peers */
|
||||
if (ebgp && (type & EXT_COMMUNITY_NON_TRANSITIVE))
|
||||
|
Loading…
Reference in New Issue
Block a user