Repository navigation
feat(link): add the so_priority endpoint option for TCP and TLS links - #2881
Open
ciprianf-flexion wants to merge 1 commit into
Open
ciprianf-flexion wants to merge 1 commit into
ciprianf-flexion wants to merge 1 commit into
Conversation
Adds the `so_priority` endpoint option. It sets the Linux socket priority (SO_PRIORITY) of TCP and TLS links. On a connect endpoint, a value applies to the link of that endpoint. On a listen endpoint, `<range>:<priority>` entries choose the value by the priority range of each accepted link, e.g. `so_priority=0-5:6|6-7:0`, and a value without a range applies to all other links. Both sides apply the value after the transport handshake, when the range of the link is known. A value the process may not set (above 6 without CAP_NET_ADMIN) fails when the endpoint is created. On other platforms the option is ignored with a warning. On NICs or qdiscs that select the TX queue or band from the socket priority, the real-time link of a multilink transport then no longer waits behind bulk data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Alexandru Farcasanu <ciprianfarcasanu@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2881 +/- ##
==========================================
+ Coverage 74.95% 74.97% +0.01%
==========================================
Files 419 420 +1
Lines 64143 64284 +141
==========================================
+ Hits 48080 48197 +117
- Misses 16063 16087 +24 ☔ View full report in Codecov by Harness. |
ciprianf-flexion
marked this pull request as ready for review
October 26, 2026 12:25
Contributor
Author
|
@DenisBiryukov91 could you please take a look? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is an alternative to #2854 (set the socket priority of multilink links from their priority range). It follows the suggestion of @DenisBiryukov91 in #2854: the value is set on the endpoint, not in a global map. Both PRs solve the same problem, so only one of them should be merged.
What does this PR do?
so_priorityendpoint option for TCP and TLS links. It sets the Linux socket priority (SO_PRIORITY) of the link.tcp/192.0.2.1:7447?prio=0-5#so_priority=6.tcp/0.0.0.0:7447#so_priority=0-5:6|6-7:0.<range>:<priority>applies to the links whose range is within<range>.CAP_NET_ADMIN. On other platforms, the option logs a warning and does nothing.Implementation:
zenoh-link-commonsparses the option and has a smallsetsockopthelper. The workspace socket2 0.5 has noset_priority.LinkUnicastTrait::apply_socket_priorityreceives the priority range of the link. The default does nothing. The transport calls it inopen_linkandaccept_link.Why is this change needed?
Multilink with
?prio=splits traffic over separate TCP connections, for example?prio=0-5for real-time data and?prio=6-7for bulk data. But on the sending host, both connections can still share one NIC TX ring. A small real-time message that enters the ring after bulk data must wait until the NIC has sent all of that bulk data. At 1 Gbit/s, 1 MB of bulk data in the ring delays the next real-time packet by up to 8 ms.Many multi-queue NIC drivers choose the TX ring from the socket priority, for example the NVIDIA Jetson
nvethernetdriver. Measured between a Jetson AGX Orin and an x86 host over 1 Gbit/s, with a 400 Hz probe and a 1.73 MB payload at 30 Hz demoted todata_low:Both ends of a link send data, so both ends need a value. The accepting side cannot use one value per listener:
SO_PRIORITYfrom the listening socket to an accepted socket.So the listener keeps its option and applies it to each accepted link when the range of that link is known.
Differences from #2854
transport.link.tx.socket_prioritymap#so_priorityon each endpoint#so_prioritypartNote: as for
#dscp, a#option on a connect endpoint currently prevents the reconnect of a single dropped multilink link, see #2569. With #2854 the endpoint string does not change, so it is not affected.How was it tested?
unicast_socket_priority, for TCP and TLS:SO_PRIORITYback on both ends of both links.#so_priority=0-5:7, withoutCAP_NET_ADMIN, stopszenohdat startup with an error that namesso_priority.cargo clippy --all-targets --features test -- --deny warnings, theuringvariant and the nightlyrustfmtcheck pass.Related Issues
Alternative to #2854. Related to #2569.
🤖 Generated with Claude Code
🏷️ Label-Based Checklist
No specific label requirements detected.
Current labels: No labels
Add one of these labels to this PR to see relevant checklist items:
api-sync,breaking-change,bug,ci,dependencies,documentation,enhancement,new feature,internalThis section updates automatically when labels change.