Skip to content

Commit a28f0fc

Browse files
bpf: nat: use icmp6_load_type() instead of ctx_load_bytes()
Replace open-coded variants of the helper. Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
1 parent ffbd7af commit a28f0fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bpf/lib/nat.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ static __always_inline int snat_v6_rewrite_ingress(struct __ctx_buff *ctx,
16291629
__u8 type = 0;
16301630
__be32 from, to;
16311631

1632-
if (ctx_load_bytes(ctx, off, &type, 1) < 0)
1632+
if (icmp6_load_type(ctx, off, &type) < 0)
16331633
return DROP_INVALID;
16341634
if (type == ICMPV6_ECHO_REQUEST || type == ICMPV6_ECHO_REPLY) {
16351635
if (ctx_store_bytes(ctx, off +
@@ -1990,7 +1990,7 @@ snat_v6_rev_nat_handle_icmp_pkt_toobig(struct __ctx_buff *ctx, __u32 off)
19901990
/* No reasons to see a packet different than
19911991
* ICMPV6_ECHO_REQUEST.
19921992
*/
1993-
if (ctx_load_bytes(ctx, icmpoff, &type, sizeof(type)) < 0 ||
1993+
if (icmp6_load_type(ctx, icmpoff, &type) < 0 ||
19941994
type != ICMPV6_ECHO_REQUEST)
19951995
return DROP_INVALID;
19961996
if (ctx_load_bytes(ctx, icmpoff +

0 commit comments

Comments
 (0)