Skip to content

Commit 3552c1d

Browse files
authored
Merge pull request tylertreat#54 from yousong/default-bw
Fix shaping default bandwidth
2 parents af870f3 + a80dc9e commit 3552c1d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: throttler/tc.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010

1111
const (
1212
tcRootQDisc = `dev %s handle 10: root`
13+
tcRootExtra = `default 1`
1314
tcDefaultClass = `dev %s parent 10: classid 10:1`
14-
tcTargetClass = `dev %s parent 10:1 classid 10:10`
15+
tcTargetClass = `dev %s parent 10: classid 10:10`
1516
tcNetemRule = `dev %s parent 10:10 handle 100:`
1617
tcRate = `rate %vkbit`
1718
tcDelay = `delay %vms`
@@ -66,7 +67,7 @@ func (t *tcThrottler) setup(cfg *Config) error {
6667
func addRootQDisc(cfg *Config, c commander) error {
6768
//Add the root QDisc
6869
root := fmt.Sprintf(tcRootQDisc, cfg.Device)
69-
strs := []string{tcAddQDisc, root, "htb"}
70+
strs := []string{tcAddQDisc, root, "htb", tcRootExtra}
7071
cmd := strings.Join(strs, " ")
7172

7273
return c.execute(cmd)
@@ -94,8 +95,8 @@ func addTargetClass(cfg *Config, c commander) error {
9495
tar := fmt.Sprintf(tcTargetClass, cfg.Device)
9596
rate := ""
9697

97-
if cfg.DefaultBandwidth > -1 {
98-
rate = fmt.Sprintf(tcRate, cfg.DefaultBandwidth)
98+
if cfg.TargetBandwidth > -1 {
99+
rate = fmt.Sprintf(tcRate, cfg.TargetBandwidth)
99100
} else {
100101
rate = fmt.Sprintf(tcRate, 1000000)
101102
}

0 commit comments

Comments
 (0)