tcp: rework {__,}tcp_ecn_check_ce() -> tcp_data_ecn_check()
authorIlpo Järvinen <ij@kernel.org>
Wed, 5 Mar 2025 22:38:46 +0000 (23:38 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Mar 2025 13:50:13 +0000 (13:50 +0000)
Rename tcp_ecn_check_ce to tcp_data_ecn_check as it is
called only for data segments, not for ACKs (with AccECN,
also ACKs may get ECN bits).

The extra "layer" in tcp_ecn_check_ce() function just
checks for ECN being enabled, that can be moved into
tcp_ecn_field_check rather than having the __ variant.

No functional changes.

Signed-off-by: Ilpo Järvinen <ij@kernel.org>
Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_input.c

index 771e075d457d9fa7758a683e03f9b6a0f96a214a..769048b559e5955c03e6cdd0cdc69b915413d6e0 100644 (file)
@@ -365,10 +365,13 @@ static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp)
        tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
 }
 
-static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
+static void tcp_data_ecn_check(struct sock *sk, const struct sk_buff *skb)
 {
        struct tcp_sock *tp = tcp_sk(sk);
 
+       if (!(tcp_sk(sk)->ecn_flags & TCP_ECN_OK))
+               return;
+
        switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) {
        case INET_ECN_NOT_ECT:
                /* Funny extension: if ECT is not set on a segment,
@@ -397,12 +400,6 @@ static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
        }
 }
 
-static void tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
-{
-       if (tcp_sk(sk)->ecn_flags & TCP_ECN_OK)
-               __tcp_ecn_check_ce(sk, skb);
-}
-
 static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th)
 {
        if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || th->cwr))
@@ -874,7 +871,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb)
        icsk->icsk_ack.lrcvtime = now;
        tcp_save_lrcv_flowlabel(sk, skb);
 
-       tcp_ecn_check_ce(sk, skb);
+       tcp_data_ecn_check(sk, skb);
 
        if (skb->len >= 128)
                tcp_grow_window(sk, skb, true);
@@ -5041,7 +5038,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb)
        bool fragstolen;
 
        tcp_save_lrcv_flowlabel(sk, skb);
-       tcp_ecn_check_ce(sk, skb);
+       tcp_data_ecn_check(sk, skb);
 
        if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) {
                NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP);