sync with OpenBSD -current

This commit is contained in:
purplerain 2024-04-23 01:36:57 +00:00
parent 62f1a75fe4
commit 01dd575d45
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
36 changed files with 399 additions and 217 deletions

View File

@ -1,12 +1,11 @@
# $OpenBSD: Makefile,v 1.56 2024/03/26 01:18:16 beck Exp $
# $OpenBSD: Makefile,v 1.57 2024/04/22 07:31:54 anton Exp $
SUBDIR += api
SUBDIR += asn1
SUBDIR += buffer
SUBDIR += bytestring
SUBDIR += ciphers
#Disable for now for upcoming changes. This needs to be easier to deal with.
#SUBDIR += client
SUBDIR += client
SUBDIR += dtls
SUBDIR += exporter
SUBDIR += handshake

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.4 2023/04/23 18:59:41 tb Exp $
# $OpenBSD: Makefile,v 1.5 2024/04/22 07:31:54 anton Exp $
PROG= clienttest
LDADD= ${SSL_INT} -lcrypto
@ -6,4 +6,7 @@ DPADD= ${LIBSSL} ${LIBCRYPTO}
WARNINGS= Yes
CFLAGS+= -DLIBRESSL_INTERNAL -Werror
# Disable for now for upcoming changes. This needs to be easier to deal with.
REGRESS_EXPECTED_FAILURES+=run-regress-clienttest
.include <bsd.regress.mk>

View File

@ -1,4 +1,4 @@
/* $Id: test-aspa.c,v 1.7 2024/03/20 04:39:10 job Exp $ */
/* $Id: test-aspa.c,v 1.8 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2022 Job Snijders <job@fastly.com>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -34,6 +34,7 @@
int outformats;
int verbose;
int filemode = 1;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-cert.c,v 1.23 2023/05/30 12:14:48 claudio Exp $ */
/* $Id: test-cert.c,v 1.24 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -35,6 +35,7 @@
int outformats;
int verbose;
int filemode;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-gbr.c,v 1.17 2024/03/20 04:39:10 job Exp $ */
/* $Id: test-gbr.c,v 1.18 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -33,6 +33,7 @@
int outformats;
int verbose;
int filemode = 1;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-geofeed.c,v 1.5 2023/09/25 11:09:30 tb Exp $ */
/* $Id: test-geofeed.c,v 1.6 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -33,6 +33,7 @@
int outformats;
int verbose;
int filemode;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-ip.c,v 1.9 2023/05/30 12:14:48 claudio Exp $ */
/* $Id: test-ip.c,v 1.10 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -34,6 +34,7 @@
int outformats;
int verbose;
int filemode;
int experimental;
static void
test(const char *res, uint16_t afiv, size_t sz, size_t unused, ...)

View File

@ -1,4 +1,4 @@
/* $Id: test-mft.c,v 1.28 2024/03/20 04:39:10 job Exp $ */
/* $Id: test-mft.c,v 1.29 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -36,6 +36,7 @@
int outformats;
int verbose;
int filemode = 1;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-roa.c,v 1.25 2024/03/20 04:39:10 job Exp $ */
/* $Id: test-roa.c,v 1.26 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -33,6 +33,7 @@
int outformats;
int verbose;
int filemode = 1;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $OpenBSD: test-rrdp.c,v 1.9 2024/01/08 08:26:38 tb Exp $ */
/* $OpenBSD: test-rrdp.c,v 1.10 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
@ -38,6 +38,7 @@
int filemode;
int outformats;
int verbose;
int experimental;
#define REGRESS_NOTIFY_URI "https://rpki.example.com/notify.xml"

View File

@ -1,4 +1,4 @@
/* $Id: test-rsc.c,v 1.9 2023/09/25 11:09:30 tb Exp $ */
/* $Id: test-rsc.c,v 1.10 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -36,6 +36,7 @@
int outformats;
int verbose;
int filemode;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-spl.c,v 1.2 2024/03/20 04:39:10 job Exp $ */
/* $Id: test-spl.c,v 1.3 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2024 Job Snijders <job@fastly.com>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -34,6 +34,7 @@
int outformats;
int verbose;
int filemode = 1;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-tak.c,v 1.7 2024/03/20 04:39:10 job Exp $ */
/* $Id: test-tak.c,v 1.8 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2022 Job Snijders <job@fastly.com>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -34,6 +34,7 @@
int outformats;
int verbose;
int filemode = 1;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $Id: test-tal.c,v 1.13 2023/06/20 12:52:32 job Exp $ */
/* $Id: test-tal.c,v 1.14 2024/04/22 05:54:01 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@ -32,6 +32,7 @@
int outformats;
int verbose;
int filemode;
int experimental;
int
main(int argc, char *argv[])

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pfctl_parser.c,v 1.350 2024/02/07 23:53:44 jsg Exp $ */
/* $OpenBSD: pfctl_parser.c,v 1.351 2024/04/22 13:30:22 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -519,7 +519,8 @@ print_pool(struct pf_pool *pool, u_int16_t p1, u_int16_t p2,
const char *pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
const char *pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
const char *pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
const char *pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
const char *pf_scounters[SCNT_MAX+1] = FCNT_NAMES;
const char *pf_ncounters[NCNT_MAX+1] = FCNT_NAMES;
void
print_status(struct pf_status *s, struct pfctl_watermarks *synflwats, int opts)
@ -617,6 +618,20 @@ print_status(struct pf_status *s, struct pfctl_watermarks *synflwats, int opts)
printf("%14s\n", "");
}
}
if (opts & PF_OPT_VERBOSE) {
printf("Fragments\n");
printf(" %-25s %14u %14s\n", "current entries",
s->fragments, "");
for (i = 0; i < NCNT_MAX; i++) {
printf(" %-25s %14lld ", pf_ncounters[i],
s->ncounters[i]);
if (runtime > 0)
printf("%14.1f/s\n",
(double)s->ncounters[i] / (double)runtime);
else
printf("%14s\n", "");
}
}
printf("Counters\n");
for (i = 0; i < PFRES_MAX; i++) {
printf(" %-25s %14llu ", pf_reasons[i],

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pf_ioctl.c,v 1.415 2023/07/06 04:55:05 dlg Exp $ */
/* $OpenBSD: pf_ioctl.c,v 1.416 2024/04/22 13:30:22 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -1955,7 +1955,9 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
struct pf_status *s = (struct pf_status *)addr;
NET_LOCK();
PF_LOCK();
PF_FRAG_LOCK();
memcpy(s, &pf_status, sizeof(struct pf_status));
PF_FRAG_UNLOCK();
pfi_update_status(s->ifname, s);
PF_UNLOCK();
NET_UNLOCK();
@ -1996,6 +1998,9 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
memset(pf_status.counters, 0, sizeof(pf_status.counters));
memset(pf_status.fcounters, 0, sizeof(pf_status.fcounters));
memset(pf_status.scounters, 0, sizeof(pf_status.scounters));
PF_FRAG_LOCK();
memset(pf_status.ncounters, 0, sizeof(pf_status.ncounters));
PF_FRAG_UNLOCK();
pf_status.since = getuptime();
PF_UNLOCK();
@ -3271,7 +3276,9 @@ pf_sysctl(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
NET_LOCK_SHARED();
PF_LOCK();
PF_FRAG_LOCK();
memcpy(&pfs, &pf_status, sizeof(struct pf_status));
PF_FRAG_UNLOCK();
pfi_update_status(pfs.ifname, &pfs);
PF_UNLOCK();
NET_UNLOCK_SHARED();

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pf_norm.c,v 1.229 2023/10/10 11:25:31 bluhm Exp $ */
/* $OpenBSD: pf_norm.c,v 1.230 2024/04/22 13:30:22 bluhm Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@ -150,13 +150,10 @@ int pf_reassemble6(struct mbuf **, struct ip6_frag *,
/* Globals */
struct pool pf_frent_pl, pf_frag_pl, pf_frnode_pl;
struct pool pf_state_scrub_pl;
int pf_nfrents;
struct mutex pf_frag_mtx;
#define PF_FRAG_LOCK_INIT() mtx_init(&pf_frag_mtx, IPL_SOFTNET)
#define PF_FRAG_LOCK() mtx_enter(&pf_frag_mtx)
#define PF_FRAG_UNLOCK() mtx_leave(&pf_frag_mtx)
void
pf_normalize_init(void)
@ -233,11 +230,12 @@ void
pf_flush_fragments(void)
{
struct pf_fragment *frag;
int goal;
u_int goal;
goal = pf_nfrents * 9 / 10;
DPFPRINTF(LOG_NOTICE, "trying to free > %d frents", pf_nfrents - goal);
while (goal < pf_nfrents) {
goal = pf_status.fragments * 9 / 10;
DPFPRINTF(LOG_NOTICE, "trying to free > %u frents",
pf_status.fragments - goal);
while (goal < pf_status.fragments) {
if ((frag = TAILQ_LAST(&pf_fragqueue, pf_fragqueue)) == NULL)
break;
pf_free_fragment(frag);
@ -268,9 +266,10 @@ pf_free_fragment(struct pf_fragment *frag)
/* Free all fragment entries */
while ((frent = TAILQ_FIRST(&frag->fr_queue)) != NULL) {
TAILQ_REMOVE(&frag->fr_queue, frent, fr_next);
pf_status.ncounters[NCNT_FRAG_REMOVALS]++;
m_freem(frent->fe_m);
pool_put(&pf_frent_pl, frent);
pf_nfrents--;
pf_status.fragments--;
}
pool_put(&pf_frag_pl, frag);
}
@ -283,6 +282,7 @@ pf_find_fragment(struct pf_frnode *key, u_int32_t id)
u_int32_t stale;
frnode = RB_FIND(pf_frnode_tree, &pf_frnode_tree, key);
pf_status.ncounters[NCNT_FRAG_SEARCH]++;
if (frnode == NULL)
return (NULL);
KASSERT(frnode->fn_fragments >= 1);
@ -328,7 +328,7 @@ pf_create_fragment(u_short *reason)
return (NULL);
}
}
pf_nfrents++;
pf_status.fragments++;
return (frent);
}
@ -405,6 +405,7 @@ pf_frent_insert(struct pf_fragment *frag, struct pf_frent *frent,
KASSERT(prev->fe_off + prev->fe_len <= frent->fe_off);
TAILQ_INSERT_AFTER(&frag->fr_queue, prev, frent, fr_next);
}
pf_status.ncounters[NCNT_FRAG_INSERT]++;
if (frag->fr_firstoff[index] == NULL) {
KASSERT(prev == NULL || pf_frent_index(prev) < index);
@ -456,6 +457,7 @@ pf_frent_remove(struct pf_fragment *frag, struct pf_frent *frent)
}
TAILQ_REMOVE(&frag->fr_queue, frent, fr_next);
pf_status.ncounters[NCNT_FRAG_REMOVALS]++;
KASSERT(frag->fr_entries[index] > 0);
frag->fr_entries[index]--;
@ -689,7 +691,7 @@ pf_fillup_fragment(struct pf_frnode *key, u_int32_t id,
"fragment requeue limit exceeded");
m_freem(after->fe_m);
pool_put(&pf_frent_pl, after);
pf_nfrents--;
pf_status.fragments--;
/* There is not way to recover */
goto free_fragment;
}
@ -703,7 +705,7 @@ pf_fillup_fragment(struct pf_frnode *key, u_int32_t id,
pf_frent_remove(frag, after);
m_freem(after->fe_m);
pool_put(&pf_frent_pl, after);
pf_nfrents--;
pf_status.fragments--;
}
/* If part of the queue gets too long, there is not way to recover. */
@ -730,7 +732,7 @@ bad_fragment:
REASON_SET(reason, PFRES_FRAG);
drop_fragment:
pool_put(&pf_frent_pl, frent);
pf_nfrents--;
pf_status.fragments--;
return (NULL);
}
@ -742,6 +744,7 @@ pf_join_fragment(struct pf_fragment *frag)
frent = TAILQ_FIRST(&frag->fr_queue);
TAILQ_REMOVE(&frag->fr_queue, frent, fr_next);
pf_status.ncounters[NCNT_FRAG_REMOVALS]++;
m = frent->fe_m;
/* Strip off any trailing bytes */
@ -752,10 +755,11 @@ pf_join_fragment(struct pf_fragment *frag)
m->m_next = NULL;
m_cat(m, m2);
pool_put(&pf_frent_pl, frent);
pf_nfrents--;
pf_status.fragments--;
while ((frent = TAILQ_FIRST(&frag->fr_queue)) != NULL) {
TAILQ_REMOVE(&frag->fr_queue, frent, fr_next);
pf_status.ncounters[NCNT_FRAG_REMOVALS]++;
m2 = frent->fe_m;
/* Strip off ip header */
m_adj(m2, frent->fe_hdrlen);
@ -763,7 +767,7 @@ pf_join_fragment(struct pf_fragment *frag)
if (frent->fe_len < m2->m_pkthdr.len)
m_adj(m2, frent->fe_len - m2->m_pkthdr.len);
pool_put(&pf_frent_pl, frent);
pf_nfrents--;
pf_status.fragments--;
m_removehdr(m2);
m_cat(m, m2);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pfvar.h,v 1.535 2024/01/01 22:16:51 bluhm Exp $ */
/* $OpenBSD: pfvar.h,v 1.536 2024/04/22 13:30:22 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -1192,6 +1192,11 @@ enum pfi_kif_refs {
#define SCNT_SRC_NODE_REMOVALS 2
#define SCNT_MAX 3
#define NCNT_FRAG_SEARCH 0
#define NCNT_FRAG_INSERT 1
#define NCNT_FRAG_REMOVALS 2
#define NCNT_MAX 3
#define REASON_SET(a, x) \
do { \
if ((void *)(a) != NULL) { \
@ -1206,6 +1211,7 @@ struct pf_status {
u_int64_t lcounters[LCNT_MAX]; /* limit counters */
u_int64_t fcounters[FCNT_MAX];
u_int64_t scounters[SCNT_MAX];
u_int64_t ncounters[NCNT_MAX];
u_int64_t pcounters[2][2][3];
u_int64_t bcounters[2][2];
u_int64_t stateid;
@ -1215,6 +1221,7 @@ struct pf_status {
u_int32_t states;
u_int32_t states_halfopen;
u_int32_t src_nodes;
u_int32_t fragments;
u_int32_t debug;
u_int32_t hostid;
u_int32_t reass; /* reassembly */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pfvar_priv.h,v 1.35 2024/01/01 22:16:51 bluhm Exp $ */
/* $OpenBSD: pfvar_priv.h,v 1.36 2024/04/22 13:30:22 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -370,6 +370,7 @@ void pf_state_unref(struct pf_state *);
extern struct rwlock pf_lock;
extern struct rwlock pf_state_lock;
extern struct mutex pf_frag_mtx;
extern struct mutex pf_inp_mtx;
#define PF_LOCK() do { \
@ -415,6 +416,9 @@ extern struct mutex pf_inp_mtx;
rw_status(&pf_state_lock), __func__);\
} while (0)
#define PF_FRAG_LOCK() mtx_enter(&pf_frag_mtx)
#define PF_FRAG_UNLOCK() mtx_leave(&pf_frag_mtx)
/* for copies to/from network byte order */
void pf_state_peer_hton(const struct pf_state_peer *,
struct pfsync_state_peer *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dsp.c,v 1.19 2024/03/20 08:42:11 ratchov Exp $ */
/* $OpenBSD: dsp.c,v 1.20 2024/04/22 12:32:51 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@ -19,23 +19,38 @@
#include "utils.h"
const int aparams_ctltovol[128] = {
0,
256, 266, 276, 287, 299, 310, 323, 335,
348, 362, 376, 391, 406, 422, 439, 456,
474, 493, 512, 532, 553, 575, 597, 621,
645, 670, 697, 724, 753, 782, 813, 845,
878, 912, 948, 985, 1024, 1064, 1106, 1149,
1195, 1241, 1290, 1341, 1393, 1448, 1505, 1564,
1625, 1689, 1756, 1825, 1896, 1971, 2048, 2128,
2212, 2299, 2389, 2483, 2580, 2682, 2787, 2896,
3010, 3128, 3251, 3379, 3511, 3649, 3792, 3941,
4096, 4257, 4424, 4598, 4778, 4966, 5161, 5363,
5574, 5793, 6020, 6256, 6502, 6757, 7023, 7298,
7585, 7883, 8192, 8514, 8848, 9195, 9556, 9931,
10321, 10726, 11148, 11585, 12040, 12513, 13004, 13515,
14045, 14596, 15170, 15765, 16384, 17027, 17696, 18390,
19112, 19863, 20643, 21453, 22295, 23170, 24080, 25025,
26008, 27029, 28090, 29193, 30339, 31530, 32768
0, 65536, 68109, 70783,
73562, 76450, 79451, 82570,
85812, 89181, 92682, 96321,
100102, 104032, 108116, 112361,
116772, 121356, 126121, 131072,
136218, 141566, 147123, 152899,
158902, 165140, 171624, 178361,
185364, 192641, 200204, 208064,
216232, 224721, 233544, 242713,
252241, 262144, 272436, 283131,
294247, 305799, 317804, 330281,
343247, 356723, 370728, 385282,
400408, 416128, 432465, 449443,
467088, 485425, 504482, 524288,
544871, 566262, 588493, 611597,
635608, 660561, 686495, 713446,
741455, 770564, 800816, 832255,
864929, 898885, 934175, 970850,
1008965, 1048576, 1089742, 1132525,
1176987, 1223194, 1271216, 1321123,
1372989, 1426892, 1482910, 1541128,
1601632, 1664511, 1729858, 1797771,
1868350, 1941700, 2017930, 2097152,
2179485, 2265049, 2353974, 2446389,
2542432, 2642246, 2745978, 2853783,
2965821, 3082257, 3203264, 3329021,
3459716, 3595542, 3736700, 3883400,
4035859, 4194304, 4358969, 4530099,
4707947, 4892777, 5084864, 5284492,
5491957, 5707567, 5931642, 6164513,
6406527, 6658043, 6919432, 7191084,
7473400, 7766800, 8071719, 8388608
};
const short dec_ulawmap[256] = {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dsp.h,v 1.10 2022/12/26 19:16:00 jmc Exp $ */
/* $OpenBSD: dsp.h,v 1.12 2024/04/22 12:32:51 ratchov Exp $ */
/*
* Copyright (c) 2012 Alexandre Ratchov <alex@caoua.org>
*
@ -74,9 +74,9 @@ typedef int adata_t;
struct aparams {
unsigned int bps; /* bytes per sample */
unsigned int bits; /* actually used bits */
unsigned int le; /* 1 if little endian, 0 if big endian */
unsigned int le; /* 1 if little endian, else be */
unsigned int sig; /* 1 if signed, 0 if unsigned */
unsigned int msb; /* 1 if msb justified, 0 if lsb justified */
unsigned int msb; /* 1 if msb justified, else lsb */
};
struct resamp {
@ -93,7 +93,7 @@ struct conv {
int bfirst; /* bytes to skip at startup */
unsigned int bps; /* bytes per sample */
unsigned int shift; /* shift to get 32bit MSB */
unsigned int bias; /* bias of unsigned samples */
unsigned int bias; /* bias of unsigned samples */
int bnext; /* to reach the next byte */
int snext; /* to reach the next sample */
int nch;
@ -107,7 +107,7 @@ struct cmap {
int nch;
};
#define MIDI_TO_ADATA(m) (aparams_ctltovol[m] << (ADATA_BITS - 16))
#define MIDI_TO_ADATA(m) (aparams_ctltovol[m])
extern const int aparams_ctltovol[128];
void aparams_init(struct aparams *);

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: newsyslog.8,v 1.54 2017/07/20 18:39:16 jca Exp $
.\" $OpenBSD: newsyslog.8,v 1.55 2024/04/22 14:16:14 jmc Exp $
.\"
.\" Copyright (c) 1997, Jason Downs. All rights reserved.
.\"
@ -41,7 +41,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
.Dd $Mdocdate: July 20 2017 $
.Dd $Mdocdate: April 22 2024 $
.Dt NEWSYSLOG 8
.Os
.Sh NAME
@ -399,7 +399,7 @@ signal (usually
to instead of
.Pa /var/run/syslog.pid .
.It Ar signal
Specify the signal to send to the process instead of
This optional field specifies the signal to send to the process instead of
.Dv SIGHUP .
Signal names
must start with

View File

@ -1,4 +1,4 @@
/* $OpenBSD: newsyslog.c,v 1.113 2023/03/08 04:43:12 guenther Exp $ */
/* $OpenBSD: newsyslog.c,v 1.114 2024/04/22 14:20:35 millert Exp $ */
/*
* Copyright (c) 1999, 2002, 2003 Todd C. Miller <millert@openbsd.org>
@ -616,7 +616,7 @@ nextline:
q = sob(++parse); /* Optional field */
if (*q == 'Z' || *q == 'z' || *q == 'B' || *q == 'b' ||
*q == 'M' || *q == 'm') {
*q == 'M' || *q == 'm' || *q == 'F' || *q == 'f') {
*(parse = son(q)) = '\0';
while (*q) {
switch (*q) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sndioctl.c,v 1.19 2023/01/31 21:38:01 ratchov Exp $ */
/* $OpenBSD: sndioctl.c,v 1.20 2024/04/22 10:49:01 ratchov Exp $ */
/*
* Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
*
@ -879,12 +879,7 @@ ondesc(void *arg, struct sioctl_desc *d, int curval)
*/
for (pi = &infolist; (i = *pi) != NULL; pi = &i->next) {
cmp = cmpdesc(d, &i->desc);
if (cmp == 0) {
fprintf(stderr, "fatal: duplicate control:\n");
print_ent(i, "duplicate");
exit(1);
}
if (cmp < 0)
if (cmp <= 0)
break;
}
i = malloc(sizeof(struct info));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dev.c,v 1.108 2024/04/02 05:21:32 ratchov Exp $ */
/* $OpenBSD: dev.c,v 1.112 2024/04/22 11:01:02 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@ -41,8 +41,6 @@ void dev_sub_bcopy(struct dev *, struct slot *);
void dev_onmove(struct dev *, int);
void dev_master(struct dev *, unsigned int);
void dev_cycle(struct dev *);
struct dev *dev_new(char *, struct aparams *, unsigned int, unsigned int,
unsigned int, unsigned int, unsigned int, unsigned int);
void dev_adjpar(struct dev *, int, int, int);
int dev_allocbufs(struct dev *);
void dev_freebufs(struct dev *);
@ -519,7 +517,8 @@ dev_mix_badd(struct dev *d, struct slot *s)
}
if (s->mix.resampbuf) {
resamp_do(&s->mix.resamp, in, s->mix.resampbuf, s->round);
resamp_do(&s->mix.resamp,
in, s->mix.resampbuf, s->round, d->round);
in = s->mix.resampbuf;
}
@ -656,7 +655,7 @@ dev_sub_bcopy(struct dev *d, struct slot *s)
if (s->sub.resampbuf) {
resamp_do(&s->sub.resamp,
s->sub.resampbuf, resamp_out, d->round);
s->sub.resampbuf, resamp_out, d->round, s->round);
}
if (s->sub.encbuf)
@ -2340,6 +2339,8 @@ ctlslot_update(struct ctlslot *s)
/* if control is hidden */
c->desc_mask |= s->self;
}
if (s->ops)
s->ops->sync(s->arg);
}
void
@ -2553,6 +2554,7 @@ ctl_update(struct ctl *c)
c->refs_mask |= s->self;
/* if control is hidden */
c->desc_mask |= s->self;
s->ops->sync(s->arg);
}
}
@ -2601,16 +2603,18 @@ ctl_onval(int scope, void *arg0, void *arg1, int val)
return 1;
}
void
int
ctl_del(int scope, void *arg0, void *arg1)
{
struct ctl *c, **pc;
int found;
found = 0;
pc = &ctl_list;
for (;;) {
c = *pc;
if (c == NULL)
return;
return found;
if (ctl_match(c, scope, arg0, arg1)) {
#ifdef DEBUG
if (log_level >= 2) {
@ -2618,6 +2622,7 @@ ctl_del(int scope, void *arg0, void *arg1)
log_puts(": removed\n");
}
#endif
found++;
c->refs_mask &= ~CTL_DEVMASK;
if (c->refs_mask == 0) {
*pc = c->next;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dev.h,v 1.43 2022/12/26 19:16:03 jmc Exp $ */
/* $OpenBSD: dev.h,v 1.44 2024/04/22 10:39:51 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@ -352,7 +352,7 @@ void slot_detach(struct slot *);
struct ctl *ctl_new(int, void *, void *,
int, char *, char *, int, char *, char *, int, int, int);
void ctl_del(int, void *, void *);
int ctl_del(int, void *, void *);
void ctl_log(struct ctl *);
int ctl_setval(struct ctl *c, int val);
int ctl_match(struct ctl *, int, void *, void *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dev_sioctl.c,v 1.7 2021/03/03 10:00:27 ratchov Exp $ */
/* $OpenBSD: dev_sioctl.c,v 1.8 2024/04/22 10:43:55 ratchov Exp $ */
/*
* Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
*
@ -81,20 +81,26 @@ dev_sioctl_onval(void *arg, unsigned int addr, unsigned int val)
struct dev *d = arg;
struct ctl *c;
dev_log(d);
log_puts(": onctl: addr = ");
log_putu(addr);
log_puts(", val = ");
log_putu(val);
log_puts("\n");
if (log_level >= 2) {
dev_log(d);
log_puts(": onctl: addr = ");
log_putu(addr);
log_puts(", val = ");
log_putu(val);
log_puts("\n");
}
for (c = ctl_list; c != NULL; c = c->next) {
if (c->scope != CTL_HW || c->u.hw.addr != addr)
continue;
ctl_log(c);
log_puts(": new value -> ");
log_putu(val);
log_puts("\n");
if (log_level >= 2) {
ctl_log(c);
log_puts(": new value -> ");
log_putu(val);
log_puts("\n");
}
c->val_mask = ~0U;
c->curval = val;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dsp.c,v 1.18 2021/07/05 08:29:59 ratchov Exp $ */
/* $OpenBSD: dsp.c,v 1.21 2024/04/22 14:11:35 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@ -19,23 +19,38 @@
#include "utils.h"
const int aparams_ctltovol[128] = {
0,
256, 266, 276, 287, 299, 310, 323, 335,
348, 362, 376, 391, 406, 422, 439, 456,
474, 493, 512, 532, 553, 575, 597, 621,
645, 670, 697, 724, 753, 782, 813, 845,
878, 912, 948, 985, 1024, 1064, 1106, 1149,
1195, 1241, 1290, 1341, 1393, 1448, 1505, 1564,
1625, 1689, 1756, 1825, 1896, 1971, 2048, 2128,
2212, 2299, 2389, 2483, 2580, 2682, 2787, 2896,
3010, 3128, 3251, 3379, 3511, 3649, 3792, 3941,
4096, 4257, 4424, 4598, 4778, 4966, 5161, 5363,
5574, 5793, 6020, 6256, 6502, 6757, 7023, 7298,
7585, 7883, 8192, 8514, 8848, 9195, 9556, 9931,
10321, 10726, 11148, 11585, 12040, 12513, 13004, 13515,
14045, 14596, 15170, 15765, 16384, 17027, 17696, 18390,
19112, 19863, 20643, 21453, 22295, 23170, 24080, 25025,
26008, 27029, 28090, 29193, 30339, 31530, 32768
0, 65536, 68109, 70783,
73562, 76450, 79451, 82570,
85812, 89181, 92682, 96321,
100102, 104032, 108116, 112361,
116772, 121356, 126121, 131072,
136218, 141566, 147123, 152899,
158902, 165140, 171624, 178361,
185364, 192641, 200204, 208064,
216232, 224721, 233544, 242713,
252241, 262144, 272436, 283131,
294247, 305799, 317804, 330281,
343247, 356723, 370728, 385282,
400408, 416128, 432465, 449443,
467088, 485425, 504482, 524288,
544871, 566262, 588493, 611597,
635608, 660561, 686495, 713446,
741455, 770564, 800816, 832255,
864929, 898885, 934175, 970850,
1008965, 1048576, 1089742, 1132525,
1176987, 1223194, 1271216, 1321123,
1372989, 1426892, 1482910, 1541128,
1601632, 1664511, 1729858, 1797771,
1868350, 1941700, 2017930, 2097152,
2179485, 2265049, 2353974, 2446389,
2542432, 2642246, 2745978, 2853783,
2965821, 3082257, 3203264, 3329021,
3459716, 3595542, 3736700, 3883400,
4035859, 4194304, 4358969, 4530099,
4707947, 4892777, 5084864, 5284492,
5491957, 5707567, 5931642, 6164513,
6406527, 6658043, 6919432, 7191084,
7473400, 7766800, 8071719, 8388608
};
const int resamp_filt[RESAMP_LENGTH / RESAMP_STEP + 1] = {
@ -269,30 +284,50 @@ aparams_native(struct aparams *par)
}
/*
* resample the given number of frames
* Return the number of input and output frame that would be consumed
* by resamp_do(p, *icnt, *ocnt).
*/
void
resamp_do(struct resamp *p, adata_t *in, adata_t *out, int todo)
resamp_getcnt(struct resamp *p, int *icnt, int *ocnt)
{
long long idiff, odiff;
int cdiff;
cdiff = p->oblksz - p->diff;
idiff = (long long)*icnt * p->oblksz;
odiff = (long long)*ocnt * p->iblksz;
if (odiff - idiff >= cdiff)
*ocnt = (idiff + cdiff + p->iblksz - 1) / p->iblksz;
else
*icnt = (odiff + p->diff) / p->oblksz;
}
/*
* Resample the given number of frames. The number of output frames
* must match the corresponding number of input frames. Either always
* use icnt and ocnt such that:
*
* icnt * oblksz = ocnt * iblksz
*
* or use resamp_getcnt() to calculate the proper numbers.
*/
void
resamp_do(struct resamp *p, adata_t *in, adata_t *out, int icnt, int ocnt)
{
unsigned int nch;
adata_t *idata;
unsigned int oblksz;
unsigned int ifr;
int s, ds, diff;
adata_t *odata;
unsigned int iblksz;
unsigned int ofr;
unsigned int c;
int64_t f[NCHAN_MAX];
adata_t *ctxbuf, *ctx;
unsigned int ctx_start;
int q, qi, qf, n;
#ifdef DEBUG
if (todo % p->iblksz != 0) {
log_puts("resamp_do: partial blocks not supported\n");
panic();
}
#endif
/*
* Partially copy structures into local variables, to avoid
* unnecessary indirections; this also allows the compiler to
@ -300,16 +335,32 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int todo)
*/
idata = in;
odata = out;
diff = p->oblksz;
diff = p->diff;
iblksz = p->iblksz;
oblksz = p->oblksz;
ctxbuf = p->ctx;
ctx_start = p->ctx_start;
nch = p->nch;
ifr = icnt;
ofr = ocnt;
/*
* Start conversion.
*/
#ifdef DEBUG
if (log_level >= 4) {
log_puts("resamp: copying ");
log_puti(ifr);
log_puts(" -> ");
log_putu(ofr);
log_puts(" frames, diff = ");
log_puti(diff);
log_puts("\n");
}
#endif
for (;;) {
if (diff >= oblksz) {
if (todo == 0)
if (ifr == 0)
break;
ctx_start = (ctx_start - 1) & (RESAMP_NCTX - 1);
ctx = ctxbuf + ctx_start;
@ -318,8 +369,10 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int todo)
ctx += RESAMP_NCTX;
}
diff -= oblksz;
todo--;
ifr--;
} else {
if (ofr == 0)
break;
for (c = 0; c < nch; c++)
f[c] = 0;
@ -361,11 +414,40 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int todo)
#endif
*odata++ = s;
}
diff += iblksz;
ofr--;
}
}
p->diff = diff;
p->ctx_start = ctx_start;
#ifdef DEBUG
if (ifr != 0) {
log_puts("resamp_do: ");
log_puti(ifr);
log_puts(": too many input frames\n");
panic();
}
if (ofr != 0) {
log_puts("resamp_do: ");
log_puti(ofr);
log_puts(": too many output frames\n");
panic();
}
#endif
}
static unsigned int
uint_gcd(unsigned int a, unsigned int b)
{
unsigned int r;
while (b > 0) {
r = a % b;
a = b;
b = r;
}
return a;
}
/*
@ -375,8 +457,26 @@ void
resamp_init(struct resamp *p, unsigned int iblksz,
unsigned int oblksz, int nch)
{
unsigned int g;
/*
* reduce iblksz/oblksz fraction
*/
g = uint_gcd(iblksz, oblksz);
iblksz /= g;
oblksz /= g;
/*
* ensure weird rates don't cause integer overflow
*/
while (iblksz > ADATA_UNIT || oblksz > ADATA_UNIT) {
iblksz >>= 1;
oblksz >>= 1;
}
p->iblksz = iblksz;
p->oblksz = oblksz;
p->diff = 0;
p->nch = nch;
p->ctx_start = 0;
memset(p->ctx, 0, sizeof(p->ctx));
@ -734,33 +834,35 @@ cmap_init(struct cmap *p,
int imin, int imax, int isubmin, int isubmax,
int omin, int omax, int osubmin, int osubmax)
{
int cmin, cmax;
int inch, onch, nch;
cmin = -NCHAN_MAX;
if (osubmin > cmin)
cmin = osubmin;
if (omin > cmin)
cmin = omin;
if (isubmin > cmin)
cmin = isubmin;
if (imin > cmin)
cmin = imin;
/*
* Ignore channels outside of the available sets
*/
if (isubmin < imin)
isubmin = imin;
if (isubmax > imax)
isubmax = imax;
if (osubmin < omin)
osubmin = omin;
if (osubmax > omax)
osubmax = omax;
cmax = NCHAN_MAX;
if (osubmax < cmax)
cmax = osubmax;
if (omax < cmax)
cmax = omax;
if (isubmax < cmax)
cmax = isubmax;
if (imax < cmax)
cmax = imax;
/*
* Shrink the input or the output subset to make both subsets of
* the same size
*/
inch = isubmax - isubmin + 1;
onch = osubmax - osubmin + 1;
nch = (inch < onch) ? inch : onch;
isubmax = isubmin + nch - 1;
osubmax = osubmin + nch - 1;
p->ostart = cmin - omin;
p->onext = omax - cmax;
p->istart = cmin - imin;
p->inext = imax - cmax;
p->nch = cmax - cmin + 1;
p->ostart = osubmin - omin;
p->onext = omax - osubmax;
p->istart = isubmin - imin;
p->inext = imax - isubmax;
p->nch = nch;
#ifdef DEBUG
if (log_level >= 3) {
log_puts("cmap: nch = ");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dsp.h,v 1.12 2022/12/26 19:16:03 jmc Exp $ */
/* $OpenBSD: dsp.h,v 1.14 2024/04/22 11:07:42 ratchov Exp $ */
/*
* Copyright (c) 2012 Alexandre Ratchov <alex@caoua.org>
*
@ -85,6 +85,7 @@ struct resamp {
adata_t ctx[NCHAN_MAX * RESAMP_NCTX];
int filt_cutoff, filt_step;
unsigned int iblksz, oblksz;
int diff;
int nch;
};
@ -106,7 +107,7 @@ struct cmap {
int nch;
};
#define MIDI_TO_ADATA(m) (aparams_ctltovol[m] << (ADATA_BITS - 16))
#define MIDI_TO_ADATA(m) (aparams_ctltovol[m])
extern const int aparams_ctltovol[128];
void aparams_init(struct aparams *);
@ -115,7 +116,8 @@ int aparams_strtoenc(struct aparams *, char *);
int aparams_enctostr(struct aparams *, char *);
int aparams_native(struct aparams *);
void resamp_do(struct resamp *, adata_t *, adata_t *, int);
void resamp_getcnt(struct resamp *, int *, int *);
void resamp_do(struct resamp *, adata_t *, adata_t *, int, int);
void resamp_init(struct resamp *, unsigned int, unsigned int, int);
void enc_do(struct conv *, unsigned char *, unsigned char *, int);
void enc_sil_do(struct conv *, unsigned char *, int);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: opt.c,v 1.9 2021/11/01 14:43:25 ratchov Exp $ */
/* $OpenBSD: opt.c,v 1.10 2024/04/22 10:42:04 ratchov Exp $ */
/*
* Copyright (c) 2008-2011 Alexandre Ratchov <alex@caoua.org>
*
@ -375,7 +375,7 @@ opt_done(struct opt *o)
* Set opt's device, and (if necessary) move clients to
* to the new device
*/
void
int
opt_setdev(struct opt *o, struct dev *ndev)
{
struct dev *odev;
@ -385,12 +385,12 @@ opt_setdev(struct opt *o, struct dev *ndev)
int i;
if (!dev_ref(ndev))
return;
return 0;
odev = o->dev;
if (odev == ndev) {
dev_unref(ndev);
return;
return 1;
}
/* check if clients can use new device */
@ -399,18 +399,20 @@ opt_setdev(struct opt *o, struct dev *ndev)
continue;
if (s->ops != NULL && !dev_iscompat(odev, ndev)) {
dev_unref(ndev);
return;
return 0;
}
}
/*
* if we're using MMC, move all opts to the new device, mtc_setdev()
* will call us back
*
* XXX: move this to the end to avoid the recursion
*/
if (o->mtc != NULL && o->mtc->dev != ndev) {
mtc_setdev(o->mtc, ndev);
dev_unref(ndev);
return;
return 1;
}
c = ctl_find(CTL_OPT_DEV, o, o->dev);
@ -468,6 +470,7 @@ opt_setdev(struct opt *o, struct dev *ndev)
}
dev_unref(ndev);
return 1;
}
/*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: opt.h,v 1.7 2021/11/01 14:43:25 ratchov Exp $ */
/* $OpenBSD: opt.h,v 1.8 2024/04/22 10:42:04 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@ -47,7 +47,7 @@ struct opt *opt_byname(char *);
struct opt *opt_bynum(int);
void opt_init(struct opt *);
void opt_done(struct opt *);
void opt_setdev(struct opt *, struct dev *);
int opt_setdev(struct opt *, struct dev *);
struct dev *opt_ref(struct opt *);
void opt_unref(struct opt *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pf.c,v 1.13 2020/09/14 11:15:30 kn Exp $ */
/* $OpenBSD: pf.c,v 1.14 2024/04/22 13:30:22 bluhm Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
*
@ -44,7 +44,8 @@ void print_fld_double(field_def *, double);
const char *pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
const char *pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
const char *pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
const char *pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
const char *pf_scounters[SCNT_MAX+1] = FCNT_NAMES;
const char *pf_ncounters[NCNT_MAX+1] = FCNT_NAMES;
static struct pf_status status;
int num_pf = 0;
@ -104,6 +105,7 @@ read_pf(void)
num_disp += FCNT_MAX + 2;
num_disp += SCNT_MAX + 2;
num_disp += NCNT_MAX + 2;
num_disp += PFRES_MAX + 1;
num_disp += LCNT_MAX + 1;
@ -296,6 +298,17 @@ print_pf(void)
ADD_LINE_V("src track", pf_scounters[i], s->scounters[i]);
}
ADD_EMPTY_LINE;
ADD_LINE_V("fragment", "Count", s->fragments);
for (i = 0; i < NCNT_MAX; i++) {
if (tm > 0)
ADD_LINE_VR("fragment", pf_ncounters[i], s->ncounters[i],
(double)s->ncounters[i] / (double)tm);
else
ADD_LINE_V("fragment", pf_ncounters[i], s->ncounters[i]);
}
ADD_EMPTY_LINE;
for (i = 0; i < PFRES_MAX; i++) {
if (tm > 0)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pftop.c,v 1.46 2023/07/04 11:34:19 sashan Exp $ */
/* $OpenBSD: pftop.c,v 1.47 2024/04/22 14:19:48 jsg Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar
* Copyright (c) 2001 Daniel Hartmeier
@ -716,15 +716,13 @@ unmask(struct pf_addr * m)
void
tb_print_addr(struct pf_addr * addr, struct pf_addr * mask, int af)
{
switch (af) {
case AF_INET: {
tbprintf("%s", inetname(addr->v4));
break;
}
case AF_INET6: {
tbprintf("%s", inet6name(&addr->v6));
break;
}
switch (af) {
case AF_INET:
tbprintf("%s", inetname(addr->v4));
break;
case AF_INET6:
tbprintf("%s", inet6name(&addr->v6));
break;
}
if (mask != NULL) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.116 2024/01/11 15:46:25 claudio Exp $ */
/* $OpenBSD: control.c,v 1.117 2024/04/22 09:36:04 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -393,31 +393,28 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers)
case IMSG_CTL_NEIGHBOR_DOWN:
neighbor.reason[
sizeof(neighbor.reason) - 1] = '\0';
strlcpy(p->conf.reason,
neighbor.reason,
sizeof(p->conf.reason));
p->conf.down = 1;
session_stop(p, ERR_CEASE_ADMIN_DOWN);
session_stop(p, ERR_CEASE_ADMIN_DOWN,
neighbor.reason);
control_result(c, CTL_RES_OK);
break;
case IMSG_CTL_NEIGHBOR_CLEAR:
neighbor.reason[
sizeof(neighbor.reason) - 1] = '\0';
strlcpy(p->conf.reason,
neighbor.reason,
sizeof(p->conf.reason));
p->IdleHoldTime =
INTERVAL_IDLE_HOLD_INITIAL;
p->errcnt = 0;
if (!p->conf.down) {
session_stop(p,
ERR_CEASE_ADMIN_RESET);
ERR_CEASE_ADMIN_RESET,
neighbor.reason);
timer_set(&p->timers,
Timer_IdleHold,
SESSION_CLEAR_DELAY);
} else {
session_stop(p,
ERR_CEASE_ADMIN_DOWN);
ERR_CEASE_ADMIN_DOWN,
neighbor.reason);
}
control_result(c, CTL_RES_OK);
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: session.c,v 1.470 2024/04/11 08:33:15 claudio Exp $ */
/* $OpenBSD: session.c,v 1.473 2024/04/22 09:43:11 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@ -87,7 +87,7 @@ int parse_header(struct peer *, u_char *, uint16_t *, uint8_t *);
int parse_open(struct peer *);
int parse_update(struct peer *);
int parse_rrefresh(struct peer *);
int parse_notification(struct peer *);
void parse_notification(struct peer *);
int parse_capabilities(struct peer *, u_char *, uint16_t, uint32_t *);
int capa_neg_calc(struct peer *);
void session_dispatch_imsg(struct imsgbuf *, int, u_int *);
@ -266,11 +266,12 @@ session_main(int debug, int verbose)
if (p->demoted)
session_demote(p, -1);
p->conf.demote_group[0] = 0;
session_stop(p, ERR_CEASE_PEER_UNCONF);
session_stop(p, ERR_CEASE_PEER_UNCONF,
NULL);
timer_remove_all(&p->timers);
tcp_md5_del_listener(conf, p);
log_peer_warnx(&p->conf, "removed");
RB_REMOVE(peer_head, &conf->peers, p);
log_peer_warnx(&p->conf, "removed");
free(p);
peer_cnt--;
continue;
@ -513,12 +514,10 @@ session_main(int debug, int verbose)
}
RB_FOREACH_SAFE(p, peer_head, &conf->peers, next) {
RB_REMOVE(peer_head, &conf->peers, p);
strlcpy(p->conf.reason,
"bgpd shutting down",
sizeof(p->conf.reason));
session_stop(p, ERR_CEASE_ADMIN_DOWN);
session_stop(p, ERR_CEASE_ADMIN_DOWN, "bgpd shutting down");
timer_remove_all(&p->timers);
tcp_md5_del_listener(conf, p);
RB_REMOVE(peer_head, &conf->peers, p);
free(p);
}
@ -624,6 +623,9 @@ bgp_fsm(struct peer *peer, enum session_events event)
}
peer->passive = 0;
break;
case EVNT_STOP:
timer_stop(&peer->timers, Timer_IdleHold);
break;
default:
/* ignore */
break;
@ -723,13 +725,7 @@ bgp_fsm(struct peer *peer, enum session_events event)
change_state(peer, STATE_OPENCONFIRM, event);
break;
case EVNT_RCVD_NOTIFICATION:
if (parse_notification(peer)) {
change_state(peer, STATE_IDLE, event);
/* don't punish, capa negotiation */
timer_set(&peer->timers, Timer_IdleHold, 0);
peer->IdleHoldTime /= 2;
} else
change_state(peer, STATE_IDLE, event);
parse_notification(peer);
break;
default:
session_notification(peer,
@ -769,7 +765,6 @@ bgp_fsm(struct peer *peer, enum session_events event)
break;
case EVNT_RCVD_NOTIFICATION:
parse_notification(peer);
change_state(peer, STATE_IDLE, event);
break;
default:
session_notification(peer,
@ -815,7 +810,6 @@ bgp_fsm(struct peer *peer, enum session_events event)
break;
case EVNT_RCVD_NOTIFICATION:
parse_notification(peer);
change_state(peer, STATE_IDLE, event);
break;
default:
session_notification(peer,
@ -2326,9 +2320,6 @@ bad_len:
session_notification(peer, ERR_OPEN, ERR_OPEN_OPT,
NULL);
change_state(peer, STATE_IDLE, EVNT_RCVD_OPEN);
/* no punish */
timer_set(&peer->timers, Timer_IdleHold, 0);
peer->IdleHoldTime /= 2;
return (-1);
}
}
@ -2493,7 +2484,7 @@ parse_rrefresh(struct peer *peer)
return (0);
}
int
void
parse_notification(struct peer *peer)
{
struct ibuf ibuf;
@ -2518,7 +2509,7 @@ parse_notification(struct peer *peer)
if (ibuf_get_n8(&ibuf, &errcode) == -1 ||
ibuf_get_n8(&ibuf, &subcode) == -1) {
log_peer_warnx(&peer->conf, "received bad notification");
return (-1);
goto done;
}
peer->errcnt++;
@ -2541,12 +2532,8 @@ parse_notification(struct peer *peer)
}
}
if (errcode == ERR_OPEN && subcode == ERR_OPEN_OPT) {
session_capa_ann_none(peer);
return (1);
}
return (0);
done:
change_state(peer, STATE_IDLE, EVNT_RCVD_NOTIFICATION);
}
int
@ -3165,7 +3152,8 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
} else if (!depend_ok && p->depend_ok) {
p->depend_ok = depend_ok;
session_stop(p,
ERR_CEASE_OTHER_CHANGE);
ERR_CEASE_OTHER_CHANGE,
NULL);
}
}
break;
@ -3631,21 +3619,21 @@ session_demote(struct peer *p, int level)
}
void
session_stop(struct peer *peer, uint8_t subcode)
session_stop(struct peer *peer, uint8_t subcode, const char *reason)
{
struct ibuf *ibuf;
char *communication;
communication = peer->conf.reason;
if (reason != NULL)
strlcpy(peer->conf.reason, reason, sizeof(peer->conf.reason));
ibuf = ibuf_dynamic(0, REASON_LEN);
if ((subcode == ERR_CEASE_ADMIN_DOWN ||
subcode == ERR_CEASE_ADMIN_RESET) &&
communication != NULL && *communication != '\0' &&
reason != NULL && *reason != '\0' &&
ibuf != NULL) {
if (ibuf_add_n8(ibuf, strlen(communication)) == -1 ||
ibuf_add(ibuf, communication, strlen(communication))) {
if (ibuf_add_n8(ibuf, strlen(reason)) == -1 ||
ibuf_add(ibuf, reason, strlen(reason))) {
log_peer_warnx(&peer->conf,
"trying to send overly long shutdown reason");
ibuf_free(ibuf);
@ -3660,6 +3648,13 @@ session_stop(struct peer *peer, uint8_t subcode)
break;
default:
/* session not open, no need to send notification */
if (subcode >= sizeof(suberr_cease_names) / sizeof(char *) ||
suberr_cease_names[subcode] == NULL)
log_peer_warnx(&peer->conf, "session stop: %s, "
"unknown subcode %u", errnames[ERR_CEASE], subcode);
else
log_peer_warnx(&peer->conf, "session stop: %s, %s",
errnames[ERR_CEASE], suberr_cease_names[subcode]);
break;
}
ibuf_free(ibuf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: session.h,v 1.168 2024/03/22 07:19:28 claudio Exp $ */
/* $OpenBSD: session.h,v 1.169 2024/04/22 09:36:04 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -331,7 +331,7 @@ int peer_matched(struct peer *, struct ctl_neighbor *);
int imsg_ctl_parent(struct imsg *);
int imsg_ctl_rde(struct imsg *);
int imsg_ctl_rde_msg(int, uint32_t, pid_t);
void session_stop(struct peer *, uint8_t);
void session_stop(struct peer *, uint8_t, const char *);
/* timer.c */
struct timer *timer_get(struct timer_head *, enum Timer);