From: Claudio Jeker Subject: bgpd: fix session_notification To: tech@openbsd.org Date: Tue, 9 Apr 2024 17:41:12 +0200 The early exit in session_notification no longer works since I moved the clearing of last_sent_errcode when the session goes into ESTABLISHED state. So if there is an error in the early phase of session establishment (e.g. capability negotiation) then this only works the first time. Instead of checking the last_sent_errcode look at the session state to know if it makes sense to issue a notification or not. I added a log_notification() in the early exit case just to know it happened. Maybe that should be removed (depending how often this early exit path is taken). -- :wq Claudio Index: session.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/session.c,v diff -u -p -r1.468 session.c --- session.c 9 Apr 2024 09:03:18 -0000 1.468 +++ session.c 9 Apr 2024 15:32:45 -0000 @@ -1720,8 +1720,16 @@ session_notification(struct peer *p, uin int errs = 0; size_t datalen = 0; - if (p->stats.last_sent_errcode) /* some notification already sent */ + switch (p->state) { + case STATE_OPENSENT: + case STATE_OPENCONFIRM: + case STATE_ESTABLISHED: + break; + default: + /* session not open, no need to send notification */ + log_notification(p, errcode, subcode, ibuf, "dropping"); return; + } log_notification(p, errcode, subcode, ibuf, "sending");