Skip to content

Commit

Permalink
net-tcp: add new ca opts flag TCP_CONG_WANTS_CE_EVENTS
Browse files Browse the repository at this point in the history
Add a a new ca opts flag TCP_CONG_WANTS_CE_EVENTS that allows a
congestion control module to receive CE events.

Currently congestion control modules have to set the TCP_CONG_NEEDS_ECN
bit in opts flag to receive CE events but this may incur changes in ECN
behavior elsewhere. This patch adds a new bit TCP_CONG_WANTS_CE_EVENTS
that allows congestion control modules to receive CE events
independently of TCP_CONG_NEEDS_ECN.

Effort: net-tcp
Origin-9xx-SHA1: 9f7e14716cde760bc6c67ef8ef7e1ee48501d95b
Change-Id: I2255506985242f376d910c6fd37daabaf4744f24
  • Loading branch information
yousukseung authored and xanmod committed Jun 28, 2021
1 parent 0d84776 commit 5d925d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion include/net/tcp.h
Expand Up @@ -1011,7 +1011,11 @@ enum tcp_ca_ack_event_flags {
#define TCP_CONG_NON_RESTRICTED 0x1
/* Requires ECN/ECT set on all packets */
#define TCP_CONG_NEEDS_ECN 0x2
#define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN)
/* Wants notification of CE events (CA_EVENT_ECN_IS_CE, CA_EVENT_ECN_NO_CE). */
#define TCP_CONG_WANTS_CE_EVENTS 0x4
#define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | \
TCP_CONG_NEEDS_ECN | \
TCP_CONG_WANTS_CE_EVENTS)

union tcp_cc_info;

Expand Down Expand Up @@ -1138,6 +1142,14 @@ static inline char *tcp_ca_get_name_by_key(u32 key, char *buffer)
}
#endif

static inline bool tcp_ca_wants_ce_events(const struct sock *sk)
{
const struct inet_connection_sock *icsk = inet_csk(sk);

return icsk->icsk_ca_ops->flags & (TCP_CONG_NEEDS_ECN |
TCP_CONG_WANTS_CE_EVENTS);
}

static inline bool tcp_ca_needs_ecn(const struct sock *sk)
{
const struct inet_connection_sock *icsk = inet_csk(sk);
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/tcp_input.c
Expand Up @@ -348,7 +348,7 @@ static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
tcp_enter_quickack_mode(sk, 2);
break;
case INET_ECN_CE:
if (tcp_ca_needs_ecn(sk))
if (tcp_ca_wants_ce_events(sk))
tcp_ca_event(sk, CA_EVENT_ECN_IS_CE);

if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) {
Expand All @@ -359,7 +359,7 @@ static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
tp->ecn_flags |= TCP_ECN_SEEN;
break;
default:
if (tcp_ca_needs_ecn(sk))
if (tcp_ca_wants_ce_events(sk))
tcp_ca_event(sk, CA_EVENT_ECN_NO_CE);
tp->ecn_flags |= TCP_ECN_SEEN;
break;
Expand Down

0 comments on commit 5d925d3

Please sign in to comment.