Skip to content
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

In place encryption and decryption #8

Open
wants to merge 4 commits into
base: LLT-5805_update_timers_periodically
Choose a base branch
from

Conversation

Hasan6979
Copy link

There is an extra copy step that happens during encryption/decryption. That is because boringtun ffi api expects separate buffers for plaintext and encrypted buffers. It is not important for us, so we can encrypt/decrypt in place instead.

Timers are updated on every single packet call, but their
accuracy is limited to 250ms where currentTime is updated.
So just mark timers to update, and update them only once in
update_timers.
// The rate limiter initially checks mac1 and mac2, and optionally asks to send a cookie
let parsed_packet =
match rate_limiter.verify_packet(Some(addr.as_socket().unwrap().ip()), packet, &mut t.dst_buf) {
match rate_limiter.verify_packet(Some(addr.as_socket().unwrap().ip()), &mut t.src_buf, packet_len, &mut t.dst_buf) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe handle the unwrap() case, to avoid panics ..?

@matislovas
Copy link
Contributor

Maybe it is worth to add some benches ..? Or is it done by xray?

@Hasan6979
Copy link
Author

@matislovas benches are there, but they are also a bit under active development. There is CI/tests/performance-tests. Eventually they would also post the results here. For now I will do that for better visibility.

@Hasan6979
Copy link
Author

Results from current branch

ID Role Interval Transfer Bitrate Retransmissions
5 Sender 0.00-120.00 sec 5.19 GBytes 371 Mbits/sec 42,342
5 Receiver 0.00-120.00 sec 5.19 GBytes 371 Mbits/sec N/A
7 Sender 0.00-120.00 sec 5.33 GBytes 381 Mbits/sec 43,285
7 Receiver 0.00-120.00 sec 5.33 GBytes 381 Mbits/sec N/A

Results from main branch

ID Role Interval Transfer Bitrate Retransmissions
5 Sender 0.00-120.00 sec 5.29 GBytes 378 Mbits/sec 45,931
5 Receiver 0.00-120.00 sec 5.28 GBytes 378 Mbits/sec N/A
7 Sender 0.00-120.00 sec 5.12 GBytes 366 Mbits/sec 42,437
7 Receiver 0.00-120.00 sec 5.12 GBytes 366 Mbits/sec N/A

@matislovas
Copy link
Contributor

Results from current branch

ID Role Interval Transfer Bitrate Retransmissions
5 Sender 0.00-120.00 sec 5.19 GBytes 371 Mbits/sec 42,342
5 Receiver 0.00-120.00 sec 5.19 GBytes 371 Mbits/sec N/A
7 Sender 0.00-120.00 sec 5.33 GBytes 381 Mbits/sec 43,285
7 Receiver 0.00-120.00 sec 5.33 GBytes 381 Mbits/sec N/A
Results from main branch

ID Role Interval Transfer Bitrate Retransmissions
5 Sender 0.00-120.00 sec 5.29 GBytes 378 Mbits/sec 45,931
5 Receiver 0.00-120.00 sec 5.28 GBytes 378 Mbits/sec N/A
7 Sender 0.00-120.00 sec 5.12 GBytes 366 Mbits/sec 42,437
7 Receiver 0.00-120.00 sec 5.12 GBytes 366 Mbits/sec N/A

Not much of the improvement performance-vise, but ok ... 😸

@matislovas
Copy link
Contributor

+1

buffer: &'a mut [u8],
data_len: usize,
) -> &'a mut [u8] {
if buffer.len() < data_len + super::DATA_OVERHEAD_SZ {
panic!("The destination buffer is too small");
Copy link
Collaborator

@jjanowsk jjanowsk Dec 16, 2024

Choose a reason for hiding this comment

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

I've experienced reproducible panic in this place when running iperf3 -u -b 500M -i 60 -t 120 -c locally

Copy link
Author

Choose a reason for hiding this comment

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

Looking into it.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed the issue.

Copy link
Contributor

@gytsto gytsto left a comment

Choose a reason for hiding this comment

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

+1

@Hasan6979 Hasan6979 force-pushed the LLT-5816_in_place_encrypt_decrypt branch from 50c35ed to fa0f75f Compare December 17, 2024 13:57
@Hasan6979 Hasan6979 force-pushed the LLT-5805_update_timers_periodically branch from e64f7d8 to d4e74e9 Compare December 18, 2024 13:24
@jjanowsk
Copy link
Collaborator

Neither tests between two physical machines nor CI runs showed any significant improvement. The differences are within 0.5%.

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.

4 participants