These are convenience functions for update a checksum in ILA where we are overwriting the locator (first eight bytes of an ILA IPv6 address).
Signed-off-by: Tom Herbert <t...@herbertland.com> --- include/net/checksum.h | 3 +++ net/core/utils.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/net/checksum.h b/include/net/checksum.h index 2d1d73c..af76b8e 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h @@ -141,6 +141,9 @@ static inline void csum_replace2(__sum16 *sum, __be16 old, __be16 new) struct sk_buff; void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, __be32 from, __be32 to, int pseudohdr); +void inet_proto_csum_replace8(__sum16 *sum, struct sk_buff *skb, + const __be32 *from, const __be32 *to, + int pseudohdr); void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, const __be32 *from, const __be32 *to, int pseudohdr); diff --git a/net/core/utils.c b/net/core/utils.c index a7732a0..79d1067 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -336,6 +336,25 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, } EXPORT_SYMBOL(inet_proto_csum_replace16); +void inet_proto_csum_replace8(__sum16 *sum, struct sk_buff *skb, + const __be32 *from, const __be32 *to, + int pseudohdr) +{ + __be32 diff[] = { + ~from[0], ~from[1], to[0], to[1], + }; + if (skb->ip_summed != CHECKSUM_PARTIAL) { + *sum = csum_fold(csum_partial(diff, sizeof(diff), + ~csum_unfold(*sum))); + if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr) + skb->csum = ~csum_partial(diff, sizeof(diff), + ~skb->csum); + } else if (pseudohdr) + *sum = ~csum_fold(csum_partial(diff, sizeof(diff), + csum_unfold(*sum))); +} +EXPORT_SYMBOL(inet_proto_csum_replace8); + struct __net_random_once_work { struct work_struct work; struct static_key *key; -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html