-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass implementation of XDP I/O loop (#1066)
This PR is the real meat of the XDP implementation, the I/O loop. The setup of the memory, sockets, and rings is done in the root xdp module, along with the spawning of one (named) thread per NIC queue, the actual packet processing code is in the xdp/process module. This split of code allows much easier testing, since we can just have a Umem (memory map) and don't need to do any actual I/O. For the sake of simplicity in this initial pass I decided not to share any code at all with the current sessionpool, instead opting for a more minimal approach to pairing client <-> server sessions by having a single TTL map for all servers, where each unique client gets its own port in the range of valid ephemeral ports that Linux itself doesn't assign, which gives 4535 unique clients per server, so the TTL applies to the server instead of each individual client. Other than that difference, the only thing different about XDP versus the other implementations is that packets need to parsed manually when received to pull out the source information, and, unless being routed to multiple servers, the packet is then modified inline and queued for sending with the new source and destination information as determined by the filters.
- Loading branch information
1 parent
a4b302a
commit 0dcfd9b
Showing
15 changed files
with
2,233 additions
and
108 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
93 changes: 93 additions & 0 deletions
93
crates/test/tests/snapshots/xdp__changes_ip_version-2.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
source: crates/test/tests/xdp.rs | ||
expression: "&packet_headers" | ||
--- | ||
PacketHeaders { | ||
link: Some( | ||
Ethernet2( | ||
Ethernet2Header { | ||
source: [ | ||
4, | ||
4, | ||
4, | ||
4, | ||
4, | ||
4, | ||
], | ||
destination: [ | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
], | ||
ether_type: 0x0800 (Internet Protocol version 4 (IPv4)), | ||
}, | ||
), | ||
), | ||
vlan: None, | ||
net: Some( | ||
Ipv4( | ||
Ipv4Header { | ||
dscp: Ipv4Dscp( | ||
0, | ||
), | ||
ecn: Ipv4Ecn( | ||
0, | ||
), | ||
total_len: 39, | ||
identification: 0, | ||
dont_fragment: false, | ||
more_fragments: false, | ||
fragment_offset: IpFragOffset( | ||
0, | ||
), | ||
time_to_live: 63, | ||
protocol: 17 (UDP - User Datagram), | ||
header_checksum: 0, | ||
source: [ | ||
2, | ||
2, | ||
2, | ||
2, | ||
], | ||
destination: [ | ||
5, | ||
5, | ||
5, | ||
5, | ||
], | ||
options: [], | ||
}, | ||
Ipv4Extensions { | ||
auth: None, | ||
}, | ||
), | ||
), | ||
transport: Some( | ||
Udp( | ||
UdpHeader { | ||
source_port: 7777, | ||
destination_port: 8888, | ||
length: 19, | ||
checksum: 1511, | ||
}, | ||
), | ||
), | ||
payload: Udp( | ||
[ | ||
241, | ||
241, | ||
241, | ||
241, | ||
241, | ||
241, | ||
241, | ||
241, | ||
241, | ||
241, | ||
241, | ||
], | ||
), | ||
} |
Oops, something went wrong.