diff options
| author | Justin Pettit <jpettit@nicira.com> | 2010-10-08 13:50:16 -0700 |
|---|---|---|
| committer | Justin Pettit <jpettit@nicira.com> | 2010-10-08 14:22:36 -0700 |
| commit | 015c93a49a4380a1645de83a0567d4736ddde622 (patch) | |
| tree | 21a88f298bb5f2cb11a53881df0f8ecc01963776 /lib/netdev-linux.c | |
| parent | 5db39d100c328b218e8c89efab4f43609febf34c (diff) | |
| download | openvswitch-015c93a49a4380a1645de83a0567d4736ddde622.tar.gz | |
netdev: Don't divide by zero when "linux-htb" zero min-rate is used
A "min-rate" of zero for the "linux-htb" QoS type would cause a divide
by zero exception. This patch prevents that by just returning zero. A
later patch will try to enforce reasonable values for "min-rate".
Bug #3745
Diffstat (limited to 'lib/netdev-linux.c')
| -rw-r--r-- | lib/netdev-linux.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index abfbe6ef8..dfea605d8 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2938,7 +2938,7 @@ tc_bytes_to_ticks(unsigned int rate, unsigned int size) if (!buffer_hz) { read_psched(); } - return ((unsigned long long int) ticks_per_s * size) / rate; + return rate ? ((unsigned long long int) ticks_per_s * size) / rate : 0; } /* Returns the number of bytes that need to be reserved for qdisc buffering at @@ -3284,9 +3284,7 @@ tc_put_rtab(struct ofpbuf *msg, uint16_t type, const struct tc_ratespec *rate) /* Calculates the proper value of 'buffer' or 'cbuffer' in HTB options given a * rate of 'Bps' bytes per second, the specified 'mtu', and a user-requested * burst size of 'burst_bytes'. (If no value was requested, a 'burst_bytes' of - * 0 is fine.) - * - * This */ + * 0 is fine.) */ static int tc_calc_buffer(unsigned int Bps, int mtu, uint64_t burst_bytes) { |
