[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <672ce819549a5_1f2676294c7@willemb.c.googlers.com.notmuch>
Date: Thu, 07 Nov 2024 11:17:29 -0500
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Anna Emese Nyiri <annaemesenyiri@...il.com>,
netdev@...r.kernel.org
Cc: fejes@....elte.hu,
annaemesenyiri@...il.com,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
willemdebruijn.kernel@...il.com
Subject: Re: [PATCH net-next v3 2/3] net: support SO_PRIORITY cmsg
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 pacth, if SO_PRIORITY is specified as ancillary data,
typo: patch
> 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.
> Suggested-by: Ferenc Fejes <fejes@....elte.hu>
> Signed-off-by: Anna Emese Nyiri <annaemesenyiri@...il.com>
Reviewed-by: Willem de Bruijn <willemb@...gle.com>
> diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
> index cf377377b52d..f6a03b418dde 100644
> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> index 0e9e01967ec9..4304a68d1db0 100644
> --- a/net/ipv4/raw.c
> +++ b/net/ipv4/raw.c
> @@ -358,7 +358,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
> skb_reserve(skb, hlen);
>
> skb->protocol = htons(ETH_P_IP);
> - skb->priority = READ_ONCE(sk->sk_priority);
> + skb->priority = sockc->priority;
This has the side effect that raw_send_hdrinc will now interpret cmsg
IP_TOS, where it previously did not (as only sockcm_cookie was passed,
not all of ipcm_cookie). This is an improvement, but good to make
explicit.
Powered by blists - more mailing lists