netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guillaume Nault <gnault@redhat.com>
To: Ido Schimmel <idosch@nvidia.com>
Cc: David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, Simon Horman <horms@kernel.org>,
	Taehee Yoo <ap420073@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Edward Cree <ecree.xilinx@gmail.com>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Harald Welte <laforge@gnumonks.org>,
	David Ahern <dsahern@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Xin Long <lucien.xin@gmail.com>
Subject: Re: [PATCH net-next] ipv4: Convert ->flowi4_tos to dscp_t.
Date: Thu, 21 Aug 2025 16:06:57 +0200	[thread overview]
Message-ID: <aKcoAbPXff_IT7MN@debian> (raw)
In-Reply-To: <aKbDCJWjMpUEOtXe@shredder>

On Thu, Aug 21, 2025 at 09:56:08AM +0300, Ido Schimmel wrote:
> On Thu, Aug 21, 2025 at 01:32:03AM +0200, Guillaume Nault wrote:
> > Convert the ->flowic_tos field of struct flowi_common from __u8 to
> > dscp_t, rename it ->flowic_dscp and propagate these changes to struct
> > flowi and struct flowi4.
> > 
> > We've had several bugs in the past where ECN bits could interfere with
> > IPv4 routing, because these bits were not properly cleared when setting
> > ->flowi4_tos. These bugs should be fixed now and the dscp_t type has
> > been introduced to ensure that variables carrying DSCP values don't
> > accidentally have any ECN bits set. Several variables and structure
> > fields have been converted to dscp_t already, but the main IPv4 routing
> > structure, struct flowi4, is still using a __u8. To avoid any future
> > regression, this patch converts it to dscp_t.
> > 
> > There are many users to convert at once. Fortunately, around half of
> > ->flowi4_tos users already have a dscp_t value at hand, which they
> > currently convert to __u8 using inet_dscp_to_dsfield(). For all of
> > these users, we just need to drop that conversion.
> > 
> > But, although we try to do the __u8 <-> dscp_t conversions at the
> > boundaries of the network or of user space, some places still store
> > TOS/DSCP variables as __u8 in core networking code. Some structure
> > fields, like struct ip_tunnel_key::tos could be converted to dscp_t,
> > but that would require a lot of work, so this is left for later. Other
> > places can't be converted, for example because the data structure is
> > part of UAPI or because the same variable or field is also used for
> > handling ECN in other parts of the code. In all of these cases where we
> > don't have a dscp_t variable at hand, we need to use
> > inet_dsfield_to_dscp() when interacting with ->flowi4_dscp.
> > 
> > Signed-off-by: Guillaume Nault <gnault@redhat.com>
> 
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> 
> Thanks! One nit below
> 
> [...]
> 
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index da391e2b0788..c75f95c60af3 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -2373,7 +2373,7 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
> >  		struct flowi4 fl4 = {
> >  			.flowi4_flags = FLOWI_FLAG_ANYSRC,
> >  			.flowi4_mark  = skb->mark,
> > -			.flowi4_tos   = inet_dscp_to_dsfield(ip4h_dscp(ip4h)),
> > +			.flowi4_dscp   = ip4h_dscp(ip4h),
> 
> Nit: alignment is off

Thanks. I thought I had carefully reviewed my patch before posting...

By the way, do you have an opinion about converting struct
ip_tunnel_key::tos? Do you think it'd be worth it, or just code churn?

> >  			.flowi4_oif   = dev->ifindex,
> >  			.flowi4_proto = ip4h->protocol,
> >  			.daddr	      = ip4h->daddr,
> 


  reply	other threads:[~2025-08-21 14:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 23:32 [PATCH net-next] ipv4: Convert ->flowi4_tos to dscp_t Guillaume Nault
2025-08-21  6:56 ` Ido Schimmel
2025-08-21 14:06   ` Guillaume Nault [this message]
2025-08-24 10:15     ` Ido Schimmel
2025-08-25 11:29       ` Guillaume Nault

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=aKcoAbPXff_IT7MN@debian \
    --to=gnault@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=ap420073@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=ecree.xilinx@gmail.com \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=haoluo@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kadlec@netfilter.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=laforge@gnumonks.org \
    --cc=leon@kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=marcelo.leitner@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mbloch@nvidia.com \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=rostedt@goodmis.org \
    --cc=saeedm@nvidia.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=tariqt@nvidia.com \
    --cc=yonghong.song@linux.dev \
    /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).