* [PATCH net-next] ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion.
@ 2025-01-15 12:44 Guillaume Nault
2025-01-15 16:40 ` Ido Schimmel
2025-01-17 1:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Guillaume Nault @ 2025-01-15 12:44 UTC (permalink / raw)
To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, Simon Horman, David Ahern, Ido Schimmel
Store rtm->rtm_tos in a dscp_t variable, which can then be used for
setting fl4.flowi4_tos and also be passed as parameter of
ip_route_input_rcu().
The .flowi4_tos field is going to be converted to dscp_t to ensure ECN
bits aren't erroneously taken into account during route lookups. Having
a dscp_t variable available will simplify that conversion, as we'll
just have to drop the inet_dscp_to_dsfield() call.
Note that we can't just convert rtm->rtm_tos to dscp_t because this
structure is exported to user space.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
net/ipv4/route.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9f9d4e6ea1b9..1f7e2a02dd25 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3269,6 +3269,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
struct flowi4 fl4 = {};
__be32 dst = 0;
__be32 src = 0;
+ dscp_t dscp;
kuid_t uid;
u32 iif;
int err;
@@ -3283,6 +3284,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
dst = nla_get_in_addr_default(tb[RTA_DST], 0);
iif = nla_get_u32_default(tb[RTA_IIF], 0);
mark = nla_get_u32_default(tb[RTA_MARK], 0);
+ dscp = inet_dsfield_to_dscp(rtm->rtm_tos);
if (tb[RTA_UID])
uid = make_kuid(current_user_ns(), nla_get_u32(tb[RTA_UID]));
else
@@ -3307,7 +3309,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
fl4.daddr = dst;
fl4.saddr = src;
- fl4.flowi4_tos = rtm->rtm_tos & INET_DSCP_MASK;
+ fl4.flowi4_tos = inet_dscp_to_dsfield(dscp);
fl4.flowi4_oif = nla_get_u32_default(tb[RTA_OIF], 0);
fl4.flowi4_mark = mark;
fl4.flowi4_uid = uid;
@@ -3331,9 +3333,8 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
fl4.flowi4_iif = iif; /* for rt_fill_info */
skb->dev = dev;
skb->mark = mark;
- err = ip_route_input_rcu(skb, dst, src,
- inet_dsfield_to_dscp(rtm->rtm_tos),
- dev, &res) ? -EINVAL : 0;
+ err = ip_route_input_rcu(skb, dst, src, dscp, dev,
+ &res) ? -EINVAL : 0;
rt = skb_rtable(skb);
if (err == 0 && rt->dst.error)
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion.
2025-01-15 12:44 [PATCH net-next] ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion Guillaume Nault
@ 2025-01-15 16:40 ` Ido Schimmel
2025-01-17 1:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2025-01-15 16:40 UTC (permalink / raw)
To: Guillaume Nault
Cc: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet, netdev,
Simon Horman, David Ahern
On Wed, Jan 15, 2025 at 01:44:52PM +0100, Guillaume Nault wrote:
> Store rtm->rtm_tos in a dscp_t variable, which can then be used for
> setting fl4.flowi4_tos and also be passed as parameter of
> ip_route_input_rcu().
>
> The .flowi4_tos field is going to be converted to dscp_t to ensure ECN
> bits aren't erroneously taken into account during route lookups. Having
> a dscp_t variable available will simplify that conversion, as we'll
> just have to drop the inet_dscp_to_dsfield() call.
>
> Note that we can't just convert rtm->rtm_tos to dscp_t because this
> structure is exported to user space.
>
> Signed-off-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion.
2025-01-15 12:44 [PATCH net-next] ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion Guillaume Nault
2025-01-15 16:40 ` Ido Schimmel
@ 2025-01-17 1:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-17 1:20 UTC (permalink / raw)
To: Guillaume Nault
Cc: davem, kuba, pabeni, edumazet, netdev, horms, dsahern, idosch
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 15 Jan 2025 13:44:52 +0100 you wrote:
> Store rtm->rtm_tos in a dscp_t variable, which can then be used for
> setting fl4.flowi4_tos and also be passed as parameter of
> ip_route_input_rcu().
>
> The .flowi4_tos field is going to be converted to dscp_t to ensure ECN
> bits aren't erroneously taken into account during route lookups. Having
> a dscp_t variable available will simplify that conversion, as we'll
> just have to drop the inet_dscp_to_dsfield() call.
>
> [...]
Here is the summary with links:
- [net-next] ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion.
https://git.kernel.org/netdev/net-next/c/65a55aa7e64e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-17 1:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-15 12:44 [PATCH net-next] ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion Guillaume Nault
2025-01-15 16:40 ` Ido Schimmel
2025-01-17 1:20 ` patchwork-bot+netdevbpf
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).