Skip to content

Commit

Permalink
tcp: introduce per-route feature RTAX_FEATURE_ECN_LOW
Browse files Browse the repository at this point in the history
Define and implement a new per-route feature, RTAX_FEATURE_ECN_LOW.

This feature indicates that the given destination network is a
low-latency ECN environment, meaning both that ECN CE marks are
applied by the network using a low-latency marking threshold and also
that TCP endpoints provide precise per-data-segment ECN feedback in
ACKs (where the ACK ECE flag echoes the received CE status of all
newly-acknowledged data segments). This feature indication can be used
by congestion control algorithms to decide how to interpret ECN
signals over the given destination network.

This feature is appropriate for datacenter-style ECN marking, such as
the ECN marking approach expected by DCTCP or BBR congestion control
modules.

Signed-off-by: David Morley <morleyd@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Tested-by: David Morley <morleyd@google.com>
Change-Id: I6bc06e9c6cb426fbae7243fc71c9a8c18175f5d3
Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
David Morley authored and xanmod committed Aug 16, 2023
1 parent 9bc8bc1 commit 3f63752
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions include/net/tcp.h
Expand Up @@ -375,6 +375,7 @@ static inline void tcp_dec_quickack_mode(struct sock *sk,
#define TCP_ECN_QUEUE_CWR 2
#define TCP_ECN_DEMAND_CWR 4
#define TCP_ECN_SEEN 8
#define TCP_ECN_LOW 16

enum tcp_tw_status {
TCP_TW_SUCCESS = 0,
Expand Down Expand Up @@ -728,6 +729,15 @@ static inline void tcp_fast_path_check(struct sock *sk)
tcp_fast_path_on(tp);
}

static inline void tcp_set_ecn_low_from_dst(struct sock *sk,
const struct dst_entry *dst)
{
struct tcp_sock *tp = tcp_sk(sk);

if (dst_feature(dst, RTAX_FEATURE_ECN_LOW))
tp->ecn_flags |= TCP_ECN_LOW;
}

/* Compute the actual rto_min value */
static inline u32 tcp_rto_min(struct sock *sk)
{
Expand Down
4 changes: 3 additions & 1 deletion include/uapi/linux/rtnetlink.h
Expand Up @@ -506,9 +506,11 @@ enum {
#define RTAX_FEATURE_SACK (1 << 1)
#define RTAX_FEATURE_TIMESTAMP (1 << 2)
#define RTAX_FEATURE_ALLFRAG (1 << 3)
#define RTAX_FEATURE_ECN_LOW (1 << 4)

#define RTAX_FEATURE_MASK (RTAX_FEATURE_ECN | RTAX_FEATURE_SACK | \
RTAX_FEATURE_TIMESTAMP | RTAX_FEATURE_ALLFRAG)
RTAX_FEATURE_TIMESTAMP | RTAX_FEATURE_ALLFRAG \
| RTAX_FEATURE_ECN_LOW)

struct rta_session {
__u8 proto;
Expand Down
2 changes: 2 additions & 0 deletions net/ipv4/tcp_minisocks.c
Expand Up @@ -423,6 +423,8 @@ void tcp_ca_openreq_child(struct sock *sk, const struct dst_entry *dst)
u32 ca_key = dst_metric(dst, RTAX_CC_ALGO);
bool ca_got_dst = false;

tcp_set_ecn_low_from_dst(sk, dst);

if (ca_key != TCP_CA_UNSPEC) {
const struct tcp_congestion_ops *ca;

Expand Down
6 changes: 4 additions & 2 deletions net/ipv4/tcp_output.c
Expand Up @@ -327,10 +327,9 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb)
bool bpf_needs_ecn = tcp_bpf_ca_needs_ecn(sk);
bool use_ecn = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn) == 1 ||
tcp_ca_needs_ecn(sk) || bpf_needs_ecn;
const struct dst_entry *dst = __sk_dst_get(sk);

if (!use_ecn) {
const struct dst_entry *dst = __sk_dst_get(sk);

if (dst && dst_feature(dst, RTAX_FEATURE_ECN))
use_ecn = true;
}
Expand All @@ -342,6 +341,9 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb)
tp->ecn_flags = TCP_ECN_OK;
if (tcp_ca_needs_ecn(sk) || bpf_needs_ecn)
INET_ECN_xmit(sk);

if (dst)
tcp_set_ecn_low_from_dst(sk, dst);
}
}

Expand Down

0 comments on commit 3f63752

Please sign in to comment.