Summary

  • RFC 3542 drew a hard line between sticky, socket-wide IPv6 options and ancillary control data attached to a single UDP or raw datagram. A per-message item overrides only the sticky option of the same name; every unrelated default keeps standing.
  • The scope has edges: a zero-length item switches one option off for one packet, receives already queued may lack newly requested metadata, and TCP cannot copy the model because one send call is not one segment.

A UDP socket is a creature of habit. It has been told which interface to leave by, what traffic class to wear, how to treat extension headers—standing orders, set once, expected to hold for every datagram it will ever carry. Then one message needs a different routing header. The lazy implementation treats the exception as a regime change: the packet gets its special route and quietly loses three policies nobody meant to touch. The packet arrives. The intent does not.

RFC 3542, published in May 2003 as Advanced Sockets Application Program Interface (API) for IPv6, is the document that refused the regime change. Informational rather than a wire standard, it governs the seam between application and kernel—how software asks for packet information, extension headers, hop limits, next hops, traffic class and Path MTU behaviour without hand-assembling every IPv6 byte.

Two surfaces, one boundary

The spec describes two ways to send. setsockopt() sets a “sticky” option for the socket, colouring transmitted packets until the application says otherwise. Ancillary data handed to sendmsg() speaks for exactly one datagram on UDP or a raw socket. One surface writes the standing order; the other files a single-message exception.

Section 4.2: the exception gets one cell, not the building

The decisive rule sits in section 4.2. An ancillary item overrides a sticky option only when the two share an option name. A per-datagram IPV6_RTHDR replaces the sticky routing header for that datagram and leaves a sticky destination option, packet-information choice and everything else exactly where it was. The exception is granted authority over the cell it names—not over the socket.

That was a deliberate break from RFC 2292. The older API let sticky options be set as one bundle, so supplying ancillary data replaced the bundle wholesale. RFC 3542 split the collection into individually addressable options, and once state became addressable one field at a time, the override rule became scoped one field at a time. The lesson outlives sockets: an API’s data model quietly decides how much collateral damage every update will do.

The zero that means “not this one”

The design even permits an explicit absence. With a sticky IPV6_HOPOPTS in place, a zero-length ancillary item of that type suppresses the Hop-by-Hop options header for one outgoing packet. The zero is not “forget everything.” It is a typed instruction: omit this feature, in this message, once. The next datagram returns to the sticky value without rebuilding the rest of the socket’s policy.

Receiving: when “missing” has two histories

Receiving runs on a different clock. The application first enables the relevant IPV6_RECVxxx options; recvmsg() then hands back whatever ancillary objects the packet carried. No routing header, no object. But RFC 3542 also warns that packets already sitting in the queue when the receive option is switched on may not carry the newly requested information. So absent metadata has at least two possible histories: the wire feature was never there, or the observation started too late. Only one of those is a fact about the network.

Why TCP cannot inherit the trick

TCP marks the boundary. The document defines no per-send ancillary transmission for TCP, because application send calls and transmitted segments have no one-to-one correspondence. Sticky options exist; retransmitted segments may or may not carry information set after the original send. Received optional information is likewise undefined, and the RFC is blunt that it could not be used for access control the way a UDP or raw-socket programmer might assume. Packet-scoped intent needs actual packet scope.

Receipts, not certificates

Checksums keep the same discipline. The kernel verifies the mandatory ICMPv6 checksum and drops failures; it may run further checks, but a portable application must not assume they happened. “Checksum accepted” is a receipt for one calculation, not a certificate that every field is meaningful or authorised.

Buffer construction repeats the lesson at a smaller scale. CMSG_SPACE includes the room alignment and allocation demand; CMSG_LEN is the length stored in the ancillary header, trailing padding excluded. Reserved and logical are related, not interchangeable. Confuse them and a correct payload ends up in an incorrectly described envelope.

Old examples, present-day labels

History needs honest dating. RFC 3542 inherited an IPv6 Routing Header Type 0 example from the RFC 2460 era. RFC 8200 is now the base specification and does not keep Type 0 as current guidance. The example remains evidence about the API functions and their moment—not a recommendation to deploy a retired routing mechanism.

So this account stops short of general extension-header policy, Path MTU algorithms and forwarding. It owns one control-scope transition: RFC 2292’s set-wide replacement became RFC 3542’s same-name override, with a typed one-packet disable and honest limits wherever observation or segmentation breaks the analogy.

There is a larger instinct here, and it is the one that keeps showing up wherever systems are governed well: give an exception the smallest scope that names it, leave untouched state untouched, and let the running thing—not the paperwork about it—decide what is true. A rule that lets one unusual packet rewrite the whole socket is not a convenience. It is a policy decision smuggled in as an implementation detail.

Four layers, recorded separately

The durable operational rule is to log four layers apart: the socket default before the call, the ancillary exception supplied for the datagram, the packet the kernel actually emitted, and the result observed downstream. A successful sendmsg() proves only that the interface accepted a request. Running evidence shows which packet left and what became of it. Narrow overrides protect the defaults; provenance protects the truth.

Sources