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: wire up ext_err in revSNAT path #25406

Merged
merged 1 commit into from
May 12, 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
14 changes: 8 additions & 6 deletions bpf/lib/nodeport.h
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,10 @@ int tail_nodeport_nat_ingress_ipv6(struct __ctx_buff *ctx)
.max_port = NODEPORT_PORT_MAX_NAT,
.src_from_world = true,
};
__s8 ext_err = 0;
int ret;

/* ext_err is NULL because errors don't survive the tailcall anyway. */
ret = snat_v6_rev_nat(ctx, &target, NULL);
ret = snat_v6_rev_nat(ctx, &target, &ext_err);
if (IS_ERR(ret)) {
if (ret == NAT_PUNT_TO_STACK ||
/* DROP_NAT_NO_MAPPING is unwanted behavior in a
Expand Down Expand Up @@ -805,7 +805,8 @@ int tail_nodeport_nat_ingress_ipv6(struct __ctx_buff *ctx)
ret = DROP_MISSED_TAIL_CALL;

drop_err:
return send_drop_notify_error(ctx, 0, ret, CTX_ACT_DROP, METRIC_INGRESS);
return send_drop_notify_error_ext(ctx, 0, ret, ext_err, CTX_ACT_DROP,
METRIC_INGRESS);
}

declare_tailcall_if(__not(is_defined(IS_BPF_LXC)), CILIUM_CALL_IPV6_NODEPORT_NAT_EGRESS)
Expand Down Expand Up @@ -1982,10 +1983,10 @@ int tail_nodeport_nat_ingress_ipv4(struct __ctx_buff *ctx)
*/
.addr = IPV4_DIRECT_ROUTING,
};
__s8 ext_err = 0;
int ret;

/* ext_err is NULL because errors don't survive the tailcall anyway. */
ret = snat_v4_rev_nat(ctx, &target, NULL);
ret = snat_v4_rev_nat(ctx, &target, &ext_err);
if (IS_ERR(ret)) {
if (ret == NAT_PUNT_TO_STACK ||
/* DROP_NAT_NO_MAPPING is unwanted behavior in a
Expand Down Expand Up @@ -2031,7 +2032,8 @@ int tail_nodeport_nat_ingress_ipv4(struct __ctx_buff *ctx)
ret = DROP_MISSED_TAIL_CALL;

drop_err:
return send_drop_notify_error(ctx, 0, ret, CTX_ACT_DROP, METRIC_INGRESS);
return send_drop_notify_error_ext(ctx, 0, ret, ext_err, CTX_ACT_DROP,
METRIC_INGRESS);
}

declare_tailcall_if(__not(is_defined(IS_BPF_LXC)), CILIUM_CALL_IPV4_NODEPORT_NAT_EGRESS)
Expand Down