From: claudio Date: Wed, 10 Apr 2024 09:05:32 +0000 (+0000) Subject: Rework the logic to not send double notifications in session_notification(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8768446ca08b6a4eb24335c9c27b50cc7633d1ee;p=openbsd Rework the logic to not send double notifications in session_notification(). last_sent_errcode is now cleared late (when state changes to ESTABLISHED) and so notifications sent in the OPEN phase would be dropped after the first incident. Using the session state to know if sending a message is possible seems more robust and is what session_stop() uses as well. For now log the notification which are not sent as 'dropping' to see how often this happens. OK tb@ --- diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index dd99479c272..769fa2d9bb9 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.468 2024/04/09 09:03:18 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.469 2024/04/10 09:05:32 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -1720,8 +1720,16 @@ session_notification(struct peer *p, uint8_t errcode, uint8_t subcode, 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");