feat(s2n-quic-dc): enable cbpf for packet filtering - #2967
Conversation
82097e8 to
8d35102
Compare
Why can't we enable this on aarch64? Edit: I see there's a comment saying it's not supported (" This test is Linux x86_64-only because cBPF socket filters are not supported on aarch64.") but that feels unlikely to me. Can we dig into what specific problem we're seeing and hopefully fix it? I'm pretty sure I've used cBPF filters on aarch64 before. |
* move ROUTER into the s2n-quic-dc crate * bind socket with reuse_port as false in tests * address some other comments
* update unit test for buf content checking
* add debug_assert! in bing_udp * don't allow port 0 when resuse port is true
This reverts commit 42b7173.
1f4891f to
859a95a
Compare
859a95a to
49efdb0
Compare
* redirect router to a sparate module
2db873e to
8071584
Compare
* apply gro and tos for all
8071584 to
e550dfe
Compare
7498b53 to
4feaef7
Compare
|
To address #2967 (comment), I implemented a socket polling prioritization: we prioritize socket 1 which handles non-client hello socket over the other socket. To test this feature, I added a The result is this: The test without socket scheduling prioritization: With socket scheduling, socket 1 will receive about 6 times more packets than socket 0, while without it, both sockets receive approximately the same number of packets. The CI ubuntu image is running slower than my local machine. Hence, I loosen the requirement for a bit. Requiring socket 1 to receive more than three times packets than socket 0. |
ddd65a1 to
f10457a
Compare
40cd4d9 to
fd3cf04
Compare
ceec61a to
8683ce8
Compare
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #[cfg(target_os = "linux")] |
There was a problem hiding this comment.
This PR is now implementing three separate features AFAICT:
- Adds the ability for s2n-quic to read packets from multiple sockets
- Adds the ability for s2n-quic to drain one socket before moving on to the next socket.
- Adds a packet filter to dc-quic's handshake sockets so that Initial packets get processed in a different port than the rest of the packets.
I don't agree with the decision to put all of these in the same PR, because it makes it difficult to tell if you've tested everything sufficiently. I would probably put feature 1 and 2 in the same PR, since those are making changes to s2n-quic, and then do a different PR for 3, since it is only touching dc-quic.
* add a check for socket 1 and 0 for receiving no more packets * remove unnecessary timeout for waiting * update the out of date comments for priority scheduling test
|
#3026 will finish what this PR is trying to do. |
Release Summary:
Implement a cbpf packet filtering for dcQUIC. This is an attempt to reduce dcQUIC handshake latency.
Resolved issues:
resolves #2954. resolves #2735.
Description of changes:
Implement a
ROUTERto filter server's incoming packets into two sockets:The instruction for the router is to load the first and the sixth byte and check if the first byte is 1100 and the six byte is exactly 8 bytes. Refer to https://www.rfc-editor.org/rfc/rfc9000.html#name-initial-packet for more information about packet structure:
s2n-quic uses 8 bytes CID when the client sends Client Hello to the server, and that's why we are checking the eight bytes CID length.
s2n-quic/quic/s2n-quic-transport/src/endpoint/mod.rs
Lines 1125 to 1136 in 8c64e04
I also restructured the tokio builder for the
rx_socketfield to takes an array of sockets and allowwith_rx_socketto append sockets torx_socketsarray instead of override the existing socket.After those changes are tested and verified, I make s2n-quic-dc's server endpoint to always use packet filtering features.
Also: #2967 (comment).
Call-outs:
s2n-quic/quic/s2n-quic-platform/src/lib.rs
Lines 11 to 12 in 8c64e04
s2n-quic-platformcrate. That would requires me to import s2n-quic as a dev-dependency. That shouldn't cause any problem for production code and release.Testing:
This test primarily test the functionality of the
ROUTER. I constructed three packets (1 client hello packet and two other packets). We verified that the first packet should be route to socket 0 and the other two should be routed to socket* Integration test: router_multi_socket_server_client_testUse tokio runtime to construct s2n-quic server and client. The server should call
.with_rx_sockettwice to attach two sockets to the router and the handshake should succeed.PlatformRxSocketStatsevent to track the number of packets routed to a socket. With this event, I added another integration testclient_hello_routed_test.dc_server_packet_filtering_load_test: this test simulate a dcQUIC client tries to connect with a dcQUIC server, while a packet generator flood the server withEXAMPLE_CLIENT_INITIAL_PROTECTED_PACKET. With packet filtering, the actual handshake should still succeed. I ran this test before the this feature was implemented, and the test will fail: main...boquan-fang:s2n-quic:before-packet-filtering.load_test.log
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.