From 7b3d58b87ea5b7a68e6dad8a0bd774d0efe3e256 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 19 Aug 2015 16:51:48 -0700 Subject: [PATCH] skip qdiscs from other interfaces --- qdisc_linux.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/qdisc_linux.go b/qdisc_linux.go index 25669cb..4d30b51 100644 --- a/qdisc_linux.go +++ b/qdisc_linux.go @@ -65,13 +65,15 @@ func QdiscAdd(qdisc Qdisc) error { // The list can be filtered by link. func QdiscList(link Link) ([]Qdisc, error) { req := nl.NewNetlinkRequest(syscall.RTM_GETQDISC, syscall.NLM_F_DUMP) - msg := &nl.TcMsg{ - Family: nl.FAMILY_ALL, - } + index := int32(0) if link != nil { base := link.Attrs() ensureIndex(base) - msg.Ifindex = int32(base.Index) + index = int32(base.Index) + } + msg := &nl.TcMsg{ + Family: nl.FAMILY_ALL, + Ifindex: index, } req.AddData(msg) @@ -80,7 +82,6 @@ func QdiscList(link Link) ([]Qdisc, error) { return nil, err } - //native := nl.NativeEndian() var res []Qdisc for _, m := range msgs { msg := nl.DeserializeTcMsg(m) @@ -90,6 +91,11 @@ func QdiscList(link Link) ([]Qdisc, error) { return nil, err } + // skip qdiscs from other interfaces + if link != nil && msg.Ifindex != index { + continue + } + base := QdiscAttrs{ LinkIndex: int(msg.Ifindex), Handle: msg.Handle,