vcl: fix ldp getsockopt tcp_info length check

netinet/tcp.h and linux/tcp.h have different lenghts but overlap. LDP
uses the former while iperf the latter. Accept both lengths for now as
we do not support exposing tcp metrics via ldp.

Type: improvement

Change-Id: I13a149d68715ed9451773630a3595c09c421aa29
Signed-off-by: Florin Coras <fcoras@cisco.com>
This commit is contained in:
Florin Coras 2024-12-07 17:28:46 -05:00 committed by Dave Barach
parent 4e271dda7b
commit 4c1f178063

View File

@ -2020,10 +2020,14 @@ getsockopt (int fd, int level, int optname,
optval, optlen);
break;
case TCP_INFO:
if (optval && optlen && (*optlen == sizeof (struct tcp_info)))
/* Note: tcp_info in netinet/tcp.h and linux/tcp.h have
* different lenghts but overlap. Accept both for now */
if (optval && optlen)
{
LDBG (1, "fd %d: vlsh %u SOL_TCP, TCP_INFO, optval %p, "
"optlen %d: #LDP-NOP#", fd, vlsh, optval, *optlen);
LDBG (1,
"fd %d: vlsh %u SOL_TCP, TCP_INFO, optval %p, "
"optlen %d: #LDP-NOP#",
fd, vlsh, optval, *optlen);
memset (optval, 0, *optlen);
rv = VPPCOM_OK;
}