Skip to content

Conversation

@millermeares
Copy link

@millermeares millermeares commented Jan 13, 2026

Summary

Relax getsockopt size checking for TCP_INFO whose struct ABI can vary across kernel versions.

Motivation

Some kernel socket options return versioned, kernel-defined structs whose size has grown over time. Older kernels legitimately return fewer bytes and update optlen accordingly, causing strict size == sizeof(T) checks to fail even though the returned data is valid. The problem here is inaccessibility of TCP_INFO from pingora on certain kernel versions.

Change

  • Add an strict flag to get_opt_sized
  • Continue enforcing exact size for fixed-size options, allowing shorter returns only when explicitly opted in by passing strict as false.
  • Opting TCP_INFO into this new behavior.
  • Preserve safety by rejecting any size > sizeof(T)

Notes

When smaller sizes are allowed, zeroed fields may indicate that a field is absent rather than a true zero value. Note that this ambiguity can already exist today: a matching struct size does not guarantee that the kernel provides the same set of fields as the userspace TCP_INFO definition.

@millermeares millermeares changed the title Supporting smaller TCP_INFO shapes by adding an allow_smaller flag to get_opt_sized Supporting smaller TCP_INFO shapes by strict flag to get_opt_sized to optionally relax validation Jan 14, 2026
@millermeares millermeares changed the title Supporting smaller TCP_INFO shapes by strict flag to get_opt_sized to optionally relax validation Supporting smaller TCP_INFO shapes by adding strict flag to get_opt_sized to optionally relax validation Jan 14, 2026
@millermeares millermeares changed the title Supporting smaller TCP_INFO shapes by adding strict flag to get_opt_sized to optionally relax validation Supporting smaller TCP_INFO shapes optionally relaxing get_opt_sized response validation with strict flag Jan 14, 2026
@johnhurt johnhurt added the ergonomics Ease of use, developer friendliness label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ergonomics Ease of use, developer friendliness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants