From b10561bbecb2870360a731b4696bff920150720d Mon Sep 17 00:00:00 2001 From: Tom Jones Date: Wed, 7 Feb 2024 13:31:50 +0000 Subject: papi: Use CMSG_SPACE for sizing ancillary buffer space CMSG_LEN provides the length required to store an ancillary item, but it does not consider padding. RFC 3542 requires portable applications to use CMSG_SPACE(), this is documented in the python API: https://docs.python.org/3/library/socket.html#socket.CMSG_LEN Type: improvement Change-Id: I0eab470585f2f39bea38639db95d6b0e047d2cff Signed-off-by: Tom Jones --- src/vpp-api/python/vpp_papi/vpp_stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vpp-api/python/vpp_papi/vpp_stats.py b/src/vpp-api/python/vpp_papi/vpp_stats.py index 4a342b68a8f..8cbe737db92 100755 --- a/src/vpp-api/python/vpp_papi/vpp_stats.py +++ b/src/vpp-api/python/vpp_papi/vpp_stats.py @@ -54,7 +54,7 @@ import re def recv_fd(sock): """Get file descriptor for memory map""" fds = array.array("i") # Array of ints - _, ancdata, _, _ = sock.recvmsg(0, socket.CMSG_LEN(4)) + _, ancdata, _, _ = sock.recvmsg(0, socket.CMSG_SPACE(4)) for cmsg_level, cmsg_type, cmsg_data in ancdata: if cmsg_level == socket.SOL_SOCKET and cmsg_type == socket.SCM_RIGHTS: fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) -- cgit 1.2.3-korg