-
Notifications
You must be signed in to change notification settings - Fork 3.4k
bpf: nat: don't check port range for ICMP ECHOs #39522
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
Conversation
In the case of ICMP ECHO packets, the `port` is really just an arbitrary 16-bit identifier. We can't skip SNAT based on what value this identifier has. For completeness also do this change for ECHO_REPLY packets, even though it won't make a difference there. It will be needed once we stop clamping the ICMP identifier NAT to the nat_target's min_port / max_port range. Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
Looking at how this code works in detail, I believe we currently would only see issues if multiple host processes (with This doesn't feel like a real-world problem, hence not backporting :). |
/test |
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.
scratched
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.
LGTM in general. Just to confirm, with this change, we skip some of the logics in the snat_v4/v6_nat_can_skip
other than the port range check. The if (target->egress_gateway)
part and !target->from_local_endpoint
part. Are we sure we also skip them?
static __always_inline bool
snat_v4_nat_can_skip(const struct ipv4_nat_target *target,
const struct ipv4_ct_tuple *tuple)
{
__u16 sport = bpf_ntohs(tuple->sport);
#if defined(ENABLE_EGRESS_GATEWAY_COMMON) && defined(IS_BPF_HOST)
if (target->egress_gateway)
return false;
#endif
return (!target->from_local_endpoint && sport < NAT_MIN_EGRESS);
}
That's correct. We care about conditions where
|
In the case of ICMP ECHO packets, the
port
is really just an arbitrary 16-bit identifier. We can't skip SNAT based on what value this identifier has.For completeness also do this change for ECHO_REPLY packets, even though it won't make a difference there. It will be needed once we stop clamping the ICMP identifier NAT to the nat_target's min_port / max_port range.