Skip to content
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
6 changes: 5 additions & 1 deletion internal/plumbing/ebpf/xdpmode/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ var sysClassNet = "/sys/class/net"
// target and has no driver link at all, as while its driver unbinds, carries
// no driver traffic; it is left out and listed in Skipped. An interface with
// no device link, such as a bond master, a veth or a VLAN, is virtual and has
// no driver of its own to consider.
// no driver of its own to consider. A regular file, such as the bonding
// driver's bonding_masters, is not an interface.
func Select(required ...string) (Decision, error) {
entries, err := os.ReadDir(sysClassNet)
if err != nil {
Expand All @@ -129,6 +130,9 @@ func Select(required ...string) (Decision, error) {
skipped []string
)
for _, e := range entries {
if e.Type().IsRegular() {
continue
}
name := e.Name()
present[name] = true
driver, physical, err := interfaceDriver(name)
Expand Down
11 changes: 11 additions & 0 deletions internal/plumbing/ebpf/xdpmode/mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ func (f *fakeSysfs) virtual(name string) {
}
}

// file adds a regular file, the way the bonding driver adds bonding_masters
// beside the interfaces.
func (f *fakeSysfs) file(name string) {
f.t.Helper()
if err := os.WriteFile(filepath.Join(sysClassNet, name), []byte("bond0 bond1\n"), 0o644); err != nil {
f.t.Fatal(err)
}
}

func TestSelect(t *testing.T) {
tests := []struct {
name string
Expand All @@ -97,6 +106,7 @@ func TestSelect(t *testing.T) {
f.physical(testNIC2, "ice")
f.virtual("lo")
f.virtual("bond0")
f.file("bonding_masters")
},
required: []string{testNIC1, testNIC2},
want: Native,
Expand All @@ -107,6 +117,7 @@ func TestSelect(t *testing.T) {
f.physical("ens1f0np0", "bnxt_en")
f.physical("ens3f0np0", "bnxt_en")
f.virtual("bond1")
f.file("bonding_masters")
},
required: []string{"ens1f0np0", "ens3f0np0"},
want: Generic,
Expand Down
Loading