-/* $OpenBSD: rde.c,v 1.628 2024/08/28 13:18:11 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.629 2024/08/28 13:21:39 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
peerid);
break;
}
- peer_imsg_push(peer, &imsg);
+ if (peer_is_up(peer))
+ peer_imsg_push(peer, &imsg);
break;
case IMSG_SESSION_ADD:
if (imsg_get_data(&imsg, &pconf, sizeof(pconf)) == -1)
struct imsg imsg;
struct ibuf ibuf;
+ if (!peer_is_up(peer)) {
+ peer_imsg_flush(peer);
+ return;
+ }
+
if (!peer_imsg_pop(peer, &imsg))
return;
switch (imsg_get_type(&imsg)) {
case IMSG_UPDATE:
- if (peer->state != PEER_UP)
- break;
if (imsg_get_ibuf(&imsg, &ibuf) == -1)
log_warn("update: bad imsg");
else
RB_FOREACH(peer, peer_tree, &peertable) {
if (peer->conf.id == 0)
continue;
- if (peer->state != PEER_UP)
+ if (!peer_is_up(peer))
continue;
if (peer->throttled)
continue;
RB_FOREACH(peer, peer_tree, &peertable) {
if (peer->conf.id == 0)
continue;
- if (peer->state != PEER_UP)
+ if (!peer_is_up(peer))
continue;
if (peer->throttled)
continue;
RB_FOREACH(peer, peer_tree, &peertable) {
if (peer->conf.id == 0)
continue;
- if (peer->state != PEER_UP)
+ if (!peer_is_up(peer))
continue;
if (peer->throttled)
continue;
-/* $OpenBSD: rde.h,v 1.304 2024/08/14 19:09:51 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.305 2024/08/28 13:21:39 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
int peer_imsg_pending(void);
void peer_imsg_flush(struct rde_peer *);
+static inline int
+peer_is_up(struct rde_peer *peer)
+{
+ return (peer->state == PEER_UP);
+}
+
RB_PROTOTYPE(peer_tree, rde_peer, entry, peer_cmp);
/* rde_attr.c */
-/* $OpenBSD: rde_peer.c,v 1.37 2024/05/22 08:41:14 claudio Exp $ */
+/* $OpenBSD: rde_peer.c,v 1.38 2024/08/28 13:21:39 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
/* skip ourself */
if (peer == peerself)
return;
- if (peer->state != PEER_UP)
+ if (!peer_is_up(peer))
return;
/* skip peers using a different rib */
if (peer->loc_rib_id != re->rib_id)