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

bpf: nodeport: fix handling of stale CT entry with CT_REPLY #23894

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions bpf/lib/nodeport.h
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,8 @@ static __always_inline int nodeport_lb6(struct __ctx_buff *ctx,
ret = ct_lb_lookup6(get_ct_map6(&tuple), &tuple, ctx, l4_off,
CT_EGRESS, &ct_state, &monitor);
switch (ret) {
case CT_REPLY:
ipv6_ct_tuple_reverse(&tuple);
case CT_NEW:
redo:
ct_state_new.src_sec_id = WORLD_ID;
Expand All @@ -941,7 +943,6 @@ static __always_inline int nodeport_lb6(struct __ctx_buff *ctx,
break;
case CT_REOPENED:
case CT_ESTABLISHED:
case CT_REPLY:
if (unlikely(ct_state.rev_nat_index !=
svc->rev_nat_index))
goto redo;
Expand Down Expand Up @@ -2007,6 +2008,13 @@ static __always_inline int nodeport_lb4(struct __ctx_buff *ctx,
ret = ct_lb_lookup4(get_ct_map4(&tuple), &tuple, ctx, l4_off,
has_l4_header, CT_EGRESS, &ct_state, &monitor);
switch (ret) {
case CT_REPLY:
/* SVC request should never be considered a reply, so this
* must be a stale CT entry.
*
* Tuple needs to be manually flipped for ct_create4():
*/
ipv4_ct_tuple_reverse(&tuple);
case CT_NEW:
redo:
ct_state_new.src_sec_id = WORLD_ID;
Expand All @@ -2019,7 +2027,6 @@ static __always_inline int nodeport_lb4(struct __ctx_buff *ctx,
break;
case CT_REOPENED:
case CT_ESTABLISHED:
case CT_REPLY:
/* Recreate CT entries, as the existing one is stale and
* belongs to a flow which target a different svc.
*/
Expand Down