RTE OSAdapter POSIX 0.1.0 build 41b3eb3
POSIX/Linux OAL OSAdapter for Platform_RTE
Loading...
Searching...
No Matches
rte_posix_osadapter_sockbuf.h File Reference

Private helper: applies the socket buffer sizes of a link config (OSA rules R5, R6). More...

#include "rte/oal/netlink/rte_netlink.h"
#include "rte/utils/status/rte_status.h"
Include dependency graph for rte_posix_osadapter_sockbuf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

rte_status_t posix_socket_apply_buffers (int fd, const rte_netlink_config_t *config)
 Sets and confirms config->rcvbuf_bytes (SO_RCVBUF) and config->sndbuf_bytes (SO_SNDBUF) on a socket.

Detailed Description

Private helper: applies the socket buffer sizes of a link config (OSA rules R5, R6).

One implementation of Platform_RTE REQ-OAL-NETLINK-015 shared by the netlink OSAdapter (at open) and the channel service OSAdapter (at every socket (re)init). Not installed: an internal header of this product, like rte_posix_osadapter_poll.h.

Definition in file rte_posix_osadapter_sockbuf.h.

Function Documentation

◆ posix_socket_apply_buffers()

rte_status_t posix_socket_apply_buffers ( int fd,
const rte_netlink_config_t * config )

Sets and confirms config->rcvbuf_bytes (SO_RCVBUF) and config->sndbuf_bytes (SO_SNDBUF) on a socket.

A field of 0 keeps the OS default: no setsockopt() and no getsockopt() call for it, so a config with both fields 0 makes no system call at all. For each non-zero field: setsockopt(SOL_SOCKET) with the value capped at INT_MAX (setsockopt takes an int), return code checked, then getsockopt() of the same option, return code and length checked. The read-back is compared with what the kernel reports for an accepted request: twice the value on Linux (the kernel doubles it for bookkeeping and caps the request at net.core.rmem_max / wmem_max without an error), the value itself on other hosts. A read-back below that is reported once per call (DEGRADED / RTE_SAFESTATE_REASON_OSA_RT_ATTRIBUTE, "socket buffer size capped") and the socket is kept. SO_RCVBUF is applied before SO_SNDBUF; the first failure ends the call. The caller owns the socket and closes it on a failure.

Parameters
fdOpen socket descriptor.
configLink configuration; only rcvbuf_bytes and sndbuf_bytes are read. Must not be NULL.
Returns
RTE_STATUS_OK when every non-zero size is set and read back (also when one was capped and reported); RTE_STATUS_INVALID_PARAM for a NULL config; RTE_STATUS_INTERNAL_ERROR when setsockopt() refuses a size or getsockopt() fails or returns an unexpected length. REQ-OAL-NETLINK-015

Global functions

Definition at line 75 of file rte_posix_osadapter_sockbuf.c.