Skip to content

[inetstack] Bug Fix: Simultaneous close misses FIN resend #1538

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

iyzhang
Copy link
Contributor

@iyzhang iyzhang commented May 1, 2025

This PR closes #1529 and #1537

@iyzhang iyzhang added bug Something Isn't Working confirmed Issue Affects Multiple People labels May 1, 2025
@iyzhang iyzhang requested a review from anandbonde May 1, 2025 17:07
@iyzhang iyzhang self-assigned this May 1, 2025
Copy link

github-actions bot commented May 1, 2025

libos = catnap
commit id = a9db96c

collapsed_stack num_calls cycles_per_call nanoseconds_per_call total_duration percent_total_duration total_duration_exclusive percent_total_duration_exclusive
bgc::catnap::transport::epoll 6454995 4166 1798 2928138535 99 2928138535 99
ioc::network::libos::push 17610 508 208 7843787 0 7843787 0
ioc::network::libos::pop 14846 463 192 5367296 0 5367296 0
ioc::network::libos::connect 50 181574 75514 3529266 0 3529266 0
ioc::network::libos::accept 26 119463 48837 1447115 0 1447115 0
demikernel::sgaalloc 11287 116 48 1138824 0 1138824 0
demikernel::sgafree 11543 62 26 746307 0 746307 0
ioc::network::libos::close 18 23507 9739 337238 0 337238 0
ioc::network::libos::pushto 768 368 165 241305 0 241305 0

Copy link

github-actions bot commented May 1, 2025

libos = catpowder
commit id = a9db96c

collapsed_stack num_calls cycles_per_call nanoseconds_per_call total_duration percent_total_duration total_duration_exclusive percent_total_duration_exclusive
bgc::inetstack::poll;inetstack::layer4::poll_once 19625281 687 277 12432610580 46 12426379664 85
bgc::inetstack::poll 9812641 1586 640 14541186755 54 2108576174 14
ioc::network::libos::push 16256 2961 1210 49564849 0 49564849 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch 5311 3173 1230 6336525 0 6333665 0
bgc::inetstack::tcp::established::background;tcp::established::background::retransmitter 11101 402 161 5324649 0 5324649 0
ioc::network::libos::pop 9047 451 181 3476014 0 3476014 0
bgc::inetstack::tcp::established::background;tcp::established::background::acknowledger 11101 733 285 3154718 0 3154718 0
bgc::inetstack::tcp::established::background 11101 1945 763 12448706 0 3106964 0
ioc::network::libos::pushto 384 5529 2368 1899180 0 1899180 0
ioc::network::libos::connect 42 41810 17142 1757950 0 1757950 0
bgc::inetstack::tcp::passiveopen::background 42 29972 11939 993781 0 993781 0
demikernel::sgaalloc 6503 129 52 880716 0 880716 0
bgc::inetstack::tcp::established::background;tcp::established::background::sender 11047 1024 395 862374 0 862374 0
demikernel::sgafree 8759 79 32 657714 0 657714 0
ioc::network::libos::close 46 2747 1097 70333 0 70333 0
ioc::network::libos::accept 38 2700 1086 62554 0 62554 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch;udp::receive 252 367 157 56244 0 56244 0
bgc::inetstack::arp::background 7 3103 1245 16994 0 16994 0
bgc::inetstack::icmp::background 1 1666 668 1803 0 1803 0

Copy link

github-actions bot commented May 1, 2025

libos = catnip
commit id = a9db96c

collapsed_stack num_calls cycles_per_call nanoseconds_per_call total_duration percent_total_duration total_duration_exclusive percent_total_duration_exclusive
bgc::inetstack::poll;inetstack::layer4::poll_once;catnip::runtime::receive 28877246 200 80 5559437776 19 5559437776 43
bgc::inetstack::poll;inetstack::layer4::poll_once 28877246 372 149 10296657502 36 4732160716 36
bgc::inetstack::poll 14438623 933 374 12935861880 45 2639204378 20
ioc::network::libos::push 16185 1099 446 17932295 0 15712585 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch 2535 3812 1499 5144756 0 5130329 0
bgc::inetstack::tcp::established::background;tcp::established::background::retransmitter 11091 308 124 4475898 0 4474562 0
bgc::inetstack::tcp::established::background;tcp::established::background::acknowledger 11091 428 175 2873800 0 2851860 0
ioc::network::libos::pop 9042 378 152 2820451 0 2820451 0
bgc::inetstack::tcp::established::background 11091 1170 471 10747886 0 2736090 0
ioc::network::libos::push;catnip::runtime::transmit 8777 311 126 2409971 0 2409971 0
ioc::network::libos::connect 42 34191 13773 1431451 0 1374982 0
demikernel::sgaalloc 6503 133 53 716167 0 716167 0
demikernel::sgafree 8759 81 33 669522 0 669522 0
bgc::inetstack::tcp::established::background;tcp::established::background::sender 11037 310 120 662097 0 651369 0
bgc::inetstack::tcp::passiveopen::background 42 26073 10527 625105 0 569882 0
ioc::network::libos::pushto 384 2022 831 560791 0 438157 0
bgc::inetstack::tcp::established::background;tcp::established::background::acknowledger;catnip::runtime::transmit 42 1751 735 136514 0 136514 0
ioc::network::libos::pushto;catnip::runtime::transmit 384 635 260 122634 0 122634 0
ioc::network::libos::close 49 2852 1150 57793 0 57793 0
ioc::network::libos::accept 37 2483 1002 57741 0 57741 0
ioc::network::libos::connect;catnip::runtime::transmit 42 6100 2425 56470 0 56470 0
bgc::inetstack::tcp::passiveopen::background;catnip::runtime::transmit 21 16479 6649 55223 0 55223 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch;udp::receive 221 256 105 51933 0 51933 0
bgc::inetstack::arp::background 7 3342 1342 22278 0 22278 0
bgc::inetstack::poll;inetstack::layer4::poll_once;inetstack::layer4::receive_batch;catnip::runtime::transmit 26 674 271 12418 0 12418 0
bgc::inetstack::tcp::established::background;tcp::established::background::sender;catnip::runtime::transmit 21 605 243 10728 0 10728 0
bgc::inetstack::tcp::established::background;tcp::established::background::retransmitter;catnip::runtime::transmit 16 850 356 8311 0 8311 0
bgc::inetstack::icmp::background 1 1712 688 1842 0 1842 0

Sender::send_ack(cb, layer3_endpoint);
},
state => warn!("Ignoring data received after FIN (in state {:?}).", state),
if data.len() > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should return early by flipping the condition. This will reduce the level of nesting in this function as well.

};
// Store whether the packet has data here because processing it will consume the DemiBuffer.
let has_data: bool = data.len() > 0;
Self::process_data_if_any(cb, layer3_endpoint, data, seg_start, seg_end, seg_len)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this call be avoided by checking has_data above?

layer3_endpoint: &mut SharedLayer3Endpoint,
now: Instant,
) -> Result<(), Fail> {
// Is this a FIN packet?
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment can be removed as the next line is unambiguous.


pub fn get_receive_window_size(&self) -> u32 {
let bytes_unread: u32 = (self.receive_next_seq_no - self.reader_next_seq_no).into();
// The window should be less than 1GB or 64KB without scaling.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to not assume these absolute sizes in the comments. These are susceptible to going stale in case the values of constants change in future.

// This inserts the segment and wakes a waiting pop coroutine.
self.pop_queue.push(temp.1);
}
} else {
Copy link
Contributor

@anandbonde anandbonde May 2, 2025

Choose a reason for hiding this comment

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

This conditional can be inverted to reduce nesting. The indentation level is pretty high in this function. Along with that, it can be broken down into smaller functions if the indentation/nesting still remains high.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something Isn't Working confirmed Issue Affects Multiple People
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test tcp-bad-close is non-deterministic on catnap/windows
2 participants