From: Quentin Young Date: Fri, 3 Nov 2017 18:47:56 +0000 (-0400) Subject: bgpd: transfer raw input buffer to new peer X-Git-Tag: frr-4.0-dev~120^2~12 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=7db44ec8fa9e2cf32007473a7cb2683b01d31692;p=matthieu%2Ffrr.git bgpd: transfer raw input buffer to new peer During initial session establishment, bgpd performs a "connection transfer" to a new peer struct if the connection was initiated passively (i.e. by the remote peer). With the addition of buffered input, I forgot to transfer the raw input buffer to the new peer. This resulted in infrequent failures during session handshaking whereby half of a packet would be thrown away in the middle of a read causing us to send a NOTIFY for an unsynchronized header. Usually the transfer coincided with a clean input buffer, hence why it only showed up once in a while. --- diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index f7c031610d..b97bebd7bb 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -181,6 +181,8 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) while (from_peer->ibuf->head) stream_fifo_push(peer->ibuf, stream_fifo_pop(from_peer->ibuf)); + + stream_copy(peer->ibuf_work, from_peer->ibuf_work); } pthread_mutex_unlock(&from_peer->io_mtx); pthread_mutex_unlock(&peer->io_mtx); diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 8ce6276c03..80e7f13dab 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -155,7 +155,6 @@ void bgp_reads_on(struct peer *peer) assert(peer->ibuf); assert(peer->fd); assert(peer->ibuf_work); - assert(stream_get_endp(peer->ibuf_work) == 0); assert(peer->obuf); assert(!peer->t_connect_check_r); assert(!peer->t_connect_check_w);