inet_proto_csum_replace16(9)
π inet_proto_csum_replace16(9) β the Kernel API Manual glow-up π
okay so bestie, this is inet_proto_csum_replace16(9) from the Kernel API Manual, and honestly? she's a little niche but she carries. we're talking layer 4 header checksum maintenance when an IPv6 address gets swapped. iykyk. let's get into it π«Ά
β¨ NAME β¨
inet_proto_csum_replace16 β update layer 4 header checksum field
like literally that's her whole job. one field. checksum. updated. slay π
π¦ SYNOPSIS π¦
void inet_proto_csum_replace16 (__sum16 *sum , struct sk_buff *skb ,
const __be32 *from , const __be32 *to , bool pseudohdr );
no return value, no drama, just vibes and five arguments. periodt β¨
π ARGUMENTS π
sumβ the layer 4 header checksum field π this is the thing getting updated, the main character of the whole operation honestlyskbβ thesk_bufffor the packet, aka the packet's whole little suitcase π§³fromβ the old IPv6 address, the one we're saying bye to πtoβ the new IPv6 address, the one sliding in πΈpseudohdrβ abool; true if the layer 4 header checksum includes a pseudoheader. yes ma'am, that matters π
π DESCRIPTION π
so here's the tea π: this function updates the layer 4 header as per the update in the IPv6 src/dst address. address moved, checksum follows. simple, iconic, done.
now the interesting part β and this is the bit you actually gotta remember for the vibe check π β there is no need to update skb->csum in this function. why? because the update happens in two fields:
a.) the IPv6 src/dst address, and b.) the L4 header checksum
and those two cancel each other out for skb->csum calculation. like not me shipping a self-cancelling pair of updates π flawless.
meanwhile inet_proto_csum_replace4 does need to update skb->csum, because that one updates three fields:
a.) the IPv4 src/dst address, b.) the IPv4 Header checksum, and c.) the L4 header checksum
and those result in the same diff as the L4 Header checksum for skb->csum calculation. so yeah, different math, different needs, both valid. we don't pit two icons against each other π
fr fr: the whole point here is that v6 gets to skip the skb->csum update and v4 doesn't. don't come for me, that's just what the math said π
π₯ SEE ALSO π₯
- Kernel file
./net/core/utils.c in4_pton(9)in6_pton(9)inet_pton_with_scope(9)
go read the whole friend group, they're all in ./net/core/utils.c together and they ate πβ¨
okay that's the whole page bestie, no cap, nothing skipped, nothing invented πΈ this little gem is brought to you by the source at ./net/core, dated October 2026, and it lives at inet_proto_csum_replace16(9) forever and ever. mwah ππ«Άπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms