netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<edumazet@google.com>, <gnault@redhat.com>, <dsahern@kernel.org>,
	<ast@kernel.org>, <daniel@iogearbox.net>, <martin.lau@linux.dev>,
	<john.fastabend@gmail.com>, <steffen.klassert@secunet.com>,
	<herbert@gondor.apana.org.au>, <bpf@vger.kernel.org>,
	Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next v2 05/12] ipv4: Unmask upper DSCP bits in get_rttos()
Date: Thu, 29 Aug 2024 09:54:52 +0300	[thread overview]
Message-ID: <20240829065459.2273106-6-idosch@nvidia.com> (raw)
In-Reply-To: <20240829065459.2273106-1-idosch@nvidia.com>

The function is used by a few socket types to retrieve the TOS value
with which to perform the FIB lookup for packets sent through the socket
(flowi4_tos). If a DS field was passed using the IP_TOS control message,
then it is used. Otherwise the one specified via the IP_TOS socket
option.

Unmask the upper DSCP bits so that in the future the lookup could be
performed according to the full DSCP value.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
---
 include/net/ip.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/net/ip.h b/include/net/ip.h
index c5606cadb1a5..2b43f04c7d03 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -33,6 +33,7 @@
 #include <net/flow_dissector.h>
 #include <net/netns/hash.h>
 #include <net/lwtunnel.h>
+#include <net/inet_dscp.h>
 
 #define IPV4_MAX_PMTU		65535U		/* RFC 2675, Section 5.1 */
 #define IPV4_MIN_MTU		68			/* RFC 791 */
@@ -258,7 +259,9 @@ static inline u8 ip_sendmsg_scope(const struct inet_sock *inet,
 
 static inline __u8 get_rttos(struct ipcm_cookie* ipc, struct inet_sock *inet)
 {
-	return (ipc->tos != -1) ? RT_TOS(ipc->tos) : RT_TOS(READ_ONCE(inet->tos));
+	u8 dsfield = ipc->tos != -1 ? ipc->tos : READ_ONCE(inet->tos);
+
+	return dsfield & INET_DSCP_MASK;
 }
 
 /* datagram.c */
-- 
2.46.0


  parent reply	other threads:[~2024-08-29  6:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-29  6:54 [PATCH net-next v2 00/12] Unmask upper DSCP bits - part 2 Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 01/12] ipv4: Unmask upper DSCP bits in RTM_GETROUTE output route lookup Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 02/12] ipv4: Unmask upper DSCP bits in ip_route_output_key_hash() Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 03/12] ipv4: icmp: Unmask upper DSCP bits in icmp_route_lookup() Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 04/12] ipv4: Unmask upper DSCP bits in ip_sock_rt_tos() Ido Schimmel
2024-08-29  6:54 ` Ido Schimmel [this message]
2024-08-29  6:54 ` [PATCH net-next v2 06/12] ipv4: Unmask upper DSCP bits when building flow key Ido Schimmel
2024-08-29 10:47   ` Guillaume Nault
2024-08-29  6:54 ` [PATCH net-next v2 07/12] xfrm: Unmask upper DSCP bits in xfrm_get_tos() Ido Schimmel
2024-08-29 10:52   ` Guillaume Nault
2024-08-29  6:54 ` [PATCH net-next v2 08/12] ipv4: Unmask upper DSCP bits in ip_send_unicast_reply() Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 09/12] ipv6: sit: Unmask upper DSCP bits in ipip6_tunnel_xmit() Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 10/12] ipvlan: Unmask upper DSCP bits in ipvlan_process_v4_outbound() Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 11/12] vrf: Unmask upper DSCP bits in vrf_process_v4_outbound() Ido Schimmel
2024-08-29  6:54 ` [PATCH net-next v2 12/12] bpf: Unmask upper DSCP bits in __bpf_redirect_neigh_v4() Ido Schimmel
2024-08-29 11:02   ` Guillaume Nault
2024-08-30  1:55 ` [PATCH net-next v2 00/12] Unmask upper DSCP bits - part 2 David Ahern
2024-08-31 16:50 ` patchwork-bot+netdevbpf

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=20240829065459.2273106-6-idosch@nvidia.com \
    --to=idosch@nvidia.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gnault@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steffen.klassert@secunet.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;
as well as URLs for NNTP newsgroup(s).