]> git.proxmox.com Git - mirror_frr.git/commitdiff
Revert "bgpd: improve socket read performance"
authorQuentin Young <qlyoung@nvidia.com>
Mon, 26 Apr 2021 22:42:12 +0000 (18:42 -0400)
committerQuentin Young <qlyoung@nvidia.com>
Thu, 29 Apr 2021 16:12:32 +0000 (12:12 -0400)
This reverts commit 97a16e648115919aab3784a6511807e35c20ee20.

bgpd/bgp_io.c

index c2d8cae580d241b252e1524b1e01798a58370369..fec96700da9d0e79ba204bc155a1e183b7260c5f 100644 (file)
@@ -462,10 +462,13 @@ done : {
  */
 static uint16_t bgp_read(struct peer *peer, int *code_p)
 {
+       size_t readsize; // how many bytes we want to read
        ssize_t nbytes;  // how many bytes we actually read
        uint16_t status = 0;
+       uint8_t ibw[peer->max_packet_size * BGP_READ_PACKET_MAX];
 
-       nbytes = ringbuf_read(peer->ibuf_work, peer->fd);
+       readsize = MIN(ringbuf_space(peer->ibuf_work), sizeof(ibw));
+       nbytes = read(peer->fd, ibw, readsize);
 
        /* EAGAIN or EWOULDBLOCK; come back later */
        if (nbytes < 0 && ERRNO_IO_RETRY(errno)) {
@@ -493,6 +496,9 @@ static uint16_t bgp_read(struct peer *peer, int *code_p)
                        *code_p = TCP_connection_closed;
 
                SET_FLAG(status, BGP_IO_FATAL_ERR);
+       } else {
+               assert(ringbuf_put(peer->ibuf_work, ibw, nbytes)
+                      == (size_t)nbytes);
        }
 
        return status;