netdev: Don't divide by zero when "linux-htb" zero min-rate is used
[sliver-openvswitch.git] / lib / netdev-linux.c
index a20a1c4..7668eff 100644 (file)
@@ -53,7 +53,6 @@
 #include "netlink.h"
 #include "ofpbuf.h"
 #include "openflow/openflow.h"
-#include "openvswitch/gre.h"
 #include "packets.h"
 #include "poll-loop.h"
 #include "port-array.h"
@@ -1009,7 +1008,7 @@ netdev_linux_update_is_pseudo(struct netdev_dev_linux *netdev_dev)
     if (!(netdev_dev->cache_valid & VALID_IS_PSEUDO)) {
         const char *name = netdev_dev_get_name(&netdev_dev->netdev_dev);
         const char *type = netdev_dev_get_type(&netdev_dev->netdev_dev);
-        
+
         netdev_dev->is_tap = !strcmp(type, "tap");
         netdev_dev->is_internal = false;
         if (!netdev_dev->is_tap) {
@@ -1873,7 +1872,7 @@ netdev_linux_get_next_hop(const struct in_addr *host, struct in_addr *next_hop,
                        iface, &dest, &gateway, &flags, &refcnt,
                        &use, &metric, &mask, &mtu, &window, &irtt) != 11) {
 
-                VLOG_WARN_RL(&rl, "%s: could not parse line %d: %s", 
+                VLOG_WARN_RL(&rl, "%s: could not parse line %d: %s",
                         fn, ln, line);
                 continue;
             }
@@ -1883,7 +1882,7 @@ netdev_linux_get_next_hop(const struct in_addr *host, struct in_addr *next_hop,
             }
 
             /* The output of 'dest', 'mask', and 'gateway' were given in
-             * network byte order, so we don't need need any endian 
+             * network byte order, so we don't need need any endian
              * conversions here. */
             if ((dest & mask) == (host->s_addr & mask)) {
                 if (!gateway) {
@@ -2622,7 +2621,7 @@ htb_class_dump_stats(const struct netdev *netdev OVS_UNUSED,
     major = tc_get_major(handle);
     minor = tc_get_minor(handle);
     if (major == 1 && minor > 0 && minor <= HTB_N_QUEUES) {
-        (*cb)(tc_get_minor(handle), &stats, aux);
+        (*cb)(minor - 1, &stats, aux);
     }
     return 0;
 }
@@ -2899,7 +2898,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
@@ -3245,9 +3244,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)
 {