#15864·Redis

Failure to apply socket-mark-id to TCP listener is not reported

Author: QiaoyiZhengCreated Sep 24, 2026Updated Sep 24, 2026

Describe the bug

If socket-mark-id is set to a nonzero value but applying SO_MARK to a TCP listening socket fails, Redis starts and accepts connections without reporting that the requested mark was not applied. This can leave an operator believing that routing or filtering based on the configured mark is active when it is not.

To reproduce

On Linux, run Redis in an environment where setsockopt(SOL_SOCKET, SO_MARK, ...) returns EPERM (for example, a container without the required capability):

bash
redis-server --bind 127.0.0.1 --port 6389 --socket-mark-id 1337 --save '' --appendonly no

In a separate terminal, run redis-cli -p 6389 PING and inspect the startup log. The server starts and responds PONG, but there is no warning about the socket mark. In a reproduced run, CONFIG GET socket-mark-id returned 1337 while the TCP listening socket's actual SO_MARK was 0. A preflight setsockopt(SO_MARK) call failed with EPERM. The log contained unrelated startup warnings, but none for this failure.

Expected behavior

When an explicitly requested socket mark cannot be applied, Redis should at least report the failure to the operator. This does not necessarily require aborting startup.

Additional information

Observed with a Redis 8.10.1 development snapshot (e342d9c6). In listenToPort() in src/server.c, the call to anetSetSockMarkId(NULL, ...) ignores the return value. anetSetSockMarkId() in src/anet.c returns ANET_ERR when setsockopt() fails, but the null error buffer and ignored result leave the failure unreported. This report concerns failure to apply the mark after a successful bind, not a failure to bind the listening port.