Skip to content
Open
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
10 changes: 10 additions & 0 deletions class_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,13 @@ func parseTcStats2(data []byte) (*ClassStatistics, error) {

return stats, nil
}

func parseTcFqXStats(data []byte) (*nl.TcFqQdStats, error) {
buf := &bytes.Buffer{}
buf.Write(data)
stats := &nl.TcFqQdStats{}
if err := binary.Read(buf, native, stats); err != nil {
return nil, err
}
return stats, nil
}
18 changes: 18 additions & 0 deletions nl/tc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,24 @@ const (
TCA_FQ_HORIZON_DROP // drop packets beyond horizon, or cap their EDT
)

type TcFqQdStats struct {
GcFlows uint64
HighPrioPackets uint64
TcpRetrans uint64
Throttled uint64
FlowsPlimit uint64
PktsTooLong uint64
AllocationErrors uint64
TimeNextDelayedFlow int64
Flows uint32
InactiveFlows uint32
ThrottledFlows uint32
UnthrottleLatencyNs uint32
CeMark uint64 // packets above ce_threshold
HorizonDrops uint64
HorizonCaps uint64
}

const (
TCA_FQ_CODEL_UNSPEC = iota
TCA_FQ_CODEL_TARGET
Expand Down
4 changes: 4 additions & 0 deletions qdisc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package netlink
import (
"fmt"
"math"

"github.com/vishvananda/netlink/nl"
)

const (
Expand Down Expand Up @@ -308,6 +310,8 @@ type Fq struct {
LowRateThreshold uint32
Horizon uint32
HorizonDropPolicy uint8

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the empty line?

Stats *nl.TcFqQdStats
}

func (fq *Fq) String() string {
Expand Down
10 changes: 10 additions & 0 deletions qdisc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,16 @@ func (h *Handle) QdiscList(link Link) ([]Qdisc, error) {
return nil, err
}
base.Statistics = (*QdiscStatistics)(s)
case nl.TCA_XSTATS:
switch qdisc.Type() {
case "fq":
fq := qdisc.(*Fq)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this casting to line 499

s, err := parseTcFqXStats(attr.Value)
if err != nil {
return nil, err
}
fq.Stats = s
}
}
}
*qdisc.Attrs() = base
Expand Down
4 changes: 4 additions & 0 deletions qdisc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ func TestFqHorizon(t *testing.T) {
t.Fatal("HorizonDropPolicy does not match")
}

if fq.Stats.GcFlows != 0 || fq.Stats.ThrottledFlows != 0 || fq.Stats.HorizonDrops != 0 {
t.Fatal("Stats is not zero")
}

if err := QdiscDel(qdisc); err != nil {
t.Fatal(err)
}
Expand Down