]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: transfer raw input buffer to new peer
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 3 Nov 2017 18:47:56 +0000 (14:47 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 21:18:05 +0000 (16:18 -0500)
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.

bgpd/bgp_fsm.c
bgpd/bgp_io.c

index f7c031610d0fcbaf1af50ff47b5906f9557361ef..b97bebd7bb22407f13de2966e55f4f30351a1469 100644 (file)
@@ -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);
index 8ce6276c033fd96476fd46dd4c62ce2890ce1855..80e7f13dab4676c3363ad9c6c79dd27a7158a5ab 100644 (file)
@@ -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);