Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TCA_HTB_DIRECT_QLEN in HTB qdisc #963

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions qdisc.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ type Htb struct {
Defcls uint32
Debug uint32
DirectPkts uint32
DirectQlen *uint32
}

func NewHtb(attrs QdiscAttrs) *Htb {
Expand All @@ -133,6 +134,7 @@ func NewHtb(attrs QdiscAttrs) *Htb {
Rate2Quantum: 10,
Debug: 0,
DirectPkts: 0,
DirectQlen: nil,
}
}

Expand Down
8 changes: 5 additions & 3 deletions qdisc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ func qdiscPayload(req *nl.NetlinkRequest, qdisc Qdisc) error {
opt.Debug = qdisc.Debug
opt.DirectPkts = qdisc.DirectPkts
options.AddRtAttr(nl.TCA_HTB_INIT, opt.Serialize())
// options.AddRtAttr(nl.TCA_HTB_DIRECT_QLEN, opt.Serialize())
if qdisc.DirectQlen != nil {
options.AddRtAttr(nl.TCA_HTB_DIRECT_QLEN, nl.Uint32Attr(*qdisc.DirectQlen))
}
case *Hfsc:
opt := nl.TcHfscOpt{}
opt.Defcls = qdisc.Defcls
Expand Down Expand Up @@ -525,8 +527,8 @@ func parseHtbData(qdisc Qdisc, data []syscall.NetlinkRouteAttr) error {
htb.Debug = opt.Debug
htb.DirectPkts = opt.DirectPkts
case nl.TCA_HTB_DIRECT_QLEN:
// TODO
//htb.DirectQlen = native.uint32(datum.Value)
directQlen := native.Uint32(datum.Value)
htb.DirectQlen = &directQlen
}
}
return nil
Expand Down
5 changes: 5 additions & 0 deletions qdisc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func TestHtbAddDel(t *testing.T) {

qdisc := NewHtb(attrs)
qdisc.Rate2Quantum = 5
directQlen := uint32(10)
qdisc.DirectQlen = &directQlen
if err := QdiscAdd(qdisc); err != nil {
t.Fatal(err)
}
Expand All @@ -111,6 +113,9 @@ func TestHtbAddDel(t *testing.T) {
if htb.Debug != qdisc.Debug {
t.Fatal("Debug doesn't match")
}
if htb.DirectQlen == nil || *htb.DirectQlen != directQlen {
t.Fatalf("DirectQlen doesn't match. Expected %d, got %v", directQlen, htb.DirectQlen)
}
if err := QdiscDel(qdisc); err != nil {
t.Fatal(err)
}
Expand Down
Loading