inet_proto_csum_replace16(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 honestly
  • skb β€” the sk_buff for 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 β€” a bool; 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 πŸ”₯

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