Skip to content

Conversation

kaworu
Copy link
Member

@kaworu kaworu commented Apr 22, 2024

NOTE: draft until #31226 is merged, also currently missing the Hubble CLI bits

Add a new source_xlated field to Hubble Flow.IP and a corresponding IP filter.

Fix the FlowFilter.Experimental.cel_expression and FlowFilter.drop_reason_desc protobuf field numbers on the way.

@kaworu kaworu added kind/feature This introduces new functionality. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. sig/hubble labels Apr 22, 2024
@kaworu kaworu self-assigned this Apr 22, 2024
@kaworu kaworu requested review from a team as code owners April 22, 2024 15:18
@kaworu kaworu marked this pull request as draft April 22, 2024 15:18
Copy link
Contributor

@chancez chancez left a comment

Choose a reason for hiding this comment

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

Could use a parser test where SnatAs is non-empty.

@chancez
Copy link
Contributor

chancez commented Apr 22, 2024

Oops just noticed this is a draft after submitting my review. Feel free to ignore as needed.

@kaworu kaworu force-pushed the pr/kaworu/hubble-snat branch 2 times, most recently from 89a9a26 to 8014b4a Compare April 26, 2024 09:26
@kaworu kaworu force-pushed the pr/kaworu/hubble-snat branch from 8014b4a to 3ef8c5c Compare April 30, 2024 13:44
@kaworu kaworu force-pushed the pr/kaworu/hubble-snat branch 3 times, most recently from f536e36 to b52e943 Compare May 1, 2024 14:05
@kaworu kaworu requested a review from chancez May 1, 2024 14:05
@kaworu
Copy link
Member Author

kaworu commented May 1, 2024

#31226 has been merged and a commit was added to add CLI support. Marking as ready to review.

@kaworu kaworu marked this pull request as ready for review May 1, 2024 14:07
@kaworu kaworu force-pushed the pr/kaworu/hubble-snat branch from b52e943 to 540de42 Compare May 1, 2024 14:10
@kaworu
Copy link
Member Author

kaworu commented May 1, 2024

/test

Copy link
Contributor

@chancez chancez left a comment

Choose a reason for hiding this comment

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

LGTM

kaworu added 6 commits May 1, 2024 18:39
In an egress gateway setup, the packet leaving the egress gateway to the
destination is SNAT'ed with the egress gateway IP address.

Before this patch, the corresponding flow would be reported wrongly as
INGRESS by Hubble, as the traffic direction heuristic would see a
non-reply flow emitted by a different BPF program that the one attached
to the source lxc interface.

This patch set the traffic direction to EGRESS when we detect that the
packet was SNAT'ed, which also fix the lb case.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
Since cel_expression is part of the new Experimental message, it doesn't
have to follow the FlowFilter field number.

Also fix drop_reason_desc field to use the highest unused field number.

Both fields were introduced recently (i.e. after v1.15) and thus this
commit doesn't break backward compatibility with any currently released
Cilium version at the time of writing.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
Move the ip != nil check earlier since the block is about setting ip
related fields and the check is repeated before this patch. This will
simplify the next commit introducing new logic related to ip.Source.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
Before this patch, when TraceNotify.OriginalIP was set, the Hubble
parser would use it as ip.Source discarding the source IP parsed from
the packet header.

This patch introduce a new IP.source_xlated field, preserving the parsed
header's source IP, allowing to expose the actual IP used in the Egress
Gateway and LB cases.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
The previous commit introduce a new SNAT IP field (source_xlated) in
Hubble flow data. This commit is a follow-up adding a corresponding
Hubble filter by SNAT IP either with exact match or CIDR match.

Note that unlike source and destination IP, source_xlated might be
empty.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
The previous commits introduced the IP.source_xlated flow field and a
corresponding source_ip_xlated filter at the Hubble API level. This
patch is a follow-up adding source_ip_xlated support to the Hubble CLI.

After this patch, the --ip flag behaviour is arguably unintuitive as it
will not take source_ip_xlated into account (i.e. only source_ip and
destination_ip).  Unfortunately, addressing this limitation would
require reworking the Hubble CLI internal left/right filter setup, which
it outside of the scope of this commit. The --ip help message was
adapted accordingly with the intent of clearing the potential confusion.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
@kaworu kaworu force-pushed the pr/kaworu/hubble-snat branch from 540de42 to 5bd08e5 Compare May 1, 2024 16:39
@kaworu kaworu added the feature/snat Relates to SNAT or Masquerading of traffic label May 1, 2024
@kaworu
Copy link
Member Author

kaworu commented May 1, 2024

/test

@rolinh rolinh removed the request for review from glibsm May 3, 2024 12:30
Copy link
Contributor

@gentoo-root gentoo-root left a comment

Choose a reason for hiding this comment

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

Looks good, one question.

@@ -189,6 +189,7 @@ func newFlowFilter() *flowFilter {
{"from-pod", "namespace", "all-namespaces"},
{"to-service", "namespace", "all-namespaces"},
{"from-service", "namespace", "all-namespaces"},
{"snat-ip"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing something, but what's the point of conflict lists that consist of one item? What do they check?

Copy link
Member

Choose a reason for hiding this comment

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

That's a good question 😅 I think there's no point in doing that although we apparently did it for other filters as well.

@tklauser tklauser enabled auto-merge May 8, 2024 10:04
@tklauser tklauser removed the request for review from aditighag May 8, 2024 10:04
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 8, 2024
@tklauser tklauser added this pull request to the merge queue May 8, 2024
Merged via the queue into cilium:main with commit 9d4ac2d May 8, 2024
@kaworu kaworu deleted the pr/kaworu/hubble-snat branch May 8, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/snat Relates to SNAT or Masquerading of traffic kind/feature This introduces new functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants