GRE tunnel introspection for sFlow #559
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Generic Routing Encapsulation (GRE) is a tunneling protocol that allows to encapsulate data of various protocols (most prominently Ethernet and IP) in IP packets. For example, an Ethernet frame encapsulated in an IP packet would lead to the following overall header structure:
Alternatively, it is also possible to encapsulate pure IP packets only, using the following header structure:
Most relevantly, the GRE header includes a field for the protocol type of the encapsulated protocol, which uses the EtherType codes.
Naturally, multiple GRE layers can be nested.
Problem
Currently, the header parsing for sFlow considers GRE a blackbox layer-4 protocol, only parses the outer headers, and records the corresponding flow information. For demonstration, we provide a PCAP file, containing sFlow records for 5 different flows that are encapsulated in an IP flow from
1.1.1.1
to2.2.2.2
. When recording these packets withsfcapd
,nfdump
shows the following records:However, in many scenarios where GRE tunneling is applied, the interesting flow information might be in the encapsulated packet.
Solution approach
We added a new command-line option
-G
to signal thatsfcapd
should consider the GRE-encapsulated packet relevant for extracting flow information. Whenever the-G
flag is present andsfcapd
encounters a GRE header (i.e., insflow_process.c
), the parsing restarts after the GRE header. This logic is applied recursively, i.e., always the 'innermost' packet is relevant for flow information.Result & Tests
When feeding the same sFlow records as above to
sfcapd
with GRE parsing enabled, we observe the followingnfdump
output, making the tunneled flows visible:The last flow record with protocol GRE refers to a packet where the GRE header is not followed by any encapsulated packet (added for robustness checks).
Moreover, all tests run with
make check
still pass.Contributors
This pull request is proposed by Simon Scherrer from NetFabric.ai.