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

Fix softnet CPU Index #517

Merged
merged 1 commit into from
May 20, 2023
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
5 changes: 5 additions & 0 deletions net_softnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func parseSoftnet(r io.Reader) ([]SoftnetStat, error) {
s := bufio.NewScanner(r)

var stats []SoftnetStat
cpuIndex := 0
for s.Scan() {
columns := strings.Fields(s.Text())
width := len(columns)
Expand Down Expand Up @@ -127,9 +128,13 @@ func parseSoftnet(r io.Reader) ([]SoftnetStat, error) {

softnetStat.SoftnetBacklogLen = us[0]
softnetStat.Index = us[1]
} else {
// For older kernels, create the Index based on the scan line number.
softnetStat.Index = uint32(cpuIndex)
}
softnetStat.Width = width
stats = append(stats, softnetStat)
cpuIndex++
}

return stats, nil
Expand Down
3 changes: 3 additions & 0 deletions net_softnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ func TestNetSoftnet(t *testing.T) {
CPUCollision: 0x00000004,
ReceivedRps: 0x00000003,
FlowLimitCount: 0x00000002,
Index: 0x00000002,
Width: 11,
},
{
Processed: 0x01663fb2,
Dropped: 0x00000000,
TimeSqueezed: 0x0109a4,
CPUCollision: 0x00020e76,
Index: 0x00000003,
Width: 9,
},
{
Expand All @@ -70,6 +72,7 @@ func TestNetSoftnet(t *testing.T) {
TimeSqueezed: 0x00000011,
CPUCollision: 0x00000020,
ReceivedRps: 0x00000010,
Index: 0x00000004,
Width: 10,
},
}
Expand Down