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

Enhance bpf interface autodetection #9498

Merged
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: 3 additions & 3 deletions felix/bpf/ut/attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func runAttachTest(t *testing.T, ipv6Enabled bool) {
)
Expect(err).NotTo(HaveOccurred())

host1 := createVethName("hostep1")
host1 := createHostIf("hostep1")
defer deleteLink(host1)

workload0 := createVethName("workloadep0")
Expand Down Expand Up @@ -278,7 +278,7 @@ func runAttachTest(t *testing.T, ipv6Enabled bool) {
Expect(xdpProgs).To(HaveLen(0))
})

host2 := createVethName("hostep2")
host2 := createHostIf("hostep2")
defer deleteLink(host2)

t.Run("create another host interface without a host endpoint (no policy)", func(t *testing.T) {
Expand Down Expand Up @@ -848,7 +848,7 @@ func TestLogFilters(t *testing.T) {
)
Expect(err).NotTo(HaveOccurred())

host1 := createVethName("hostep1")
host1 := createHostIf("hostep1")
defer deleteLink(host1)

workload0 := createVethName("workloadep0")
Expand Down
12 changes: 12 additions & 0 deletions felix/bpf/ut/precompilation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ func createVethName(name string) netlink.Link {
return veth
}

func createHostIf(name string) netlink.Link {
la := netlink.NewLinkAttrs()
la.Name = name
la.Flags = net.FlagUp
var hostIf netlink.Link = &netlink.Dummy{
LinkAttrs: la,
}
err := netlink.LinkAdd(hostIf)
ExpectWithOffset(1, err).NotTo(HaveOccurred(), fmt.Sprintf("failed to create test hostIf: %q", name))
return hostIf
}

func deleteLink(veth netlink.Link) {
err := netlink.LinkDel(veth)
Expect(err).NotTo(HaveOccurred(), "failed to delete test veth")
Expand Down
Loading
Loading