-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
net: add setTypeOfService and getTypeOfService to Socket #61503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. Can you add the documentation?
|
Thanks @mcollina , is this ready to be merged? Please let me know if there is anything else you need me to adjust. |
42d5142 to
c0407b2
Compare
|
@mcollina I'm confused by the CI failures. Any ideas? Or just flaky? |
i guess you are right @ronag |
|
and also i have observed some flaky ci tests here, should i report them as issues? or just paste them here so the internal team fixed them?? |
|
libuv/libuv#2536 |
|
@ronag after inspecting some of errors in ci, i rolled some changes, kindle approve the ci once again so i can futher improve the checks |
|
What does TOS stand for? |
|
doc/api/net.md
Outdated
| @@ -1461,6 +1461,45 @@ If `timeout` is 0, then the existing idle timeout is disabled. | |||
| The optional `callback` parameter will be added as a one-time listener for the | |||
| [`'timeout'`][] event. | |||
|
|
|||
| ### `socket.getTOS()` | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our API names in Node.js are generally more verbose than the corresponding OS APIs – would there be anything speaking against calling these socket.getTypeOfService() and socket.setTypeOfService()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense and i agree to that, i will update to use full names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@addaleax i have used full names now, check the latest changes
| } else { | ||
| args.GetReturnValue().Set(uv_translate_sys_error(errno)); | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't say this needs to block this PR, but upstreaming these additions to https://github.com/libuv/libuv might be a good follow-up change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even i was thinking the same, if internal members of nodejs will work and do the changes over there to libuv, then additions will be fast, rather than i do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can open an issue there pointing to this PR, that will help and maybe someone picks it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@santigimeno i already made an issue there, and a member of libuv is working on that, untill that, we could make a todo here in the cpp code to track the isssue and its relevant pr, and will update the libuv api, once it is rolled out. i looked a long on recent issues, prs whch got merged and i saw that it took a lot of time, but as we need to roll out this feature soon in the next minor version, we could consider forward looking at this pr so that we could easily bring the feature
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61503 +/- ##
==========================================
- Coverage 89.82% 88.88% -0.94%
==========================================
Files 667 672 +5
Lines 203693 203928 +235
Branches 39163 39129 -34
==========================================
- Hits 182963 181259 -1704
- Misses 13061 14933 +1872
- Partials 7669 7736 +67
🚀 New features to boost your workflow:
|
ac01361 to
2bb4591
Compare
|
@ronag kindly approve once again, i fixed the issue related to win vs2022 build error on my win laptop, and also i tested it here. i guess it should work, rest the rhel and linuxone test failures are flaky, i confirmed it by looking the console logs. also i added a todo for the libuv in future. as i saw it will take time for the required api in the libuv. |
this PR implements
socket.setTOS(tos)andsocket.getTOS()innet.Socket. it needed this to support DSCP tagging (QoS) for traffic prioritization, which wasn't previously exposed in the JS API. for the implementation:tcp_wrap.ccto attemptIP_TOSfirst, and fallback toIPV6_TCLASSif that fails. This handles both IPv4 and IPv6 sockets automatically without needing a separate flag.UV_ENOSYSfor now since the headers/implementation differ there.test-net-socket-tos.js) to verify input validation and ensure the values are actually set on supported platforms.Fixes: #61489