netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH net-next v3 2/2] ila: Precompute checksum difference for translations
Date: Mon, 24 Aug 2015 09:45:42 -0700	[thread overview]
Message-ID: <1440434742-4112603-3-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1440434742-4112603-1-git-send-email-tom@herbertland.com>

In the ILA build state for LWT compute the checksum difference to apply
to transport checksums that include the IPv6 pseudo header. The
difference is between the route destination (from fib6_config) and the
locator to write.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/ipv6/ila.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/net/ipv6/ila.c b/net/ipv6/ila.c
index ffe4dca..678d2df 100644
--- a/net/ipv6/ila.c
+++ b/net/ipv6/ila.c
@@ -14,6 +14,8 @@
 
 struct ila_params {
 	__be64 locator;
+	__be64 locator_match;
+	__wsum csum_diff;
 };
 
 static inline struct ila_params *ila_params_lwtunnel(
@@ -33,6 +35,9 @@ static inline __wsum compute_csum_diff8(const __be32 *from, const __be32 *to)
 
 static inline __wsum get_csum_diff(struct ipv6hdr *ip6h, struct ila_params *p)
 {
+	if (*(__be64 *)&ip6h->daddr == p->locator_match)
+		return p->csum_diff;
+	else
 		return compute_csum_diff8((__be32 *)&ip6h->daddr,
 					  (__be32 *)&p->locator);
 }
@@ -130,8 +135,12 @@ static int ila_build_state(struct net_device *dev, struct nlattr *nla,
 	struct nlattr *tb[ILA_ATTR_MAX + 1];
 	size_t encap_len = sizeof(*p);
 	struct lwtunnel_state *newts;
+	const struct fib6_config *cfg6 = cfg;
 	int ret;
 
+	if (family != AF_INET6)
+		return -EINVAL;
+
 	ret = nla_parse_nested(tb, ILA_ATTR_MAX, nla,
 			       ila_nl_policy);
 	if (ret < 0)
@@ -149,6 +158,15 @@ static int ila_build_state(struct net_device *dev, struct nlattr *nla,
 
 	p->locator = (__force __be64)nla_get_u64(tb[ILA_ATTR_LOCATOR]);
 
+	if (cfg6->fc_dst_len > sizeof(__be64)) {
+		/* Precompute checksum difference for translation since we
+		 * know both the old locator and the new one.
+		 */
+		p->locator_match = *(__be64 *)&cfg6->fc_dst;
+		p->csum_diff = compute_csum_diff8(
+			(__be32 *)&p->locator_match, (__be32 *)&p->locator);
+	}
+
 	newts->type = LWTUNNEL_ENCAP_ILA;
 	newts->flags |= LWTUNNEL_STATE_OUTPUT_REDIRECT |
 			LWTUNNEL_STATE_INPUT_REDIRECT;
-- 
1.8.1

  parent reply	other threads:[~2015-08-24 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 16:45 [PATCH net-next v3 0/2] ila: Precompute checksums Tom Herbert
2015-08-24 16:45 ` [PATCH net-next v3 1/2] lwt: Add cfg argument to build_state Tom Herbert
2015-08-24 16:45 ` Tom Herbert [this message]
2015-08-24 17:39 ` [PATCH net-next v3 0/2] ila: Precompute checksums David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440434742-4112603-3-git-send-email-tom@herbertland.com \
    --to=tom@herbertland.com \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).