summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2019-06-28 09:14:36 +0000
committerclaudio <claudio@openbsd.org>2019-06-28 09:14:36 +0000
commitfde294fc124eaeacce70d5b5f5a8812f1f1c7787 (patch)
treef9452ad4e13adc20515d5a540a73780d36a7815a
parentswitch timestamps to use timevals in filters like we do in reporting (diff)
downloadwireguard-openbsd-fde294fc124eaeacce70d5b5f5a8812f1f1c7787.tar.xz
wireguard-openbsd-fde294fc124eaeacce70d5b5f5a8812f1f1c7787.zip
Reset rpending (read pending) indicator for a peer when the peer goes down
and the read buffer is cleared. Also make sure that the poll timeout is only reduced to 0 if rpending is set and the read buffer has data to process. This should fix a problem within the SE causing it to spin with a poll timeout of 0. OK phessler@
-rw-r--r--usr.sbin/bgpd/session.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 2afaf60adac..dd552c9c826 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.386 2019/06/22 05:36:40 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.387 2019/06/28 09:14:36 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -422,7 +422,7 @@ session_main(int debug, int verbose)
if (p->wbuf.queued > 0 || p->state == STATE_CONNECT)
events |= POLLOUT;
/* is there still work to do? */
- if (p->rpending)
+ if (p->rpending && p->rbuf && p->rbuf->wpos)
timeout = 0;
/* poll events */
@@ -888,6 +888,7 @@ change_state(struct peer *peer, enum session_state state,
msgbuf_clear(&peer->wbuf);
free(peer->rbuf);
peer->rbuf = NULL;
+ peer->rpending = 0;
bzero(&peer->capa.peer, sizeof(peer->capa.peer));
if (!peer->template)
imsg_compose(ibuf_main, IMSG_PFKEY_RELOAD,
@@ -2959,6 +2960,7 @@ getpeerbyip(struct bgpd_config *c, struct sockaddr *ip)
newpeer->state = newpeer->prev_state = STATE_NONE;
newpeer->reconf_action = RECONF_KEEP;
newpeer->rbuf = NULL;
+ newpeer->rpending = 0;
init_peer(newpeer);
bgp_fsm(newpeer, EVNT_START);
if (RB_INSERT(peer_head, &c->peers, newpeer) != NULL)