Skip to contentSkip to conversation

net: Remove more RTO_ONLINK users.

PATCH Applied Guillaume Nault 3 participants 6 messages Jul 17, 2023 – Jul 19, 2023

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

cover net: Remove more RTO_ONLINK users.

Code that initialise a flowi4 structure manually before doing a fib lookup can easily avoid overloading ->flowi4_tos with the RTO_ONLINK bit. They can just set ->flowi4_scope correctly instead.

Properly separating the routing scope from ->flowi4_tos will allow to eventually convert this field to dscp_t (to ensure proper separation between DSCP and ECN).

Guillaume Nault (3):
gtp: Set TOS and routing scope independently for fib lookups.
dccp: Set TOS and routing scope independently for fib lookups.
sctp: Set TOS and routing scope independently for fib lookups.

 drivers/net/gtp.c   | 3 ++-
 net/dccp/ipv4.c     | 3 ++-
 net/sctp/protocol.c | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/3 gtp: Set TOS and routing scope independently for fib lookups.

There's no reason for setting the RTO_ONLINK flag in ->flowi4_tos as RT_CONN_FLAGS() does. We can easily set ->flowi4_scope properly instead. This makes the code more explicit and will allow to convert ->flowi4_tos to dscp_t in the future.

---
 drivers/net/gtp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/gtp.c +2 -1
index acb20ad4e37e..144ec626230d 100644
@@ -243,7 +243,8 @@ static struct rtable *ip4_route_output_gtp(struct flowi4 *fl4,
 	fl4->flowi4_oif		= sk->sk_bound_dev_if;
 	fl4->daddr		= daddr;
 	fl4->saddr		= saddr;
-	fl4->flowi4_tos		= RT_CONN_FLAGS(sk);
+	fl4->flowi4_tos		= ip_sock_rt_tos(sk);
+	fl4->flowi4_scope	= ip_sock_rt_scope(sk);
 	fl4->flowi4_proto	= sk->sk_protocol;
 
 	return ip_route_output_key(sock_net(sk), fl4);
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/3 dccp: Set TOS and routing scope independently for fib lookups.

In reply to Guillaume Nault

There's no reason for setting the RTO_ONLINK flag in ->flowi4_tos as RT_CONN_FLAGS() does. We can easily set ->flowi4_scope properly instead. This makes the code more explicit and will allow to convert ->flowi4_tos to dscp_t in the future.

---
 net/dccp/ipv4.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/dccp/ipv4.c +2 -1
index fa8079303cb0..8e919cfe6e23 100644
@@ -474,7 +474,8 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
 		.flowi4_oif = inet_iif(skb),
 		.daddr = iph->saddr,
 		.saddr = iph->daddr,
-		.flowi4_tos = RT_CONN_FLAGS(sk),
+		.flowi4_tos = ip_sock_rt_tos(sk),
+		.flowi4_scope = ip_sock_rt_scope(sk),
 		.flowi4_proto = sk->sk_protocol,
 		.fl4_sport = dccp_hdr(skb)->dccph_dport,
 		.fl4_dport = dccp_hdr(skb)->dccph_sport,
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/3 sctp: Set TOS and routing scope independently for fib lookups.

In reply to Guillaume Nault

There's no reason for setting the RTO_ONLINK flag in ->flowi4_tos as RT_CONN_FLAGS() does. We can easily set ->flowi4_scope properly instead. This makes the code more explicit and will allow to convert ->flowi4_tos to dscp_t in the future.

---
 net/sctp/protocol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/protocol.c +2 -1
index 274d07bd774f..33c0895e101c 100644
@@ -435,7 +435,8 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
 	fl4->fl4_dport = daddr->v4.sin_port;
 	fl4->flowi4_proto = IPPROTO_SCTP;
 	if (asoc) {
-		fl4->flowi4_tos = RT_CONN_FLAGS_TOS(asoc->base.sk, tos);
+		fl4->flowi4_tos = RT_TOS(tos);
+		fl4->flowi4_scope = ip_sock_rt_scope(asoc->base.sk);
 		fl4->flowi4_oif = asoc->base.sk->sk_bound_dev_if;
 		fl4->fl4_sport = htons(asoc->base.bind_addr.port);
 	}
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH net-next 3/3] sctp: Set TOS and routing scope independently for fib lookups.

Quoted 26 lines · Guillaume Nault

There's no reason for setting the RTO_ONLINK flag in ->flowi4_tos as RT_CONN_FLAGS() does. We can easily set ->flowi4_scope properly instead. This makes the code more explicit and will allow to convert ->flowi4_tos to dscp_t in the future.

---
 net/sctp/protocol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/protocol.c +2 -2
index 274d07bd774f..33c0895e101c 100644
@@ -435,7 +435,8 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
        fl4->fl4_dport = daddr->v4.sin_port;
        fl4->flowi4_proto = IPPROTO_SCTP;
        if (asoc) {
-               fl4->flowi4_tos = RT_CONN_FLAGS_TOS(asoc->base.sk, tos);
+               fl4->flowi4_tos = RT_TOS(tos);
+               fl4->flowi4_scope = ip_sock_rt_scope(asoc->base.sk);
                fl4->flowi4_oif = asoc->base.sk->sk_bound_dev_if;
                fl4->fl4_sport = htons(asoc->base.bind_addr.port);
        }
--
Quoted 1 line

2.39.2

#5 lore raw
In reply to Guillaume Nault
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

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

Quoted 9 lines · On Mon, 17 Jul 2023 15:53:24 +0200 you wrote:

Code that initialise a flowi4 structure manually before doing a fib lookup can easily avoid overloading ->flowi4_tos with the RTO_ONLINK bit. They can just set ->flowi4_scope correctly instead.

Properly separating the routing scope from ->flowi4_tos will allow to eventually convert this field to dscp_t (to ensure proper separation between DSCP and ECN).

[...]

Here is the summary with links:
- [net-next,1/3] gtp: Set TOS and routing scope independently for fib lookups.

    https://git.kernel.org/netdev/net-next/c/b16b50476714
  - [net-next,2/3] dccp: Set TOS and routing scope independently for fib lookups.
    https://git.kernel.org/netdev/net-next/c/2d6c85ca3eb8
  - [net-next,3/3] sctp: Set TOS and routing scope independently for fib lookups.
    https://git.kernel.org/netdev/net-next/c/ba80e20d7f3f

You are awesome, thank you!

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