On 7/4/25 10:53 AM, chia-yu.chang@xxxxxxxxxxxxxxxxxxx wrote: > @@ -285,9 +297,33 @@ static inline void tcp_ecn_received_counters(struct sock *sk, > > if (len > 0) { > u8 minlen = tcp_ecnfield_to_accecn_optfield(ecnfield); > + u32 oldbytes = tp->received_ecn_bytes[ecnfield - 1]; > + > tp->received_ecn_bytes[ecnfield - 1] += len; > tp->accecn_minlen = max_t(u8, tp->accecn_minlen, > minlen); > + > + /* Demand AccECN option at least every 2^22 bytes to > + * avoid overflowing the ECN byte counters. > + */ > + if ((tp->received_ecn_bytes[ecnfield - 1] ^ oldbytes) & > + ~((1 << 22) - 1)) { I don't understand the above statement, I don't think it yield the result expected according to the above comment. > @@ -365,6 +401,7 @@ static inline void tcp_accecn_init_counters(struct tcp_sock *tp) > __tcp_accecn_init_bytes_counters(tp->received_ecn_bytes); > __tcp_accecn_init_bytes_counters(tp->delivered_ecn_bytes); > tp->accecn_minlen = 0; > + tp->accecn_opt_demand = 0; > tp->est_ecnfield = 0; > } > > @@ -447,6 +484,7 @@ static inline void tcp_ecn_rcv_synack(struct sock *sk, const struct tcphdr *th, > default: > tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); > tp->syn_ect_rcv = ip_dsfield & INET_ECN_MASK; > + tp->accecn_opt_demand = 2; > if (INET_ECN_is_ce(ip_dsfield) && > tcp_accecn_validate_syn_feedback(sk, ace, > tp->syn_ect_snt)) { > @@ -467,6 +505,7 @@ static inline void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th, > } else { > tp->syn_ect_rcv = TCP_SKB_CB(skb)->ip_dsfield & > INET_ECN_MASK; > + tp->prev_ecnfield = tp->syn_ect_rcv; > tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); > } > } > @@ -565,4 +604,16 @@ tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th) > th->ece = 1; > } > > +static inline bool tcp_accecn_option_beacon_check(const struct sock *sk) > +{ > + const struct tcp_sock *tp = tcp_sk(sk); > + > + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option_beacon)) > + return false; > + > + return tcp_stamp_us_delta(tp->tcp_mstamp, tp->accecn_opt_tstamp) * > + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option_beacon) >= > + (tp->srtt_us >> 3); To be consistent: u32 ecn_beacon = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option_beacon); if (!ecn_beacon) return false; return tcp_stamp_us_delta(tp->tcp_mstamp, tp->accecn_opt_tstamp) * ecn_beacon // ... /P