Skip to content

Add support for Unix domain datagram sockets when using native epoll/kqueue transport#11423

Merged
normanmaurer merged 9 commits into
netty:4.1from
violetagg:uds-dgram
Jul 9, 2021
Merged

Add support for Unix domain datagram sockets when using native epoll/kqueue transport#11423
normanmaurer merged 9 commits into
netty:4.1from
violetagg:uds-dgram

Conversation

@violetagg
Copy link
Copy Markdown
Member

Motivation:

There are use cases when Unix domain datagram sockets are needed for communication. This PR adds such support for Epoll/KQueue.

Modification:

  • Expose Channel, Config and Packet interfaces/classes for Unix domain datagram sockets. All interfaces/classes are in transport-native-unix-common module in order to be available for KQueue and Epoll implementations
  • Add JNI code for Unix domain datagram sockets
  • Refactor DatagramUnicastTest so that it can be used for testing also Unix domain datagram sockets
  • Add Unix domain datagram sockets implementation for KQueue transport
  • Add Unix domain datagram sockets implementation for Epoll transport

Result:

Fixes #6737

@violetagg
Copy link
Copy Markdown
Member Author

Here are some notes for the current implementation:

  1. I tried to separate the changes on logical commit so that it is easier for a review.

  2. There isn't File descriptor support:

  • what might be the use case?
  • there is a possibility the packet to be discarded.
  1. There is no disconnect support as I wasn't able to have it working with AF_UNSPEC for both KQueue and Epoll

Copy link
Copy Markdown
Member

@chrisvest chrisvest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some random comments from a quick glance. Haven't done a full review.

@normanmaurer
Copy link
Copy Markdown
Member

@violetagg can you please rebase ?

@violetagg
Copy link
Copy Markdown
Member Author

The build on Windows failed with the one below, I'm not sure how this is related to this change

2021-07-05T09:07:34.2974217Z [ERROR] Failures: 
2021-07-05T09:07:34.2976021Z [ERROR]   JdkOpenSslEngineInteroptTest>SSLEngineTest.testMutualAuthDiffCerts:582->SSLEngineTest.runTest:1191->SSLEngineTest.writeAndVerifyReceived:1220
2021-07-05T09:07:34.2979428Z [INFO] 
2021-07-05T09:07:34.2980299Z [ERROR] Tests run: 12074, Failures: 1, Errors: 0, Skipped: 344

@normanmaurer
Copy link
Copy Markdown
Member

@violetagg yeah the test-failure was observed before... trying to reproduce it as well

@normanmaurer normanmaurer requested a review from chrisvest July 8, 2021 12:03
Copy link
Copy Markdown
Member

@normanmaurer normanmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mostly fine... Just a few comments

@normanmaurer
Copy link
Copy Markdown
Member

normanmaurer commented Jul 8, 2021 via email

@normanmaurer
Copy link
Copy Markdown
Member

@violetagg can you rebase this one ?

violetagg added 9 commits July 9, 2021 08:22
…datagram sockets

All interfaces/classes are in transport-native-unix-common module in order to be available for KQueue and Epoll impl
Motivation:

Move INET related test in a separate test class, with that change DatagramUnicastTest can be used
for testing also Unix domain datagram sockets.

Modifications:

- Move DatagramUnicastTest#testBindWithPortOnly to DatagramUnicastInetTest.
- Adapt DatagramUnicastIPv6Test, EpollDatagramUnicastTest and KQueueDatagramUnicastTest
to inherit the new test class.
- testBindWithPortOnly(Bootstrap, Bootstrap) method tests only with the second parameter - remove
from the signature the first parameter. Make the method private and static.

Result:

DatagramUnicastTest can be used for testing also Unix domain datagram sockets.
Make DatagramUnicastTest an abstract class
According to https://man7.org/linux/man-pages/man7/unix.7.html
SO_RCVBUF option does not effect for UNIX domain sockets

"The SO_SNDBUF socket option does have an effect for UNIX domain
sockets, but the SO_RCVBUF option does not."
Make the helper test methods private
@violetagg
Copy link
Copy Markdown
Member Author

@violetagg can you rebase this one ?

ok, rebased

@trustin
Copy link
Copy Markdown
Member

trustin commented Jul 9, 2021

I went over the PR and it seems good to me. Didn't have enough time to review every single line, though. One concern is we have quite a bit of duplication across the channel implementation such as spinning I/O, but that's probably something that has to be handled in other place.

@normanmaurer
Copy link
Copy Markdown
Member

@trustin yeah I think this is something to fix later on.

@violetagg
Copy link
Copy Markdown
Member Author

I went over the PR and it seems good to me. Didn't have enough time to review every single line, though. One concern is we have quite a bit of duplication across the channel implementation such as spinning I/O, but that's probably something that has to be handled in other place.

I refrained from doing a big refactoring because it would complicate the review process

@normanmaurer normanmaurer added this to the 4.1.66.Final milestone Jul 9, 2021
@normanmaurer normanmaurer merged commit 3f9a5f5 into netty:4.1 Jul 9, 2021
@normanmaurer
Copy link
Copy Markdown
Member

@violetagg thanks a lot!

@violetagg
Copy link
Copy Markdown
Member Author

violetagg commented Jul 9, 2021

@chrisvest @trustin @normanmaurer Thank you very much! 🎉 🚀

@normanmaurer
Copy link
Copy Markdown
Member

@violetagg I tried to port this over to master but I have some failing tests... Not sure yet why :/

@violetagg
Copy link
Copy Markdown
Member Author

@violetagg I tried to port this over to master but I have some failing tests... Not sure yet why :/

Should I try?

@normanmaurer
Copy link
Copy Markdown
Member

normanmaurer commented Jul 9, 2021 via email

@violetagg
Copy link
Copy Markdown
Member Author

Yes please

ok let me give it a try

@violetagg violetagg deleted the uds-dgram branch July 9, 2021 15:20
@violetagg
Copy link
Copy Markdown
Member Author

@normanmaurer I opened this PR #11476
Let's see whether the tests will be OK (on my side they are passing)

raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
…kqueue transport (netty#11423)

Motivation:

There are use cases when Unix domain datagram sockets are needed for communication. This PR adds such support for Epoll/KQueue.

Modification:

- Expose Channel, Config and Packet interfaces/classes for Unix domain datagram sockets. All interfaces/classes are in `transport-native-unix-common` module in order to be available for KQueue and Epoll implementations
- Add JNI code for Unix domain datagram sockets
- Refactor `DatagramUnicastTest` so that it can be used for testing also Unix domain datagram sockets
- Add Unix domain datagram sockets implementation for KQueue transport
- Add Unix domain datagram sockets implementation for Epoll transport

Result:

Fixes netty#6737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support DGRAM unix domain socket

4 participants