From 91e95112e831b7e47d6c359980b3b55f0a58519c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 24 Jul 2023 10:33:21 -0400 Subject: [PATCH] bgpd: Reduce size of ibuf_work ringbuf The ringbuf is 650k in size. This is obscenely large and in practical experimentation FRR never even approaches that size at all. Let's reduce this to 1.5 max packet sizes. If a BGP_MAX_PACKET_SIZE packet is ever received having a bit of extra space ensures that we can read at least 1 packet. This also will significantly reduce memory usage when the operator has a lot of peers. Signed-off-by: Donald Sharp (cherry picked from commit fe1c72a57315a7c9fc3c63dd2fbf3a10dafbc10b) --- bgpd/bgpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 86bded14bb..c12cf03cec 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1414,7 +1414,7 @@ struct peer *peer_new(struct bgp *bgp) pthread_mutex_init(&peer->io_mtx, NULL); peer->ibuf_work = - ringbuf_new(BGP_MAX_PACKET_SIZE * BGP_READ_PACKET_MAX); + ringbuf_new(BGP_MAX_PACKET_SIZE + BGP_MAX_PACKET_SIZE/2); /* Get service port number. */ sp = getservbyname("bgp", "tcp"); -- 2.39.5