-
Notifications
You must be signed in to change notification settings - Fork 673
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
TCP reassembly - support closing connection with FIN + RST on one side #1496
Changes from 2 commits
53f39a4
3e39f78
b285e0d
80a444e
ea6d385
83e38f9
f07c629
a1f3495
5da4f20
5dfdd6c
4220df7
1671b7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,11 @@ TcpReassembly::ReassemblyStatus TcpReassembly::reassemblePacket(Packet& tcpData) | |
if (tcpReassemblyData->twoSides[sideIndex].gotFinOrRst) | ||
{ | ||
PCPP_LOG_DEBUG("Got a packet after FIN or RST were already seen on this side (" << static_cast<int>(sideIndex) << "). Ignoring this packet"); | ||
if (!tcpReassemblyData->twoSides[1 - sideIndex].gotFinOrRst && isRst) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not very familiar with this piece of code, could you explain why it's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1-sideIndex is mean other side tcp stream,the sideIndex's value maybe 0 or 1. |
||
{ | ||
handleFinOrRst(tcpReassemblyData, 1 - sideIndex, flowKey, isRst); | ||
return FIN_RSTWithNoData; | ||
} | ||
return Ignore_PacketOfClosedFlow; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1264,3 +1264,36 @@ PTF_TEST_CASE(TestTcpReassemblyTimeStamps) | |
packetStream.clear(); | ||
tcpReassemblyResults.clear(); | ||
} // TestTcpReassemblyTimeStamps | ||
|
||
PTF_TEST_CASE(TestTcpReassemblyFinishReset) | ||
{ | ||
TcpReassemblyMultipleConnStats results; | ||
std::string errMsg; | ||
|
||
pcpp::TcpReassemblyConfiguration config(true, 2, 1); | ||
pcpp::TcpReassembly tcpReassembly(tcpReassemblyMsgReadyCallback, &results, tcpReassemblyConnectionStartCallback, | ||
tcpReassemblyConnectionEndCallback, config); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a better approach would be to call
|
||
|
||
std::vector<pcpp::RawPacket> packetStream; | ||
PTF_ASSERT_TRUE( | ||
readPcapIntoPacketVec("PcapExamples/one_tcp_stream_fin_rst_close_packet.pcap", packetStream, errMsg)); | ||
|
||
pcpp::RawPacket lastPacket = packetStream.back(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused? |
||
|
||
packetStream.pop_back(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do you pop the last packet? |
||
|
||
for (auto iter : packetStream) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's declare |
||
{ | ||
pcpp::Packet packet(&iter); | ||
tcpReassembly.reassemblePacket(packet); | ||
} | ||
|
||
pcpp::TcpReassembly::ConnectionInfoList managedConnections = | ||
seladb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tcpReassembly.getConnectionInformation(); // make a copy of list | ||
PTF_ASSERT_EQUAL(managedConnections.size(), 1); | ||
bool isOpen = tcpReassembly.isConnectionOpen(managedConnections.begin()->second); | ||
PTF_ASSERT_FALSE(isOpen); | ||
|
||
packetStream.clear(); | ||
|
||
} // TestTcpReassemblyFinishReset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this debug log to after the if condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in this commit a1f3495