Skip to content

Commit

Permalink
Merge pull request #8887 from tomastigera/auto-pick-of-#8884-upstream…
Browse files Browse the repository at this point in the history
…-release-v3.28

[release-v3.28] Auto pick #8884: Cleanup bpfin/out.cali when BPF is turned off
  • Loading branch information
tomastigera authored Jun 7, 2024
2 parents d808d50 + 05fe504 commit 902fec6
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 @@ -4024,3 +4024,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 @@ -634,6 +634,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 902fec6

Please sign in to comment.