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>
This commit is contained in:
parent
69d25465c9
commit
fa56513034
|
|
@ -111,6 +111,11 @@ static int get_ticks(__u32 *ticks, const char *str)
|
||||||
if(get_usecs(&t, str))
|
if(get_usecs(&t, str))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (tc_core_usec2big(t)) {
|
||||||
|
fprintf(stderr, "Illegal %d usecs (too large)\n", t);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
*ticks = tc_core_usec2tick(t);
|
*ticks = tc_core_usec2tick(t);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,15 @@ static __u32 t2us=1;
|
||||||
static __u32 us2t=1;
|
static __u32 us2t=1;
|
||||||
static double tick_in_usec = 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)
|
long tc_core_usec2tick(long usec)
|
||||||
{
|
{
|
||||||
return usec*tick_in_usec;
|
return usec*tick_in_usec;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
#include <linux/pkt_sched.h>
|
#include <linux/pkt_sched.h>
|
||||||
|
|
||||||
|
int tc_core_usec2big(long usec);
|
||||||
long tc_core_usec2tick(long usec);
|
long tc_core_usec2tick(long usec);
|
||||||
long tc_core_tick2usec(long tick);
|
long tc_core_tick2usec(long tick);
|
||||||
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
|
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue