bpf: clat: fix translation of ICMPv6 Parameter Problem

According to RFC 6145 5.2, the pointer should be set for code 0, not
1.
This commit is contained in:
Beniamino Galvani 2026-01-02 16:41:50 +01:00
parent 80bba04baa
commit d209e01442

View file

@ -468,14 +468,11 @@ rewrite_icmpv6(struct ipv6hdr *ip6h,
case 0:
icmp.type = ICMP_PARAMETERPROB;
icmp.code = 0;
break;
case 1:
icmp.type = ICMP_DEST_UNREACH;
icmp.code = ICMP_PROT_UNREACH;
ptr = bpf_ntohl(icmp6->icmp6_pointer);
/* Figure 6 in RFC6145 - using if statements b/c of
* range at the bottom
*/
ptr = bpf_ntohl(icmp6->icmp6_pointer);
if (ptr == 0 || ptr == 1)
icmp.un.reserved[0] = ptr;
else if (ptr == 4 || ptr == 5)
@ -491,6 +488,10 @@ rewrite_icmpv6(struct ipv6hdr *ip6h,
else
return -1;
break;
case 1:
icmp.type = ICMP_DEST_UNREACH;
icmp.code = ICMP_PROT_UNREACH;
break;
default:
return -1;
}