GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — Fix UDP_GRO segment size is lost when reading with recvmmsg by octa-one · Pull Request #17492 · netty/netty Conversation
|
|
@octa-one did you sign our icla yet ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes, already signed it |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It looks like the leak detectors are also flagging an issue from the second PR #17493, so I will add that commit here so we can rerun the tests |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
### Motivation: When recvmmsg returns a single message, the single packet fast path creates a DatagramPacket, which retains a slice of the receive buffer. If that packet is an UDP_GRO batch (SegmentedDatagramPacket), it falls through to the loop, which creates the packet again and the first one is never released. It is related to #17492. After this PR every `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` will be affected. Today this requires `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` and `IP_RECVORIGDSTADDR` set together. ### Modification: Release the fast path packet before falling through to the loop ### Result: No receive buffer leak when recvmmsg returns a single UDP_GRO batch.
There was an error while loading. Please reload this page.
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Failed Jobs without Test Failures❌ Build PR / macos-x86_64-java11-boringssl build Test SummaryBuild PR / linux-x86_64-java11-boringssl-jdk8-tests build > Netty/Buffer
🏷️ Commit: d6a91a4 Test FailuresReadOnlyByteBufferBufTest > testDuplicateBytesInArrayMultipleThreads() (Netty/Buffer in Build PR / linux-x86_64-java11-boringssl-jdk8-tests build)Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…atch (#17500) Auto-port of #17493 to 4.1 Cherry-picked commit: 8ffa436 --- ### Motivation: When recvmmsg returns a single message, the single packet fast path creates a DatagramPacket, which retains a slice of the receive buffer. If that packet is an UDP_GRO batch (SegmentedDatagramPacket), it falls through to the loop, which creates the packet again and the first one is never released. It is related to #17492. After this PR every `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` will be affected. Today this requires `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` and `IP_RECVORIGDSTADDR` set together. ### Modification: Release the fast path packet before falling through to the loop ### Result: No receive buffer leak when recvmmsg returns a single UDP_GRO batch. Co-authored-by: Alexander Mitropolsky <[email protected]>
…atch (#17502) Auto-port of #17493 to 5.0 Cherry-picked commit: 8ffa436 --- ### Motivation: When recvmmsg returns a single message, the single packet fast path creates a DatagramPacket, which retains a slice of the receive buffer. If that packet is an UDP_GRO batch (SegmentedDatagramPacket), it falls through to the loop, which creates the packet again and the first one is never released. It is related to #17492. After this PR every `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` will be affected. Today this requires `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` and `IP_RECVORIGDSTADDR` set together. ### Modification: Release the fast path packet before falling through to the loop ### Result: No receive buffer leak when recvmmsg returns a single UDP_GRO batch. Co-authored-by: Alexander Mitropolsky <[email protected]>
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Port for 4.1: #17506 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Port for 5.0: #17507 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…7492) (#17507) With EpollChannelOption.UDP_GRO enabled, the kernel coalesces same size datagrams and reports the segments size in a control message, which EpollDatagramChannel turns into a SegmentedDatagramPacket to split later. This works with recvmsg, which always passes a control buffer, but not with recvmmsg. recvmmsg0 only provided control buffers with `IP_RECVORIGDSTADDR` enabled (checked with a additional syscall getsockopt on every call) Without control buf the kernel drops the control message (setting MSG_CTRUNC, which is not checked), so a coalesced batch is delivered as a single DatagramPacket holding all of its segments. Notably, the existing GRO tests dont set `MAX_DATAGRAM_PAYLOAD_SIZE`, so tests only run recvmsg path. - recvmmsg0 allocates a control buffer for every message, sized as in recvmsg0 and frees it on the early return path. Per call getsockopt for `IP_RECVORIGDSTADDR` is removed. - init_packet consider the control segment size as an int ([as the kernel actually writes](https://github.com/torvalds/linux/blob/f6e7b42bf05b2427fb8a7a1d1c387a86638bb413/include/linux/udp.h#L185)). Otherwise, there could be problems when reading on bigendian systems. - Add a test for recvmmsg path. GSO send to a GRO socket whose receive buffer holds two batches, so the batch is read with recvmmsg, checking that every segment arrives separately. GRO batches read through recvmmsg are correctly split into their segments. When no receive options are enabled the kernel leaves the control buffers untouched and each recvmmsg call saves a getsockopt syscall. The new test fails on 4.2 and passes with this change. Co-authored-by: Alexander Mitropolsky <[email protected]>
…7492) (#17506) With EpollChannelOption.UDP_GRO enabled, the kernel coalesces same size datagrams and reports the segments size in a control message, which EpollDatagramChannel turns into a SegmentedDatagramPacket to split later. This works with recvmsg, which always passes a control buffer, but not with recvmmsg. recvmmsg0 only provided control buffers with `IP_RECVORIGDSTADDR` enabled (checked with a additional syscall getsockopt on every call) Without control buf the kernel drops the control message (setting MSG_CTRUNC, which is not checked), so a coalesced batch is delivered as a single DatagramPacket holding all of its segments. Notably, the existing GRO tests dont set `MAX_DATAGRAM_PAYLOAD_SIZE`, so tests only run recvmsg path. - recvmmsg0 allocates a control buffer for every message, sized as in recvmsg0 and frees it on the early return path. Per call getsockopt for `IP_RECVORIGDSTADDR` is removed. - init_packet consider the control segment size as an int ([as the kernel actually writes](https://github.com/torvalds/linux/blob/f6e7b42bf05b2427fb8a7a1d1c387a86638bb413/include/linux/udp.h#L185)). Otherwise, there could be problems when reading on bigendian systems. - Add a test for recvmmsg path. GSO send to a GRO socket whose receive buffer holds two batches, so the batch is read with recvmmsg, checking that every segment arrives separately. GRO batches read through recvmmsg are correctly split into their segments. When no receive options are enabled the kernel leaves the control buffers untouched and each recvmmsg call saves a getsockopt syscall. The new test fails on 4.2 and passes with this change. Co-authored-by: Alexander Mitropolsky <[email protected]>
…atch (netty#17500) Auto-port of netty#17493 to 4.1 Cherry-picked commit: 8ffa436 --- ### Motivation: When recvmmsg returns a single message, the single packet fast path creates a DatagramPacket, which retains a slice of the receive buffer. If that packet is an UDP_GRO batch (SegmentedDatagramPacket), it falls through to the loop, which creates the packet again and the first one is never released. It is related to netty#17492. After this PR every `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` will be affected. Today this requires `UDP_GRO` + `MAX_DATAGRAM_PAYLOAD_SIZE` and `IP_RECVORIGDSTADDR` set together. ### Modification: Release the fast path packet before falling through to the loop ### Result: No receive buffer leak when recvmmsg returns a single UDP_GRO batch. Co-authored-by: Alexander Mitropolsky <[email protected]>
…tty#17492) (netty#17506) With EpollChannelOption.UDP_GRO enabled, the kernel coalesces same size datagrams and reports the segments size in a control message, which EpollDatagramChannel turns into a SegmentedDatagramPacket to split later. This works with recvmsg, which always passes a control buffer, but not with recvmmsg. recvmmsg0 only provided control buffers with `IP_RECVORIGDSTADDR` enabled (checked with a additional syscall getsockopt on every call) Without control buf the kernel drops the control message (setting MSG_CTRUNC, which is not checked), so a coalesced batch is delivered as a single DatagramPacket holding all of its segments. Notably, the existing GRO tests dont set `MAX_DATAGRAM_PAYLOAD_SIZE`, so tests only run recvmsg path. - recvmmsg0 allocates a control buffer for every message, sized as in recvmsg0 and frees it on the early return path. Per call getsockopt for `IP_RECVORIGDSTADDR` is removed. - init_packet consider the control segment size as an int ([as the kernel actually writes](https://github.com/torvalds/linux/blob/f6e7b42bf05b2427fb8a7a1d1c387a86638bb413/include/linux/udp.h#L185)). Otherwise, there could be problems when reading on bigendian systems. - Add a test for recvmmsg path. GSO send to a GRO socket whose receive buffer holds two batches, so the batch is read with recvmmsg, checking that every segment arrives separately. GRO batches read through recvmmsg are correctly split into their segments. When no receive options are enabled the kernel leaves the control buffers untouched and each recvmmsg call saves a getsockopt syscall. The new test fails on 4.2 and passes with this change. Co-authored-by: Alexander Mitropolsky <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.