Merge "bpf clatd.c - refix RFC6145 - really use low 16 bits of IPv6 frag id"

This commit is contained in:
Maciej Żenczykowski
2022-11-24 15:25:59 +00:00
committed by Gerrit Code Review

View File

@@ -111,8 +111,9 @@ static inline __always_inline int nat64(struct __sk_buff* skb, bool is_ethernet)
return TC_ACT_PIPE;
const struct frag_hdr *frag = (const struct frag_hdr *)(ip6 + 1);
proto = frag->nexthdr;
// Per RFC6145 use bottom 16-bits of 32-bit IPv6 ID field for 16-bit IPv4 field.
ip_id = frag->identification;
// RFC6145: use bottom 16-bits of network endian 32-bit IPv6 ID field for 16-bit IPv4 field.
// this is equivalent to: ip_id = htons(ntohl(frag->identification));
ip_id = frag->identification >> 16;
// Conversion of 16-bit IPv6 frag offset to 16-bit IPv4 frag offset field.
// IPv6 is '13 bits of offset in multiples of 8' + 2 zero bits + more fragment bit
// IPv4 is zero bit + don't frag bit + more frag bit + '13 bits of offset in multiples of 8'