Clear the last_sent_errcode, last_rcvd_errcode and last_reason when
authorclaudio <claudio@openbsd.org>
Thu, 11 Jan 2024 14:11:03 +0000 (14:11 +0000)
committerclaudio <claudio@openbsd.org>
Thu, 11 Jan 2024 14:11:03 +0000 (14:11 +0000)
the session comes up instead of at the start of a connect.
With this the last errors reported should stick around longer.
Reported by linx.net, OK job@

usr.sbin/bgpd/session.c

index 8e77c4f..c36fae4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: session.c,v 1.457 2024/01/10 11:08:04 claudio Exp $ */
+/*     $OpenBSD: session.c,v 1.458 2024/01/11 14:11:03 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -608,11 +608,6 @@ bgp_fsm(struct peer *peer, enum session_events event)
                        /* init write buffer */
                        msgbuf_init(&peer->wbuf);
 
-                       peer->stats.last_sent_errcode = 0;
-                       peer->stats.last_sent_suberr = 0;
-                       peer->stats.last_rcvd_errcode = 0;
-                       peer->stats.last_rcvd_suberr = 0;
-
                        if (!peer->depend_ok)
                                timer_stop(&peer->timers, Timer_ConnectRetry);
                        else if (peer->passive || peer->conf.passive ||
@@ -3553,6 +3548,13 @@ session_up(struct peer *p)
 {
        struct session_up        sup;
 
+       /* clear last errors, now that the session is up */
+       p->stats.last_sent_errcode = 0;
+       p->stats.last_sent_suberr = 0;
+       p->stats.last_rcvd_errcode = 0;
+       p->stats.last_rcvd_suberr = 0;
+       memset(p->stats.last_reason, 0, sizeof(p->stats.last_reason));
+
        if (imsg_rde(IMSG_SESSION_ADD, p->conf.id,
            &p->conf, sizeof(p->conf)) == -1)
                fatalx("imsg_compose error");