include/net/tcp_ecn.h
Source file repositories/reference/linux-study-clean/include/net/tcp_ecn.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/tcp_ecn.h- Extension
.h- Size
- 20322 bytes
- Lines
- 676
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/tcp.hlinux/skbuff.hlinux/bitfield.hnet/inet_connection_sock.hnet/sock.hnet/tcp.hnet/inet_ecn.h
Detected Declarations
enum tcp_ecn_modeenum tcp_accecn_optionfunction INET_ECN_xmit_ect_1_negotiationfunction tcp_ecn_queue_cwrfunction tcp_ecn_accept_cwrfunction tcp_ecn_withdraw_cwrfunction tcp_accecn_ace_fail_sendfunction tcp_accecn_ace_fail_recvfunction tcp_accecn_opt_fail_sendfunction tcp_accecn_opt_fail_recvfunction tcp_accecn_fail_mode_setfunction tcp_accecn_acefunction tcp_accecn_extract_syn_ectfunction tcp_ect_transition_validfunction tcp_accecn_validate_syn_feedbackfunction tcp_accecn_saw_opt_fail_recvfunction tcp_accecn_third_ackfunction tcp_accecn_opt_demand_minfunction tcp_ecnfield_to_accecn_optfieldfunction tcp_accecn_field_init_offsetfunction tcp_accecn_optfield_to_ecnfieldfunction tcp_update_ecn_bytesfunction tcp_ecn_received_countersfunction tcp_ecn_received_counters_payloadfunction cookie_accecn_okfunction tcp_accecn_reflector_flagsfunction flagsfunction __tcp_accecn_init_bytes_countersfunction tcp_accecn_init_countersfunction tcp_accecn_echo_syn_ectfunction tcp_accecn_set_acefunction tcp_accecn_option_initfunction tcp_ecn_rcv_synack_accecnfunction tcp_ecn_rcv_synackfunction tcp_ecn_rcv_synfunction tcp_ecn_rcv_ecn_echofunction tcp_ecn_send_synackfunction tcp_ecn_send_synfunction tcp_ecn_clear_synfunction tcp_ecn_make_synackfunction tcp_accecn_option_beacon_check
Annotated Snippet
tcp_accecn_validate_syn_feedback(sk, ace, sent_ect)) {
if ((tcp_accecn_extract_syn_ect(ace) == INET_ECN_CE) &&
!tp->delivered_ce)
WRITE_ONCE(tp->delivered_ce, 1);
}
break;
}
}
/* Demand the minimum # to send AccECN optnio */
static inline void tcp_accecn_opt_demand_min(struct sock *sk,
u8 opt_demand_min)
{
struct tcp_sock *tp = tcp_sk(sk);
u8 opt_demand;
opt_demand = max_t(u8, opt_demand_min, tp->accecn_opt_demand);
tp->accecn_opt_demand = opt_demand;
}
/* Maps IP ECN field ECT/CE code point to AccECN option field number, given
* we are sending fields with Accurate ECN Order 1: ECT(1), CE, ECT(0).
*/
static inline u8 tcp_ecnfield_to_accecn_optfield(u8 ecnfield)
{
switch (ecnfield & INET_ECN_MASK) {
case INET_ECN_NOT_ECT:
return 0; /* AccECN does not send counts of NOT_ECT */
case INET_ECN_ECT_1:
return 1;
case INET_ECN_CE:
return 2;
case INET_ECN_ECT_0:
return 3;
}
return 0;
}
/* Maps IP ECN field ECT/CE code point to AccECN option field value offset.
* Some fields do not start from zero, to detect zeroing by middleboxes.
*/
static inline u32 tcp_accecn_field_init_offset(u8 ecnfield)
{
switch (ecnfield & INET_ECN_MASK) {
case INET_ECN_NOT_ECT:
return 0; /* AccECN does not send counts of NOT_ECT */
case INET_ECN_ECT_1:
return TCP_ACCECN_E1B_INIT_OFFSET;
case INET_ECN_CE:
return TCP_ACCECN_CEB_INIT_OFFSET;
case INET_ECN_ECT_0:
return TCP_ACCECN_E0B_INIT_OFFSET;
}
return 0;
}
/* Maps AccECN option field #nr to IP ECN field ECT/CE bits */
static inline unsigned int tcp_accecn_optfield_to_ecnfield(unsigned int option,
bool order)
{
/* Based on Table 5 of the AccECN spec to map (option, order) to
* the corresponding ECN conuters (ECT-1, ECT-0, or CE).
*/
static const u8 optfield_lookup[2][3] = {
/* order = 0: 1st field ECT-0, 2nd field CE, 3rd field ECT-1 */
{ INET_ECN_ECT_0, INET_ECN_CE, INET_ECN_ECT_1 },
/* order = 1: 1st field ECT-1, 2nd field CE, 3rd field ECT-0 */
{ INET_ECN_ECT_1, INET_ECN_CE, INET_ECN_ECT_0 }
};
return optfield_lookup[order][option % 3];
}
/* Handles AccECN option ECT and CE 24-bit byte counters update into
* the u32 value in tcp_sock. As we're processing TCP options, it is
* safe to access from - 1.
*/
static inline s32 tcp_update_ecn_bytes(u32 *cnt, const char *from,
u32 init_offset)
{
u32 truncated = (get_unaligned_be32(from - 1) - init_offset) &
0xFFFFFFU;
u32 delta = (truncated - *cnt) & 0xFFFFFFU;
/* If delta has the highest bit set (24th bit) indicating
* negative, sign extend to correct an estimation using
* sign_extend32(delta, 24 - 1)
*/
delta = sign_extend32(delta, 23);
*cnt += delta;
Annotation
- Immediate include surface: `linux/tcp.h`, `linux/skbuff.h`, `linux/bitfield.h`, `net/inet_connection_sock.h`, `net/sock.h`, `net/tcp.h`, `net/inet_ecn.h`.
- Detected declarations: `enum tcp_ecn_mode`, `enum tcp_accecn_option`, `function INET_ECN_xmit_ect_1_negotiation`, `function tcp_ecn_queue_cwr`, `function tcp_ecn_accept_cwr`, `function tcp_ecn_withdraw_cwr`, `function tcp_accecn_ace_fail_send`, `function tcp_accecn_ace_fail_recv`, `function tcp_accecn_opt_fail_send`, `function tcp_accecn_opt_fail_recv`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.