lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1433361502-3478761-2-git-send-email-tom@herbertland.com>
Date:	Wed, 3 Jun 2015 12:58:17 -0700
From:	Tom Herbert <tom@...bertland.com>
To:	<davem@...emloft.net>, <agartrell@...com>, <maheshb@...gle.com>,
	<tgraf@...g.ch>, <netdev@...r.kernel.org>
Subject: [RFC net-next 1/6] net: Checksum functions to replace 8 bytes at a time

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 <tom@...bertland.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 majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ