Skip to contentSkip to conversation

ipv4: Remove RT_CONN_FLAGS() calls in flowi4_init_output().

PATCH Applied Guillaume Nault 3 participants 6 messages Jun 5, 2023 – Jun 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ipv4: Remove RT_CONN_FLAGS() calls in flowi4_init_output().

Remove a few RT_CONN_FLAGS() calls used inside flowi4_init_output(). These users can be easily converted to set the scope properly, instead of overloading the tos parameter with scope information as done by RT_CONN_FLAGS().

The objective is to eventually remove RT_CONN_FLAGS() entirely, which will then allow to also remove RTO_ONLINK and to finally convert ->flowi4_tos to dscp_t.

Guillaume Nault (2):
ipv4: Set correct scope in inet_csk_route_*().
tcp: Set route scope properly in cookie_v4_check().

 net/ipv4/inet_connection_sock.c | 4 ++--
 net/ipv4/syncookies.c           | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/2 ipv4: Set correct scope in inet_csk_route_*().

RT_CONN_FLAGS(sk) overloads the tos parameter with the RTO_ONLINK bit when sk has the SOCK_LOCALROUTE flag set. This is only useful for ip_route_output_key_hash() to eventually adjust the route scope.

Let's drop RTO_ONLINK and set the correct scope directly to avoid this special case in the future and to allow converting ->flowi4_tos to dscp_t.

---
 net/ipv4/inet_connection_sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/inet_connection_sock.c +2 -2
index 1386787eaf1a..15424dec4584 100644
@@ -792,7 +792,7 @@ struct dst_entry *inet_csk_route_req(const struct sock *sk,
 	opt = rcu_dereference(ireq->ireq_opt);
 
 	flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
-			   RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
+			   ip_sock_rt_tos(sk), ip_sock_rt_scope(sk),
 			   sk->sk_protocol, inet_sk_flowi_flags(sk),
 			   (opt && opt->opt.srr) ? opt->opt.faddr : ireq->ir_rmt_addr,
 			   ireq->ir_loc_addr, ireq->ir_rmt_port,
@@ -830,7 +830,7 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
 	fl4 = &newinet->cork.fl.u.ip4;
 
 	flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
-			   RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
+			   ip_sock_rt_tos(sk), ip_sock_rt_scope(sk),
 			   sk->sk_protocol, inet_sk_flowi_flags(sk),
 			   (opt && opt->opt.srr) ? opt->opt.faddr : ireq->ir_rmt_addr,
 			   ireq->ir_loc_addr, ireq->ir_rmt_port,
Signature · 1 line
2.39.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH net-next 1/2] ipv4: Set correct scope in inet_csk_route_*().

Quoted 4 lines · Guillaume Nault

RT_CONN_FLAGS(sk) overloads the tos parameter with the RTO_ONLINK bit when sk has the SOCK_LOCALROUTE flag set. This is only useful for ip_route_output_key_hash() to eventually adjust the route scope.

Quoted 9 lines

Let's drop RTO_ONLINK and set the correct scope directly to avoid this special case in the future and to allow converting ->flowi4_tos to dscp_t.

---
 net/ipv4/inet_connection_sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#3 lore raw

PATCH 2/2 tcp: Set route scope properly in cookie_v4_check().

In reply to Guillaume Nault

RT_CONN_FLAGS(sk) overloads flowi4_tos with the RTO_ONLINK bit when sk has the SOCK_LOCALROUTE flag set. This allows ip_route_output_key_hash() to eventually adjust flowi4_scope.

Instead of relying on special handling of the RTO_ONLINK bit, we can just set the route scope correctly. This will eventually allow to avoid special interpretation of tos variables and to convert ->flowi4_tos to dscp_t.

---
 net/ipv4/syncookies.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/syncookies.c +2 -2
index 26fb97d1d4d9..dc478a0574cb 100644
@@ -418,8 +418,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
 	 * no easy way to do this.
 	 */
 	flowi4_init_output(&fl4, ireq->ir_iif, ireq->ir_mark,
-			   RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE, IPPROTO_TCP,
-			   inet_sk_flowi_flags(sk),
+			   ip_sock_rt_tos(sk), ip_sock_rt_scope(sk),
+			   IPPROTO_TCP, inet_sk_flowi_flags(sk),
 			   opt->srr ? opt->faddr : ireq->ir_rmt_addr,
 			   ireq->ir_loc_addr, th->source, th->dest, sk->sk_uid);
 	security_req_classify_flow(req, flowi4_to_flowi_common(&fl4));
Signature · 1 line
2.39.2
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH net-next 2/2] tcp: Set route scope properly in cookie_v4_check().

Quoted 9 lines · Guillaume Nault

RT_CONN_FLAGS(sk) overloads flowi4_tos with the RTO_ONLINK bit when sk has the SOCK_LOCALROUTE flag set. This allows ip_route_output_key_hash() to eventually adjust flowi4_scope.

Instead of relying on special handling of the RTO_ONLINK bit, we can just set the route scope correctly. This will eventually allow to avoid special interpretation of tos variables and to convert ->flowi4_tos to dscp_t.

Quoted 5 lines
---
 net/ipv4/syncookies.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#5 lore raw
In reply to Guillaume Nault
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Mon, 5 Jun 2023 23:55:19 +0200 you wrote:

Remove a few RT_CONN_FLAGS() calls used inside flowi4_init_output(). These users can be easily converted to set the scope properly, instead of overloading the tos parameter with scope information as done by RT_CONN_FLAGS().

The objective is to eventually remove RT_CONN_FLAGS() entirely, which will then allow to also remove RTO_ONLINK and to finally convert ->flowi4_tos to dscp_t.

[...]

Here is the summary with links:
- [net-next,1/2] ipv4: Set correct scope in inet_csk_route_*().

    https://git.kernel.org/netdev/net-next/c/4b095281caca
  - [net-next,2/2] tcp: Set route scope properly in cookie_v4_check().
    https://git.kernel.org/netdev/net-next/c/6f8a76f80221

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html