Skip to content

Commit

Permalink
Merge pull request tylertreat#54 from yousong/default-bw
Browse files Browse the repository at this point in the history
Fix shaping default bandwidth
  • Loading branch information
tylertreat committed Oct 13, 2016
2 parents af870f3 + a80dc9e commit 3552c1d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions throttler/tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

const (
tcRootQDisc = `dev %s handle 10: root`
tcRootExtra = `default 1`
tcDefaultClass = `dev %s parent 10: classid 10:1`
tcTargetClass = `dev %s parent 10:1 classid 10:10`
tcTargetClass = `dev %s parent 10: classid 10:10`
tcNetemRule = `dev %s parent 10:10 handle 100:`
tcRate = `rate %vkbit`
tcDelay = `delay %vms`
Expand Down Expand Up @@ -66,7 +67,7 @@ func (t *tcThrottler) setup(cfg *Config) error {
func addRootQDisc(cfg *Config, c commander) error {
//Add the root QDisc
root := fmt.Sprintf(tcRootQDisc, cfg.Device)
strs := []string{tcAddQDisc, root, "htb"}
strs := []string{tcAddQDisc, root, "htb", tcRootExtra}
cmd := strings.Join(strs, " ")

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

if cfg.DefaultBandwidth > -1 {
rate = fmt.Sprintf(tcRate, cfg.DefaultBandwidth)
if cfg.TargetBandwidth > -1 {
rate = fmt.Sprintf(tcRate, cfg.TargetBandwidth)
} else {
rate = fmt.Sprintf(tcRate, 1000000)
}
Expand Down

0 comments on commit 3552c1d

Please sign in to comment.