Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tc-tbf burst value in bytes #169

Merged

Conversation

hustcat
Copy link
Contributor

@hustcat hustcat commented Jul 2, 2018

According to iproute2, we should calculate the buffer in bytes for rate and burst both. But the current burst is in bit unit.

@rosenhouse
Copy link
Contributor

@hustcat this change looks right, but it broke some tests. Could you fix that up?

@hustcat
Copy link
Contributor Author

hustcat commented Jul 3, 2018

@rosenhouse Updated, PTAL

Copy link
Contributor

@rosenhouse rosenhouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@squeed
Copy link
Member

squeed commented Jul 4, 2018

Hmm. I tested the original bandwidth plugin and it seemed to create the correct values, at least when I viewed the queues. But I don't know enough about this stuff.

@hustcat
Copy link
Contributor Author

hustcat commented Jul 5, 2018

@squeed This is my test with original bandwidth tool before this PR:

  • Create veth pair
# ip netns add netns1
# ip link add veth_host type veth peer name veth_con
# ip link set veth_con netns netns1
# ip link show veth_host
2719: veth_host@if2718: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether b2:1d:56:6a:ff:3c brd ff:ff:ff:ff:ff:ff link-netnsid 5
  • Set rate to 8000bit and burt to 80bit by bandwidth
# cat bandwidth.conf 
{
"cniVersion": "0.3.1",
"name": "slowdown",
"type": "bandwidth",
"ingressRate": 8000,
"ingressBurst": 80,
"egressRate": 8000,
"egressBurst": 80,
"prevResult": {"cniVersion":"0.3.1", "interfaces": [{"name": "veth_host","mac": "b2:1d:56:6a:ff:3c", "sandbox": ""}]}
}

# CNI_PATH=`pwd`/bin CNI_COMMAND=ADD CNI_NETNS=/var/run/netns/netns1 CNI_CONTAINERID=netns1 CNI_IFNAME=veth_con CNI_ARGS="" bin/bandwidth < bandwidth.conf
{
    "cniVersion": "0.3.1",
    "interfaces": [
        {
            "name": "veth_host",
            "mac": "b2:1d:56:6a:ff:3c"
        },
        {
            "name": "5026",
            "mac": "7a:49:f8:e0:ff:9e"
        }
    ],
    "dns": {}
}

# ./tc -r qdisc show dev veth_host
qdisc tbf 1:[00010000] root refcnt 2 rate 8Kbit burst 80b [001312d0] lat 25.0ms limit 105b 
qdisc ingress ffff:[ffff0000] parent ffff:fff1 ---------------- 
  • Set rate to 8000bit and burt to 80bit(=10b) by tc
# tc qdisc delete dev veth_host root handle 1:
# tc qdisc delete dev veth_host ingress


# tc qdisc add dev veth_host handle 1: root tbf rate 8kbit burst 10b latency 25ms

# ./tc  -r qdisc show dev veth_host                                                 
qdisc tbf 1:[00010000] root refcnt 2 rate 8Kbit burst 10b [0002625a] lat 25.0ms limit 35b

As we can see, the values of burst and limit are not same between the bandwidth and tc ouput.

@hustcat
Copy link
Contributor Author

hustcat commented Jul 5, 2018

Maybe we should make ingressBurst and egressBurst use byte as unit directly, but not bit. See here.

@squeed
Copy link
Member

squeed commented Jul 5, 2018

Ahh, I see. Thanks for the explanation. I definitely want to keep the config API the same (bits), so your fix seems right.

Copy link
Member

@matthewdupre matthewdupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tried it, but it all looks right and consistent.

@matthewdupre matthewdupre merged commit 9201a5a into containernetworking:master Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants