diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-11-14 00:12:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-11-14 00:12:14 -0500 |
commit | 6dd10a62353a50b30b30e0c18653650975b29c71 (patch) | |
tree | 1410482f86ec88a4f65692c4dd301eae5696a762 /drivers/char | |
parent | cb4da1a34de3840ce49dc7292a063e1ef7f127af (diff) |
[NET] random : secure_tcp_sequence_number should not assume CONFIG_KTIME_SCALAR
All 32 bits machines but i386 dont have CONFIG_KTIME_SCALAR. On these
machines, ktime.tv64 is more than 4 times the (correct) result given
by ktime_to_ns()
Again on these machines, using ktime_get_real().tv64 >> 6 give a
32bits rollover every 64 seconds, which is not wanted (less than the
120 s MSL)
Using ktime_to_ns() is the portable way to get nsecs from a ktime, and
have correct code.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/random.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 1756b1f7cb72..5fee05661823 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -1494,7 +1494,7 @@ __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, | |||
1494 | seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; | 1494 | seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; |
1495 | seq += keyptr->count; | 1495 | seq += keyptr->count; |
1496 | 1496 | ||
1497 | seq += ktime_get_real().tv64; | 1497 | seq += ktime_to_ns(ktime_get_real()); |
1498 | 1498 | ||
1499 | return seq; | 1499 | return seq; |
1500 | } | 1500 | } |
@@ -1556,7 +1556,7 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, | |||
1556 | * overlaps less than one time per MSL (2 minutes). | 1556 | * overlaps less than one time per MSL (2 minutes). |
1557 | * Choosing a clock of 64 ns period is OK. (period of 274 s) | 1557 | * Choosing a clock of 64 ns period is OK. (period of 274 s) |
1558 | */ | 1558 | */ |
1559 | seq += ktime_get_real().tv64 >> 6; | 1559 | seq += ktime_to_ns(ktime_get_real()) >> 6; |
1560 | #if 0 | 1560 | #if 0 |
1561 | printk("init_seq(%lx, %lx, %d, %d) = %d\n", | 1561 | printk("init_seq(%lx, %lx, %d, %d) = %d\n", |
1562 | saddr, daddr, sport, dport, seq); | 1562 | saddr, daddr, sport, dport, seq); |
@@ -1616,7 +1616,7 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, | |||
1616 | seq = half_md4_transform(hash, keyptr->secret); | 1616 | seq = half_md4_transform(hash, keyptr->secret); |
1617 | seq |= ((u64)keyptr->count) << (32 - HASH_BITS); | 1617 | seq |= ((u64)keyptr->count) << (32 - HASH_BITS); |
1618 | 1618 | ||
1619 | seq += ktime_get_real().tv64; | 1619 | seq += ktime_to_ns(ktime_get_real()); |
1620 | seq &= (1ull << 48) - 1; | 1620 | seq &= (1ull << 48) - 1; |
1621 | #if 0 | 1621 | #if 0 |
1622 | printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n", | 1622 | printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n", |