From 0c679ffcbe52d93eafbe5adbd218d67fa3732ff4 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Wed, 7 Feb 2024 23:03:37 +0200 Subject: [PATCH] bgpd: Do not show TCP MSS if the socket is broken Just avoid calling for TCP MSS socket option if it's not in use. Signed-off-by: Donatas Abraitis (cherry picked from commit 65497556eda9ce413e8c9f88479aa57957266265) --- lib/sockopt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/sockopt.c b/lib/sockopt.c index 41fcc41202ef..bce7ff4dd894 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -673,6 +673,9 @@ int sockopt_tcp_mss_get(int sock) int tcp_maxseg = 0; socklen_t tcp_maxseg_len = sizeof(tcp_maxseg); + if (sock < 0) + return 0; + ret = getsockopt(sock, IPPROTO_TCP, TCP_MAXSEG, &tcp_maxseg, &tcp_maxseg_len); if (ret != 0) {