sync with OpenBSD -current

This commit is contained in:
purplerain 2024-03-23 00:52:05 +00:00
parent 5c4b291e07
commit b478f6b854
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
50 changed files with 466 additions and 438 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: logmsg.c,v 1.11 2024/01/16 13:15:31 claudio Exp $ */
/* $OpenBSD: logmsg.c,v 1.13 2024/03/22 15:41:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -133,12 +133,18 @@ log_statechange(struct peer *peer, enum session_state nstate,
void
log_notification(const struct peer *peer, uint8_t errcode, uint8_t subcode,
struct ibuf *data, const char *dir)
const struct ibuf *data, const char *dir)
{
struct ibuf ibuf;
char *p;
const char *suberrname = NULL;
int uk = 0;
if (data != NULL)
ibuf_from_ibuf(&ibuf, data);
else
ibuf_from_buffer(&ibuf, NULL, 0);
p = log_fmt_peer(&peer->conf);
switch (errcode) {
case ERR_HEADER:
@ -154,6 +160,18 @@ log_notification(const struct peer *peer, uint8_t errcode, uint8_t subcode,
uk = 1;
else
suberrname = suberr_open_names[subcode];
if (errcode == ERR_OPEN && subcode == ERR_OPEN_CAPA) {
uint8_t capa_code;
if (ibuf_get_n8(&ibuf, &capa_code) == -1)
break;
logit(LOG_ERR, "%s: %s notification: %s, %s: %s",
p, dir, errnames[errcode], suberrname,
log_capability(capa_code));
free(p);
return;
}
break;
case ERR_UPDATE:
if (subcode >= sizeof(suberr_update_names) / sizeof(char *) ||
@ -168,6 +186,24 @@ log_notification(const struct peer *peer, uint8_t errcode, uint8_t subcode,
uk = 1;
else
suberrname = suberr_cease_names[subcode];
if (subcode == ERR_CEASE_ADMIN_DOWN ||
subcode == ERR_CEASE_ADMIN_RESET) {
uint8_t len;
/* check if shutdown reason is included */
if (ibuf_get_n8(&ibuf, &len) != -1 && len != 0) {
char *s;
if ((s = ibuf_get_string(&ibuf, len)) != NULL) {
logit(LOG_ERR, "%s: %s notification: "
"%s, %s: reason \"%s\"", p, dir,
errnames[errcode], suberrname,
log_reason(s));
free(s);
free(p);
return;
}
}
}
break;
case ERR_HOLDTIMEREXPIRED:
if (subcode != 0)