Created
November 25, 2015 07:29
-
-
Save chantra/19de76aea31414acd262 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/shaping/shaping_linux.go b/src/shaping/shaping_linux.go | |
index 9ed8dc5..c48306e 100644 | |
--- a/src/shaping/shaping_linux.go | |
+++ b/src/shaping/shaping_linux.go | |
@@ -330,17 +330,6 @@ func lookupInterfaces() (wan, lan netlink.Link, err error) { | |
} | |
func setupRootQdisc(link netlink.Link) error { | |
- // Clean out old qdiscs | |
- qdiscs, err := netlink.QdiscList(link) | |
- if err != nil { | |
- return err | |
- } | |
- for _, q := range qdiscs { | |
- if err := netlink.QdiscDel(q); err != nil { | |
- Log.Printf("warning: Could not delete root qdisc (%s): %v\n", link.Attrs().Name, err) | |
- } | |
- } | |
- | |
// Setup new HTB qdisc as root | |
root_qdisc := netlink.NewHtb(netlink.QdiscAttrs{ | |
LinkIndex: link.Attrs().Index, | |
@@ -348,8 +337,8 @@ func setupRootQdisc(link netlink.Link) error { | |
Handle: netlink.MakeHandle(1, 0), | |
}) | |
- if err := netlink.QdiscAdd(root_qdisc); err != nil { | |
- return fmt.Errorf("Could not create root qdisc (%s): %v", link.Attrs().Name, err) | |
+ if err := netlink.QdiscReplace(root_qdisc); err != nil { | |
+ return fmt.Errorf("Could not set root qdisc (%s): %v", link.Attrs().Name, err) | |
} | |
return nil | |
} | |
diff --git a/src/shaping/shaping_linux_test.go b/src/shaping/shaping_linux_test.go | |
index 43ad398..2453a9a 100644 | |
--- a/src/shaping/shaping_linux_test.go | |
+++ b/src/shaping/shaping_linux_test.go | |
@@ -18,7 +18,7 @@ func TestCreatesRootQdisc(t *testing.T) { | |
defer tearDown() | |
// Setup root qdisc. | |
- check(t, setupRootQdisc(link), "couldn't create root qdisc") | |
+ check(t, setupRootQdisc(link), "couldn't setup root qdisc") | |
// Check that the root qdisc exists. | |
qdiscs, err := netlink.QdiscList(link) | |
check(t, err, "couldn't list qdiscs") | |
@@ -44,7 +44,7 @@ func TestShapeOn(t *testing.T) { | |
tearDown, link := setUpNetlinkTest(t) | |
defer tearDown() | |
- check(t, setupRootQdisc(link), "couldn't create root qdisc") | |
+ check(t, setupRootQdisc(link), "couldn't setup root qdisc") | |
// Set up class + filters (ipv4/ipv6) using shape_on | |
mark := int64(5) | |
@@ -86,7 +86,7 @@ func TestShapeRate0(t *testing.T) { | |
tearDown, link := setUpNetlinkTest(t) | |
defer tearDown() | |
- check(t, setupRootQdisc(link), "couldn't create root qdisc") | |
+ check(t, setupRootQdisc(link), "couldn't setup root qdisc") | |
// Set up class + filters (ipv4/ipv6) using shape_on | |
mark := int64(5) | |
@@ -120,7 +120,7 @@ func TestShapeOff(t *testing.T) { | |
tearDown, link := setUpNetlinkTest(t) | |
defer tearDown() | |
- check(t, setupRootQdisc(link), "couldn't create root qdisc") | |
+ check(t, setupRootQdisc(link), "couldn't setup root qdisc") | |
// Set up class + filters (ipv4/ipv6) using shape_on | |
mark := int64(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment