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

[IPFIX] Fix parsing when using buffered (TCP) input #194

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

Conversation

Abazigal
Copy link

@Abazigal Abazigal commented Jul 12, 2021

When using a TCP input, packets' data are buffered before logstash
tries do decode them. Therefore, our decode() function will receive
chunks of "random" sizes, that might contain 2 PDUs, 3.4 PDUs, etc.

The current code parses only one PDU and discards the rest of the
payload. Therefore, we can easily miss a PDU, and the next call will
most likely parse the middle of a PDU, which will result in an error.
The file ipfix.dat used during CI is actually a good example : it
contains 3 IPFIX messages. But so far, the code is only considering
the first one, hence the 7 flows returned instead of the 13 that the
file contains.

This commit makes sure each call consumes all the PDUs available in
the payload, and the remaining data (beginning of another PDU) are
buffered to be reused in the next call.

@cla-checker-service
Copy link

cla-checker-service bot commented Jul 12, 2021

💚 CLA has been signed

@Abazigal Abazigal changed the title [IPFIX] Fix parsing when using buffered (TCP) input [DRAFT][IPFIX] Fix parsing when using buffered (TCP) input Jul 12, 2021
@Abazigal Abazigal force-pushed the issue_tcp_ipfix branch 12 times, most recently from ce564ef to 6d345b5 Compare July 12, 2021 17:26
 When using a TCP input, packets' data are buffered before logstash
 tries do decode them. Therefore, our decode() function will receive
 chunks of "random" sizes, that might contain 2 PDUs, 3.4 PDUs, etc.

 The current code parses only one PDU and discards the rest of the
 payload. Therefore, we can easily miss a PDU, and the next call will
 most likely parse the middle of a PDU, which will result in an error.
 The file ipfix.dat used during CI is actually a good example : it
 contains 3 IPFIX messages. But so far, the code is only considering
 the first one, hence the 7 flows returned instead of the 13 that the
 file contains.

 This commit makes sure each call consumes all the PDUs available in
 the payload, and the remaining data (beginning of another PDU) are
 buffered to be reused in the next call.
@Abazigal
Copy link
Author

The remaining CI issue comes from master.

@Abazigal Abazigal changed the title [DRAFT][IPFIX] Fix parsing when using buffered (TCP) input [IPFIX] Fix parsing when using buffered (TCP) input Jul 12, 2021
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.

1 participant