skip qdiscs from other interfaces

This commit is contained in:
Vishvananda Ishaya 2015-08-19 16:51:48 -07:00 committed by Vishvananda Ishaya
parent acc8a28738
commit 7b3d58b87e
1 changed files with 11 additions and 5 deletions

View File

@ -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,