Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Anna Emese Nyiri <annaemesenyiri@gmail.com>,  netdev@vger.kernel.org
Cc: fejes@inf.elte.hu,  annaemesenyiri@gmail.com,
	 edumazet@google.com,  kuba@kernel.org,  pabeni@redhat.com,
	 willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH net-next v3 2/3] net: support SO_PRIORITY cmsg
Date: Thu, 07 Nov 2024 11:17:29 -0500	[thread overview]
Message-ID: <672ce819549a5_1f2676294c7@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <20241107132231.9271-3-annaemesenyiri@gmail.com>

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@inf.elte.hu>
> Signed-off-by: Anna Emese Nyiri <annaemesenyiri@gmail.com>

Reviewed-by: Willem de Bruijn <willemb@google.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.

  parent reply	other threads:[~2024-11-07 16:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 13:22 [PATCH net-next v3 0/3] SO_PRIORITY cmsg patch summary Anna Emese Nyiri
2024-11-07 13:22 ` [PATCH net-next v3 1/3] net: Introduce sk_set_prio_allowed helper function Anna Emese Nyiri
2024-11-07 13:48   ` Eric Dumazet
2024-11-07 15:55   ` Willem de Bruijn
2024-11-07 13:22 ` [PATCH net-next v3 2/3] net: support SO_PRIORITY cmsg Anna Emese Nyiri
2024-11-07 13:50   ` Eric Dumazet
2024-11-07 16:17   ` Willem de Bruijn [this message]
2024-11-07 13:22 ` [PATCH net-next v3 3/3] selftest: net: test SO_PRIORITY ancillary data with cmsg_sender Anna Emese Nyiri
2024-11-07 17:22   ` Willem de Bruijn
2024-11-08 14:46     ` Willem de Bruijn
2024-11-09 18:54       ` Ferenc Fejes
2024-11-09 19:56         ` Willem de Bruijn
2024-11-10 13:27           ` Ido Schimmel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=672ce819549a5_1f2676294c7@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=annaemesenyiri@gmail.com \
    --cc=edumazet@google.com \
    --cc=fejes@inf.elte.hu \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox