summaryrefslogtreecommitdiffstats
path: root/net/can
diff options
context:
space:
mode:
authorAnna Emese Nyiri <annaemesenyiri@gmail.com>2024-12-13 09:44:55 +0100
committerJakub Kicinski <kuba@kernel.org>2024-12-16 18:13:44 -0800
commita32f3e9d1ed146f81162702605d65447a319eb76 (patch)
tree41695029151b8a24d213c707ff399b30942a3e44 /net/can
parent77ec16be758ea65de641833149963bec39f311da (diff)
downloadlinux-a32f3e9d1ed146f81162702605d65447a319eb76.tar.gz
linux-a32f3e9d1ed146f81162702605d65447a319eb76.tar.bz2
linux-a32f3e9d1ed146f81162702605d65447a319eb76.zip
sock: support SO_PRIORITY cmsg
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 f02db315b8d8 ("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. Reviewed-by: Willem de Bruijn <willemb@google.com> Suggested-by: Ferenc Fejes <fejes@inf.elte.hu> Signed-off-by: Anna Emese Nyiri <annaemesenyiri@gmail.com> Link: https://patch.msgid.link/20241213084457.45120-3-annaemesenyiri@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/can')
-rw-r--r--net/can/raw.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/can/raw.c b/net/can/raw.c
index 255c0a8f39d6..46e8ed9d64da 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -962,7 +962,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
}
skb->dev = dev;
- skb->priority = READ_ONCE(sk->sk_priority);
+ skb->priority = sockc.priority;
skb->mark = READ_ONCE(sk->sk_mark);
skb->tstamp = sockc.transmit_time;