at the ibuf payload passed to log_notification().
Because of this move ibuf_get_string() and the log_notification() call
in parse_notification().
OK tb@
-/* $OpenBSD: bgpd.h,v 1.488 2024/03/22 07:19:28 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.489 2024/03/22 15:41:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
time_t getmonotime(void);
/* util.c */
+char *ibuf_get_string(struct ibuf *, size_t);
const char *log_addr(const struct bgpd_addr *);
const char *log_in6addr(const struct in6_addr *);
const char *log_sockaddr(struct sockaddr *, socklen_t);
-/* $OpenBSD: logmsg.c,v 1.12 2024/03/22 07:19:28 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>
if (subcode == ERR_CEASE_ADMIN_DOWN ||
subcode == ERR_CEASE_ADMIN_RESET) {
- if (peer->stats.last_reason[0] != '\0') {
- logit(LOG_ERR, "%s: %s notification: %s, %s: "
- "reason \"%s\"", p, dir,
- errnames[errcode], suberrname,
- log_reason(peer->stats.last_reason));
- free(p);
- return;
+ 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;
-/* $OpenBSD: rtr_proto.c,v 1.33 2024/01/23 15:59:56 claudio Exp $ */
+/* $OpenBSD: rtr_proto.c,v 1.34 2024/03/22 15:41:34 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
return -1;
}
-static char *
-ibuf_get_string(struct ibuf *buf, size_t len)
-{
- char *str;
-
- if (ibuf_size(buf) < len) {
- errno = EBADMSG;
- return (NULL);
- }
- str = strndup(ibuf_data(buf), len);
- if (str == NULL)
- return (NULL);
- ibuf_skip(buf, len);
- return (str);
-}
-
/*
* Parse an Error Response message. This function behaves a bit different
* from other parse functions since on error the connection needs to be
-/* $OpenBSD: session.c,v 1.465 2024/03/22 07:19:28 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.466 2024/03/22 15:41:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
peer->stats.last_rcvd_errcode = errcode;
peer->stats.last_rcvd_suberr = subcode;
+ log_notification(peer, errcode, subcode, &ibuf, "received");
+
CTASSERT(sizeof(peer->stats.last_reason) > UINT8_MAX);
memset(peer->stats.last_reason, 0, sizeof(peer->stats.last_reason));
if (errcode == ERR_CEASE &&
}
}
- log_notification(peer, errcode, subcode, &ibuf, "received");
-
if (errcode == ERR_OPEN && subcode == ERR_OPEN_OPT) {
session_capa_ann_none(peer);
return (1);
-/* $OpenBSD: util.c,v 1.84 2024/03/22 07:19:28 claudio Exp $ */
+/* $OpenBSD: util.c,v 1.85 2024/03/22 15:41:34 claudio Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
#include "rde.h"
#include "log.h"
+char *
+ibuf_get_string(struct ibuf *buf, size_t len)
+{
+ char *str;
+
+ if (ibuf_size(buf) < len) {
+ errno = EBADMSG;
+ return (NULL);
+ }
+ str = strndup(ibuf_data(buf), len);
+ if (str == NULL)
+ return (NULL);
+ ibuf_skip(buf, len);
+ return (str);
+}
+
const char *
log_addr(const struct bgpd_addr *addr)
{