Re: [PATCH net-next v4 2/3] sock: support SO_PRIORITY cmsg
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2024-11-18 20:20:10
Anna Emese Nyiri wrote:
The Linux socket API currently allows setting SO_PRIORITY at the
socket level, applying a uniform priority to all packets sent through
that socket. The exception to this is IP_TOS, when the priority value
is calculated during the handling of
ancillary data, as implemented in commit <f02db315b8d88>
("ipv4: IP_TOS and IP_TTL can be specified as ancillary data").
However, this is a computed
value, and there is currently no mechanism to set a custom priority
via control messages prior to this patch.
According to this patch, if SO_PRIORITY is specified as ancillary data,
the packet is sent with the priority value set through
sockc->priority, overriding the socket-level values
set via the traditional setsockopt() method. This is analogous to
the existing support for SO_MARK, as implemented in commit
<c6af0c227a22> ("ip: support SO_MARK cmsg").
If both cmsg SO_PRIORITY and IP_TOS are passed, then the one that
takes precedence is the last one in the cmsg list.
This patch has the side effect that raw_send_hdrinc now interprets cmsg
IP_TOS.
Suggested-by: Ferenc Fejes <redacted>
Signed-off-by: Anna Emese Nyiri <redacted>Reviewed-by: Willem de Bruijn <willemb@google.com> Good catch on ipv6 ping.