Skip to content

Commit 2c99b2e

Browse files
committed
Merge branch 'tcp-accecn'
Chia-Yu Chang says: ==================== AccECN protocol preparation patch series Please find the v7 v7 (03-Mar-2025) - Move 2 new patches added in v6 to the next AccECN patch series v6 (27-Dec-2024) - Avoid removing removing the potential CA_ACK_WIN_UPDATE in ack_ev_flags of patch kernel-patches#1 (Eric Dumazet <[email protected]>) - Add reviewed-by tag in patches kernel-patches#2, kernel-patches#3, kernel-patches#4, kernel-patches#5, kernel-patches#6, kernel-patches#7, kernel-patches#8, kernel-patches#12, kernel-patches#14 - Foloiwng 2 new pathces are added after patch kernel-patches#9 (Patch that adds SKB_GSO_TCP_ACCECN) * New patch kernel-patches#10 to replace exisiting SKB_GSO_TCP_ECN with SKB_GSO_TCP_ACCECN in the driver to avoid CWR flag corruption * New patch kernel-patches#11 adds AccECN for virtio by adding new negotiation flag (VIRTIO_NET_F_HOST/GUEST_ACCECN) in feature handshake and translating Accurate ECN GSO flag between virtio_net_hdr (VIRTIO_NET_HDR_GSO_ACCECN) and skb header (SKB_GSO_TCP_ACCECN) - Add detailed changelog and comments in kernel-patches#13 (Eric Dumazet <[email protected]>) - Move patch kernel-patches#14 to the next AccECN patch series (Eric Dumazet <[email protected]>) v5 (5-Nov-2024) - Add helper function "tcp_flags_ntohs" to preserve last 2 bytes of TCP flags of patch kernel-patches#4 (Paolo Abeni <[email protected]>) - Fix reverse X-max tree order of patches kernel-patches#4, kernel-patches#11 (Paolo Abeni <[email protected]>) - Rename variable "delta" as "timestamp_delta" of patch kernel-patches#2 fo clariety - Remove patch kernel-patches#14 in this series (Paolo Abeni <[email protected]>, Joel Granados <[email protected]>) v4 (21-Oct-2024) - Fix line length warning of patches kernel-patches#2, kernel-patches#4, kernel-patches#8, kernel-patches#10, kernel-patches#11, kernel-patches#14 - Fix spaces preferred around '|' (ctx:VxV) warning of patch kernel-patches#7 - Add missing CC'ed of patches kernel-patches#4, kernel-patches#12, kernel-patches#14 v3 (19-Oct-2024) - Fix build error in v2 v2 (18-Oct-2024) - Fix warning caused by NETIF_F_GSO_ACCECN_BIT in patch kernel-patches#9 (Jakub Kicinski <[email protected]>) The full patch series can be found in https://github.com/L4STeam/linux-net-next/commits/upstream_l4steam/ The Accurate ECN draft can be found in https://datatracker.ietf.org/doc/html/draft-ietf-tcpm-accurate-ecn-28 ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents bfc6c67 + 9866884 commit 2c99b2e

18 files changed

+226
-112
lines changed

include/linux/netdev_features.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ enum {
5353
NETIF_F_GSO_UDP_BIT, /* ... UFO, deprecated except tuntap */
5454
NETIF_F_GSO_UDP_L4_BIT, /* ... UDP payload GSO (not UFO) */
5555
NETIF_F_GSO_FRAGLIST_BIT, /* ... Fraglist GSO */
56+
NETIF_F_GSO_ACCECN_BIT, /* TCP AccECN w/ TSO (no clear CWR) */
5657
/**/NETIF_F_GSO_LAST = /* last bit, see GSO_MASK */
57-
NETIF_F_GSO_FRAGLIST_BIT,
58+
NETIF_F_GSO_ACCECN_BIT,
5859

5960
NETIF_F_FCOE_CRC_BIT, /* FCoE CRC32 */
6061
NETIF_F_SCTP_CRC_BIT, /* SCTP checksum offload */
61-
__UNUSED_NETIF_F_37,
6262
NETIF_F_NTUPLE_BIT, /* N-tuple filters supported */
6363
NETIF_F_RXHASH_BIT, /* Receive hashing offload */
6464
NETIF_F_RXCSUM_BIT, /* Receive checksumming offload */
@@ -128,6 +128,7 @@ enum {
128128
#define NETIF_F_SG __NETIF_F(SG)
129129
#define NETIF_F_TSO6 __NETIF_F(TSO6)
130130
#define NETIF_F_TSO_ECN __NETIF_F(TSO_ECN)
131+
#define NETIF_F_GSO_ACCECN __NETIF_F(GSO_ACCECN)
131132
#define NETIF_F_TSO __NETIF_F(TSO)
132133
#define NETIF_F_VLAN_CHALLENGED __NETIF_F(VLAN_CHALLENGED)
133134
#define NETIF_F_RXFCS __NETIF_F(RXFCS)
@@ -210,7 +211,8 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
210211
NETIF_F_TSO_ECN | NETIF_F_TSO_MANGLEID)
211212

212213
/* List of features with software fallbacks. */
213-
#define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | NETIF_F_GSO_SCTP | \
214+
#define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | \
215+
NETIF_F_GSO_ACCECN | NETIF_F_GSO_SCTP | \
214216
NETIF_F_GSO_UDP_L4 | NETIF_F_GSO_FRAGLIST)
215217

216218
/*

include/linux/netdevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5269,6 +5269,8 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
52695269
BUILD_BUG_ON(SKB_GSO_UDP != (NETIF_F_GSO_UDP >> NETIF_F_GSO_SHIFT));
52705270
BUILD_BUG_ON(SKB_GSO_UDP_L4 != (NETIF_F_GSO_UDP_L4 >> NETIF_F_GSO_SHIFT));
52715271
BUILD_BUG_ON(SKB_GSO_FRAGLIST != (NETIF_F_GSO_FRAGLIST >> NETIF_F_GSO_SHIFT));
5272+
BUILD_BUG_ON(SKB_GSO_TCP_ACCECN !=
5273+
(NETIF_F_GSO_ACCECN >> NETIF_F_GSO_SHIFT));
52725274

52735275
return (features & feature) == feature;
52745276
}

include/linux/skbuff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,8 @@ enum {
708708
SKB_GSO_UDP_L4 = 1 << 17,
709709

710710
SKB_GSO_FRAGLIST = 1 << 18,
711+
712+
SKB_GSO_TCP_ACCECN = 1 << 19,
711713
};
712714

713715
#if BITS_PER_LONG > 32

include/net/tcp.h

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/kref.h>
2727
#include <linux/ktime.h>
2828
#include <linux/indirect_call_wrapper.h>
29+
#include <linux/bits.h>
2930

3031
#include <net/inet_connection_sock.h>
3132
#include <net/inet_timewait_sock.h>
@@ -373,16 +374,53 @@ static inline void tcp_dec_quickack_mode(struct sock *sk)
373374
}
374375
}
375376

376-
#define TCP_ECN_OK 1
377-
#define TCP_ECN_QUEUE_CWR 2
378-
#define TCP_ECN_DEMAND_CWR 4
379-
#define TCP_ECN_SEEN 8
377+
#define TCP_ECN_MODE_RFC3168 BIT(0)
378+
#define TCP_ECN_QUEUE_CWR BIT(1)
379+
#define TCP_ECN_DEMAND_CWR BIT(2)
380+
#define TCP_ECN_SEEN BIT(3)
381+
#define TCP_ECN_MODE_ACCECN BIT(4)
382+
383+
#define TCP_ECN_DISABLED 0
384+
#define TCP_ECN_MODE_PENDING (TCP_ECN_MODE_RFC3168 | TCP_ECN_MODE_ACCECN)
385+
#define TCP_ECN_MODE_ANY (TCP_ECN_MODE_RFC3168 | TCP_ECN_MODE_ACCECN)
386+
387+
static inline bool tcp_ecn_mode_any(const struct tcp_sock *tp)
388+
{
389+
return tp->ecn_flags & TCP_ECN_MODE_ANY;
390+
}
391+
392+
static inline bool tcp_ecn_mode_rfc3168(const struct tcp_sock *tp)
393+
{
394+
return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_RFC3168;
395+
}
396+
397+
static inline bool tcp_ecn_mode_accecn(const struct tcp_sock *tp)
398+
{
399+
return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_ACCECN;
400+
}
401+
402+
static inline bool tcp_ecn_disabled(const struct tcp_sock *tp)
403+
{
404+
return !tcp_ecn_mode_any(tp);
405+
}
406+
407+
static inline bool tcp_ecn_mode_pending(const struct tcp_sock *tp)
408+
{
409+
return (tp->ecn_flags & TCP_ECN_MODE_PENDING) == TCP_ECN_MODE_PENDING;
410+
}
411+
412+
static inline void tcp_ecn_mode_set(struct tcp_sock *tp, u8 mode)
413+
{
414+
tp->ecn_flags &= ~TCP_ECN_MODE_ANY;
415+
tp->ecn_flags |= mode;
416+
}
380417

381418
enum tcp_tw_status {
382419
TCP_TW_SUCCESS = 0,
383420
TCP_TW_RST = 1,
384421
TCP_TW_ACK = 2,
385-
TCP_TW_SYN = 3
422+
TCP_TW_SYN = 3,
423+
TCP_TW_ACK_OOW = 4
386424
};
387425

388426

@@ -669,7 +707,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority,
669707
enum sk_rst_reason reason);
670708
int tcp_send_synack(struct sock *);
671709
void tcp_push_one(struct sock *, unsigned int mss_now);
672-
void __tcp_send_ack(struct sock *sk, u32 rcv_nxt);
710+
void __tcp_send_ack(struct sock *sk, u32 rcv_nxt, u16 flags);
673711
void tcp_send_ack(struct sock *sk);
674712
void tcp_send_delayed_ack(struct sock *sk);
675713
void tcp_send_loss_probe(struct sock *sk);
@@ -934,15 +972,22 @@ static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq)
934972

935973
#define tcp_flag_byte(th) (((u_int8_t *)th)[13])
936974

937-
#define TCPHDR_FIN 0x01
938-
#define TCPHDR_SYN 0x02
939-
#define TCPHDR_RST 0x04
940-
#define TCPHDR_PSH 0x08
941-
#define TCPHDR_ACK 0x10
942-
#define TCPHDR_URG 0x20
943-
#define TCPHDR_ECE 0x40
944-
#define TCPHDR_CWR 0x80
945-
975+
#define TCPHDR_FIN BIT(0)
976+
#define TCPHDR_SYN BIT(1)
977+
#define TCPHDR_RST BIT(2)
978+
#define TCPHDR_PSH BIT(3)
979+
#define TCPHDR_ACK BIT(4)
980+
#define TCPHDR_URG BIT(5)
981+
#define TCPHDR_ECE BIT(6)
982+
#define TCPHDR_CWR BIT(7)
983+
#define TCPHDR_AE BIT(8)
984+
#define TCPHDR_FLAGS_MASK (TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST | \
985+
TCPHDR_PSH | TCPHDR_ACK | TCPHDR_URG | \
986+
TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE)
987+
#define tcp_flags_ntohs(th) (ntohs(*(__be16 *)&tcp_flag_word(th)) & \
988+
TCPHDR_FLAGS_MASK)
989+
990+
#define TCPHDR_ACE (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE)
946991
#define TCPHDR_SYN_ECN (TCPHDR_SYN | TCPHDR_ECE | TCPHDR_CWR)
947992

948993
/* State flags for sacked in struct tcp_skb_cb */
@@ -977,7 +1022,7 @@ struct tcp_skb_cb {
9771022
u16 tcp_gso_size;
9781023
};
9791024
};
980-
__u8 tcp_flags; /* TCP header flags. (tcp[13]) */
1025+
__u16 tcp_flags; /* TCP header flags (tcp[12-13])*/
9811026

9821027
__u8 sacked; /* State flags for SACK. */
9831028
__u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
@@ -1132,9 +1177,9 @@ enum tcp_ca_ack_event_flags {
11321177
#define TCP_CA_UNSPEC 0
11331178

11341179
/* Algorithm can be set on socket without CAP_NET_ADMIN privileges */
1135-
#define TCP_CONG_NON_RESTRICTED 0x1
1180+
#define TCP_CONG_NON_RESTRICTED BIT(0)
11361181
/* Requires ECN/ECT set on all packets */
1137-
#define TCP_CONG_NEEDS_ECN 0x2
1182+
#define TCP_CONG_NEEDS_ECN BIT(1)
11381183
#define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN)
11391184

11401185
union tcp_cc_info;

include/uapi/linux/tcp.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ struct tcphdr {
2828
__be32 seq;
2929
__be32 ack_seq;
3030
#if defined(__LITTLE_ENDIAN_BITFIELD)
31-
__u16 res1:4,
31+
__u16 ae:1,
32+
res1:3,
3233
doff:4,
3334
fin:1,
3435
syn:1,
@@ -40,7 +41,8 @@ struct tcphdr {
4041
cwr:1;
4142
#elif defined(__BIG_ENDIAN_BITFIELD)
4243
__u16 doff:4,
43-
res1:4,
44+
res1:3,
45+
ae:1,
4446
cwr:1,
4547
ece:1,
4648
urg:1,
@@ -70,6 +72,7 @@ union tcp_word_hdr {
7072
#define tcp_flag_word(tp) (((union tcp_word_hdr *)(tp))->words[3])
7173

7274
enum {
75+
TCP_FLAG_AE = __constant_cpu_to_be32(0x01000000),
7376
TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000),
7477
TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000),
7578
TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000),
@@ -78,7 +81,7 @@ enum {
7881
TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000),
7982
TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000),
8083
TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000),
81-
TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000),
84+
TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0E000000),
8285
TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000)
8386
};
8487

net/ethtool/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
3636
[NETIF_F_TSO_BIT] = "tx-tcp-segmentation",
3737
[NETIF_F_GSO_ROBUST_BIT] = "tx-gso-robust",
3838
[NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation",
39+
[NETIF_F_GSO_ACCECN_BIT] = "tx-tcp-accecn-segmentation",
3940
[NETIF_F_TSO_MANGLEID_BIT] = "tx-tcp-mangleid-segmentation",
4041
[NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation",
4142
[NETIF_F_FSO_BIT] = "tx-fcoe-segmentation",

net/ipv4/bpf_tcp_ca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int bpf_tcp_ca_btf_struct_access(struct bpf_verifier_log *log,
121121
BPF_CALL_2(bpf_tcp_send_ack, struct tcp_sock *, tp, u32, rcv_nxt)
122122
{
123123
/* bpf_tcp_ca prog cannot have NULL tp */
124-
__tcp_send_ack((struct sock *)tp, rcv_nxt);
124+
__tcp_send_ack((struct sock *)tp, rcv_nxt, 0);
125125
return 0;
126126
}
127127

net/ipv4/ip_output.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
#include <net/checksum.h>
7676
#include <net/gso.h>
7777
#include <net/inetpeer.h>
78-
#include <net/inet_ecn.h>
7978
#include <net/lwtunnel.h>
8079
#include <net/inet_dscp.h>
8180
#include <linux/bpf-cgroup.h>
@@ -1640,7 +1639,7 @@ void ip_send_unicast_reply(struct sock *sk, const struct sock *orig_sk,
16401639
if (IS_ERR(rt))
16411640
return;
16421641

1643-
inet_sk(sk)->tos = arg->tos & ~INET_ECN_MASK;
1642+
inet_sk(sk)->tos = arg->tos;
16441643

16451644
sk->sk_protocol = ip_hdr(skb)->protocol;
16461645
sk->sk_bound_dev_if = arg->bound_dev_if;

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4138,7 +4138,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
41384138
info->tcpi_rcv_wscale = tp->rx_opt.rcv_wscale;
41394139
}
41404140

4141-
if (tp->ecn_flags & TCP_ECN_OK)
4141+
if (tcp_ecn_mode_any(tp))
41424142
info->tcpi_options |= TCPI_OPT_ECN;
41434143
if (tp->ecn_flags & TCP_ECN_SEEN)
41444144
info->tcpi_options |= TCPI_OPT_ECN_SEEN;

net/ipv4/tcp_dctcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ __bpf_kfunc static void dctcp_init(struct sock *sk)
9090
{
9191
const struct tcp_sock *tp = tcp_sk(sk);
9292

93-
if ((tp->ecn_flags & TCP_ECN_OK) ||
93+
if (tcp_ecn_mode_any(tp) ||
9494
(sk->sk_state == TCP_LISTEN ||
9595
sk->sk_state == TCP_CLOSE)) {
9696
struct dctcp *ca = inet_csk_ca(sk);

net/ipv4/tcp_dctcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static inline void dctcp_ece_ack_update(struct sock *sk, enum tcp_ca_event evt,
2828
*/
2929
if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER) {
3030
dctcp_ece_ack_cwr(sk, *ce_state);
31-
__tcp_send_ack(sk, *prior_rcv_nxt);
31+
__tcp_send_ack(sk, *prior_rcv_nxt, 0);
3232
}
3333
inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_NOW;
3434
}

0 commit comments

Comments
 (0)