Skip to content

Commit

Permalink
[BPF] clean up the right progs when ebpf is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tomastigera committed Dec 19, 2024
1 parent b88f571 commit be41db2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions felix/bpf/nat/connecttime.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const (
ProgIndexCTLBConnectV6 = iota
ProgIndexCTLBSendV6
ProgIndexCTLBRecvV6

ProgNamePrefix = "calico_"
)

var ctlbProgToIndex = map[string]int{
Expand Down Expand Up @@ -81,6 +83,7 @@ func RemoveConnectTimeLoadBalancer(cgroupv2 string) error {
cmd := exec.Command("bpftool", "-j", "-p", "cgroup", "show", cgroupPath)
log.WithField("args", cmd.Args).Info("Running bpftool to look up programs attached to cgroup")
out, err := cmd.Output()
fmt.Printf("XXX out = %+v\n", string(out))
if err != nil || strings.TrimSpace(string(out)) == "" {
log.WithError(err).WithField("output", string(out)).Info(
"Failed to list BPF programs. Assuming not supported/nothing to clean up.")
Expand All @@ -96,7 +99,7 @@ func RemoveConnectTimeLoadBalancer(cgroupv2 string) error {
}

for _, p := range progs {
if !strings.HasPrefix(p.Name, "cali_") {
if !strings.HasPrefix(p.Name, ProgNamePrefix) {
continue
}

Expand Down Expand Up @@ -164,7 +167,7 @@ func attachProgram(name, ipver, bpfMount, cgroupPath string, udpNotSeen time.Dur
progPinDir := path.Join(bpfMount, "calico_connect4")
_ = os.RemoveAll(progPinDir)

progName := "calico_" + name + "_v" + ipver
progName := ProgNamePrefix + name + "_v" + ipver

// N.B. no need to remember the link since we are never going to detach
// these programs unless Felix restarts.
Expand Down

0 comments on commit be41db2

Please sign in to comment.