diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2006-10-19 13:10:26 -0700 |
---|---|---|
committer | Stephen Hemminger <shemminger@osdl.org> | 2006-10-19 13:10:26 -0700 |
commit | fa56513034c839e444ab7ca986ddb178dece86c7 (patch) | |
tree | 85b7162a5eeffc2cdf5e90f04dfd5ab48756e412 /tc/tc_core.c | |
parent | 69d25465c9b2cd0ebfe6af1fe57bb2bf4e0cab2e (diff) |
Trap possible overflow in usec values to netem
If user asks for large usec value it could overflow 32 bits.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Diffstat (limited to 'tc/tc_core.c')
-rw-r--r-- | tc/tc_core.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tc/tc_core.c b/tc/tc_core.c index 07cf2fa9..10c375ef 100644 --- a/tc/tc_core.c +++ b/tc/tc_core.c @@ -27,6 +27,15 @@ static __u32 t2us=1; static __u32 us2t=1; static double tick_in_usec = 1; +int tc_core_usec2big(long usec) +{ + __u64 t = usec; + + t *= tick_in_usec; + return (t >> 32) != 0; +} + + long tc_core_usec2tick(long usec) { return usec*tick_in_usec; |