Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ila: Precompute checksum difference for translations

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tom Herbert and committed by
David S. Miller
92b78aff 127eb7cd

+18
+18
net/ipv6/ila.c
··· 14 14 15 15 struct ila_params { 16 16 __be64 locator; 17 + __be64 locator_match; 18 + __wsum csum_diff; 17 19 }; 18 20 19 21 static inline struct ila_params *ila_params_lwtunnel( ··· 35 33 36 34 static inline __wsum get_csum_diff(struct ipv6hdr *ip6h, struct ila_params *p) 37 35 { 36 + if (*(__be64 *)&ip6h->daddr == p->locator_match) 37 + return p->csum_diff; 38 + else 38 39 return compute_csum_diff8((__be32 *)&ip6h->daddr, 39 40 (__be32 *)&p->locator); 40 41 } ··· 135 130 struct nlattr *tb[ILA_ATTR_MAX + 1]; 136 131 size_t encap_len = sizeof(*p); 137 132 struct lwtunnel_state *newts; 133 + const struct fib6_config *cfg6 = cfg; 138 134 int ret; 135 + 136 + if (family != AF_INET6) 137 + return -EINVAL; 139 138 140 139 ret = nla_parse_nested(tb, ILA_ATTR_MAX, nla, 141 140 ila_nl_policy); ··· 157 148 p = ila_params_lwtunnel(newts); 158 149 159 150 p->locator = (__force __be64)nla_get_u64(tb[ILA_ATTR_LOCATOR]); 151 + 152 + if (cfg6->fc_dst_len > sizeof(__be64)) { 153 + /* Precompute checksum difference for translation since we 154 + * know both the old locator and the new one. 155 + */ 156 + p->locator_match = *(__be64 *)&cfg6->fc_dst; 157 + p->csum_diff = compute_csum_diff8( 158 + (__be32 *)&p->locator_match, (__be32 *)&p->locator); 159 + } 160 160 161 161 newts->type = LWTUNNEL_ENCAP_ILA; 162 162 newts->flags |= LWTUNNEL_STATE_OUTPUT_REDIRECT |