* [PATCH net-next] ila: Fix checksum neutral mapping
@ 2016-06-14 23:29 Tom Herbert
2016-06-16 4:44 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Tom Herbert @ 2016-06-14 23:29 UTC (permalink / raw)
To: davem, netdev; +Cc: kernel-team, haoxuany
The algorithm for checksum neutral mapping is incorrect. This problem
was being hidden since we were previously always performing checksum
offload on the translated addresses and only with IPv6 HW csum.
Enabling an ILA router shows the issue.
Corrected algorithm:
old_loc is the original locator in the packet, new_loc is the value
to overwrite with and is found in the lookup table. old_flag is
the old flag value (zero of CSUM_NEUTRAL_FLAG) and new_flag is
then (old_flag ^ CSUM_NEUTRAL_FLAG) & CSUM_NEUTRAL_FLAG.
Need SUM(new_id + new_flag + diff) == SUM(old_id + old_flag) for
checksum neutral translation.
Solving for diff gives:
diff = (old_id - new_id) + (old_flag - new_flag)
compute_csum_diff8(new_id, old_id) gives old_id - new_id
If old_flag is set
old_flag - new_flag = old_flag = CSUM_NEUTRAL_FLAG
Else
old_flag - new_flag = -new_flag = ~CSUM_NEUTRAL_FLAG
Tested:
- Implemented a user space program that creates random addresses
and random locators to overwrite. Compares the checksum over
the address before and after translation (must always be equal)
- Enabled ILA router and showed proper operation.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
net/ipv6/ila/ila_common.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/ila/ila_common.c b/net/ipv6/ila/ila_common.c
index b3d00be..ec9efbc 100644
--- a/net/ipv6/ila/ila_common.c
+++ b/net/ipv6/ila/ila_common.c
@@ -34,12 +34,12 @@ static void ila_csum_do_neutral(struct ila_addr *iaddr,
if (p->locator_match.v64) {
diff = p->csum_diff;
} else {
- diff = compute_csum_diff8((__be32 *)iaddr,
- (__be32 *)&p->locator);
+ diff = compute_csum_diff8((__be32 *)&p->locator,
+ (__be32 *)iaddr);
}
fval = (__force __wsum)(ila_csum_neutral_set(iaddr->ident) ?
- ~CSUM_NEUTRAL_FLAG : CSUM_NEUTRAL_FLAG);
+ CSUM_NEUTRAL_FLAG : ~CSUM_NEUTRAL_FLAG);
diff = csum_add(diff, fval);
@@ -140,8 +140,8 @@ void ila_init_saved_csum(struct ila_params *p)
return;
p->csum_diff = compute_csum_diff8(
- (__be32 *)&p->locator_match,
- (__be32 *)&p->locator);
+ (__be32 *)&p->locator,
+ (__be32 *)&p->locator_match);
}
static int __init ila_init(void)
--
2.8.0.rc2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ila: Fix checksum neutral mapping
2016-06-14 23:29 [PATCH net-next] ila: Fix checksum neutral mapping Tom Herbert
@ 2016-06-16 4:44 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-06-16 4:44 UTC (permalink / raw)
To: tom; +Cc: netdev, kernel-team, haoxuany
From: Tom Herbert <tom@herbertland.com>
Date: Tue, 14 Jun 2016 16:29:15 -0700
> The algorithm for checksum neutral mapping is incorrect. This problem
> was being hidden since we were previously always performing checksum
> offload on the translated addresses and only with IPv6 HW csum.
> Enabling an ILA router shows the issue.
>
> Corrected algorithm:
>
> old_loc is the original locator in the packet, new_loc is the value
> to overwrite with and is found in the lookup table. old_flag is
> the old flag value (zero of CSUM_NEUTRAL_FLAG) and new_flag is
> then (old_flag ^ CSUM_NEUTRAL_FLAG) & CSUM_NEUTRAL_FLAG.
>
> Need SUM(new_id + new_flag + diff) == SUM(old_id + old_flag) for
> checksum neutral translation.
>
> Solving for diff gives:
>
> diff = (old_id - new_id) + (old_flag - new_flag)
>
> compute_csum_diff8(new_id, old_id) gives old_id - new_id
>
> If old_flag is set
> old_flag - new_flag = old_flag = CSUM_NEUTRAL_FLAG
> Else
> old_flag - new_flag = -new_flag = ~CSUM_NEUTRAL_FLAG
>
> Tested:
> - Implemented a user space program that creates random addresses
> and random locators to overwrite. Compares the checksum over
> the address before and after translation (must always be equal)
> - Enabled ILA router and showed proper operation.
>
> Signed-off-by: Tom Herbert <tom@herbertland.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-16 4:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-14 23:29 [PATCH net-next] ila: Fix checksum neutral mapping Tom Herbert
2016-06-16 4:44 ` David Miller
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).