@@ -225,6 +225,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
TCPOLEN_ACCECN_PERCOUNTER * \
TCP_ACCECN_NUMCOUNTERS)
#define TCP_ACCECN_BEACON_FREQ_SHIFT 2 /* Send option at least 2^2 times per RTT */
+#define TCP_ACCECN_SAFETY_SHIFT 1 /* SAFETY_FACTOR in accecn draft */
/* tp->saw_accecn_opt states, empty seen & orderbit are overloaded */
#define TCP_ACCECN_OPT_EMPTY_SEEN 0x1
@@ -518,14 +518,16 @@ static bool tcp_accecn_process_option(struct tcp_sock *tp,
static u32 tcp_accecn_process(struct tcp_sock *tp, const struct sk_buff *skb,
u32 delivered_pkts, u32 delivered_bytes, int flag)
{
- u32 delta, safe_delta;
+ u32 delta, safe_delta, d_ceb;
u32 corrected_ace;
+ u32 old_ceb = tp->delivered_ecn_bytes[INET_ECN_CE - 1];
+ bool opt_deltas_valid;
/* Reordered ACK? (...or uncertain due to lack of data to send and ts) */
if (!(flag & (FLAG_FORWARD_PROGRESS|FLAG_TS_PROGRESS)))
return 0;
- tcp_accecn_process_option(tp, skb, delivered_bytes);
+ opt_deltas_valid = tcp_accecn_process_option(tp, skb, delivered_bytes);
if (!(flag & FLAG_SLOWPATH)) {
/* AccECN counter might overflow on large ACKs */
@@ -545,6 +547,16 @@ static u32 tcp_accecn_process(struct tcp_sock *tp, const struct sk_buff *skb,
safe_delta = delivered_pkts -
((delivered_pkts - delta) & TCP_ACCECN_CEP_ACE_MASK);
+ if (opt_deltas_valid) {
+ d_ceb = tp->delivered_ecn_bytes[INET_ECN_CE - 1] - old_ceb;
+ if (!d_ceb)
+ return delta;
+ if (d_ceb > delta * tp->mss_cache)
+ return safe_delta;
+ if (d_ceb < safe_delta * tp->mss_cache >> TCP_ACCECN_SAFETY_SHIFT)
+ return delta;
+ }
+
return safe_delta;
}