Skip to content

Commit

Permalink
Merge pull request #8884 from tomastigera/tomas-bpf-bpfin-out-cleanup
Browse files Browse the repository at this point in the history
Cleanup bpfin/out.cali when BPF is turned off
  • Loading branch information
marvin-tigera authored Jun 6, 2024
2 parents afc7ce6 + 7756875 commit b37a4bb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions felix/dataplane/linux/bpf_ep_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4176,3 +4176,19 @@ func (pa *jumpMapAlloc) checkFreeLockHeld(idx int) {
}).Panic("jumpMapAlloc: Free set and free stack got out of sync")
}
}

func removeBPFSpecialDevices() {
bpfin, err := netlink.LinkByName(bpfInDev)
if err != nil {
if errors.Is(err, netlink.LinkNotFoundError{}) {
return
}
log.WithError(err).Warnf("Failed to make sure that %s/%s device is (not) present.", bpfInDev, bpfOutDev)
return
}

err = netlink.LinkDel(bpfin)
if err != nil {
log.WithError(err).Warnf("Failed to remove %s/%s device.", bpfInDev, bpfOutDev)
}
}
1 change: 1 addition & 0 deletions felix/dataplane/linux/int_dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ func NewIntDataplaneDriver(config Config) *InternalDataplane {
log.WithError(err).Info("Failed to remove BPF connect-time load balancer, ignoring.")
}
tc.CleanUpProgramsAndPins()
removeBPFSpecialDevices()
} else {
// In BPF mode we still use iptables for raw egress policy.
dp.RegisterManager(newRawEgressPolicyManager(rawTableV4, ruleRenderer, 4, ipSetsV4.SetFilter))
Expand Down
7 changes: 6 additions & 1 deletion felix/fv/bpf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ func describeBPFTests(opts ...bpfTestOpt) bool {
It("should cleanup after we disable eBPF", func() {
By("Waiting for dp to get setup up")

ensureAllNodesBPFProgramsAttached(tc.Felixes)
ensureBPFProgramsAttached(tc.Felixes[0], "bpfout.cali")

By("Changing env and restarting felix")

Expand All @@ -1112,6 +1112,11 @@ func describeBPFTests(opts ...bpfTestOpt) bool {
out, _ := tc.Felixes[0].ExecOutput("bpftool", "-jp", "map", "show")
return out
}, "15s", "1s").ShouldNot(Or(ContainSubstring("cali_"), ContainSubstring("xdp_cali_")))

out, _ := tc.Felixes[0].ExecCombinedOutput("ip", "link", "show", "dev", "bpfin.cali")
Expect(out).To(Equal("Device \"bpfin.cali\" does not exist.\n"))
out, _ = tc.Felixes[0].ExecCombinedOutput("ip", "link", "show", "dev", "bpfout.cali")
Expect(out).To(Equal("Device \"bpfout.cali\" does not exist.\n"))
})
}
})
Expand Down

0 comments on commit b37a4bb

Please sign in to comment.