Skip to content

Attaching ECN on send erases the socket's DSCP #5

Closed

Description

@aotodev

Problem

ecn::build writes the bare ECN bits as the IP_TOS / IPV6_TCLASS control
message. The kernel uses that value as the whole traffic-class byte for the
datagram (ip_cmsg_send: ipc->tos = val), which overrides whatever DSCP the
socket was given with setsockopt(IP_TOS).

Repro: sender with setsockopt(IP_TOS, 0xb8) (EF), control ecn = ect0. The raw
TOS on the wire is 0x02, not 0xba.

Proposed fix

Pick one:

  • Carry DSCP alongside ECN in the transmit control, for example a traffic_class
    feature whose value holds both fields, with ecn as a convenience on top.
  • Let a socket option record the DSCP at open time, and have ecn::build OR it
    in. This needs somewhere to keep it, which the stateless feature design does
    not have today.
  • At minimum, document on ecn and in docs/metadata.md that sending with it
    resets DSCP to zero.

Acceptance

A test that sets DSCP and sends with ECN observes both on the wire.

Activity

  1. self-assigned this
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions