← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1884273] [NEW] tc_lib (QoS; tc qdisc tbf) uses wrong value for byte/s conversion

 

Public bug reported:

Hi.
I have noticed that the value used for kbit -> bytes/s conversion inside add_tc_qdisc() method is wrong. The code is using 1024 instead of 1000. 1024 would be used if the max_kbps variable was in Kibit, but it's not - it's in kbit, which would use 1000.

File:
neutron/neutron/agent/linux/tc_lib.py

Code:

def add_tc_qdisc(device, qdisc_type, parent=None, handle=None, latency_ms=None,
                 max_kbps=None, burst_kb=None, kernel_hz=None,
                 namespace=None):
    """Add/replace a TC qdisc on a device
(...)
        args['burst'] = int(
            _get_tbf_burst_value(max_kbps, burst_kb, kernel_hz) * 1024 / 8)
        args['rate'] = int(max_kbps * 1024 / 8)
        args['latency'] = latency_ms * 1000
(...)

** Affects: neutron
     Importance: Undecided
         Status: New

** Description changed:

  Hi.
  I have noticed that the value used for kbit -> bytes/s conversion inside add_tc_qdisc() method is wrong. The code is using 1024 instead of 1000. 1024 would be used if the max_kbps variable was in Kibit, but it's not - it's in kbit, which would use 1000.
  
  File:
  neutron/neutron/agent/linux/tc_lib.py
  
  Code:
- ```
+ 
  def add_tc_qdisc(device, qdisc_type, parent=None, handle=None, latency_ms=None,
-                  max_kbps=None, burst_kb=None, kernel_hz=None,
-                  namespace=None):
-     """Add/replace a TC qdisc on a device
+                  max_kbps=None, burst_kb=None, kernel_hz=None,
+                  namespace=None):
+     """Add/replace a TC qdisc on a device
  (...)
-         args['burst'] = int(
-             _get_tbf_burst_value(max_kbps, burst_kb, kernel_hz) * 1024 / 8)
-         args['rate'] = int(max_kbps * 1024 / 8)
-         args['latency'] = latency_ms * 1000
+         args['burst'] = int(
+             _get_tbf_burst_value(max_kbps, burst_kb, kernel_hz) * 1024 / 8)
+         args['rate'] = int(max_kbps * 1024 / 8)
+         args['latency'] = latency_ms * 1000
  (...)
- ```

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1884273

Title:
  tc_lib (QoS; tc qdisc tbf) uses wrong value for byte/s conversion

Status in neutron:
  New

Bug description:
  Hi.
  I have noticed that the value used for kbit -> bytes/s conversion inside add_tc_qdisc() method is wrong. The code is using 1024 instead of 1000. 1024 would be used if the max_kbps variable was in Kibit, but it's not - it's in kbit, which would use 1000.

  File:
  neutron/neutron/agent/linux/tc_lib.py

  Code:

  def add_tc_qdisc(device, qdisc_type, parent=None, handle=None, latency_ms=None,
                   max_kbps=None, burst_kb=None, kernel_hz=None,
                   namespace=None):
      """Add/replace a TC qdisc on a device
  (...)
          args['burst'] = int(
              _get_tbf_burst_value(max_kbps, burst_kb, kernel_hz) * 1024 / 8)
          args['rate'] = int(max_kbps * 1024 / 8)
          args['latency'] = latency_ms * 1000
  (...)

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1884273/+subscriptions


Follow ups