tcp: helpers for ECN mode handling

Create helpers for TCP ECN modes. 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>
This commit is contained in:
Ilpo Järvinen
2025-03-05 23:38:47 +01:00
committed by David S. Miller
parent f0db2bca0c
commit 041fb11d51
6 changed files with 55 additions and 17 deletions

View File

@@ -374,10 +374,46 @@ static inline void tcp_dec_quickack_mode(struct sock *sk)
}
}
#define TCP_ECN_OK 1
#define TCP_ECN_QUEUE_CWR 2
#define TCP_ECN_DEMAND_CWR 4
#define TCP_ECN_SEEN 8
#define TCP_ECN_MODE_RFC3168 BIT(0)
#define TCP_ECN_QUEUE_CWR BIT(1)
#define TCP_ECN_DEMAND_CWR BIT(2)
#define TCP_ECN_SEEN BIT(3)
#define TCP_ECN_MODE_ACCECN BIT(4)
#define TCP_ECN_DISABLED 0
#define TCP_ECN_MODE_PENDING (TCP_ECN_MODE_RFC3168 | TCP_ECN_MODE_ACCECN)
#define TCP_ECN_MODE_ANY (TCP_ECN_MODE_RFC3168 | TCP_ECN_MODE_ACCECN)
static inline bool tcp_ecn_mode_any(const struct tcp_sock *tp)
{
return tp->ecn_flags & TCP_ECN_MODE_ANY;
}
static inline bool tcp_ecn_mode_rfc3168(const struct tcp_sock *tp)
{
return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_RFC3168;
}
static inline bool tcp_ecn_mode_accecn(const struct tcp_sock *tp)
{
return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_ACCECN;
}
static inline bool tcp_ecn_disabled(const struct tcp_sock *tp)
{
return !tcp_ecn_mode_any(tp);
}
static inline bool tcp_ecn_mode_pending(const struct tcp_sock *tp)
{
return (tp->ecn_flags & TCP_ECN_MODE_PENDING) == TCP_ECN_MODE_PENDING;
}
static inline void tcp_ecn_mode_set(struct tcp_sock *tp, u8 mode)
{
tp->ecn_flags &= ~TCP_ECN_MODE_ANY;
tp->ecn_flags |= mode;
}
enum tcp_tw_status {
TCP_TW_SUCCESS = 0,