Skip to content

Commit

Permalink
gh-494 In any panic, we need to gracefully exit and unload eBPF at th…
Browse files Browse the repository at this point in the history
…e min
  • Loading branch information
TrekkieCoder committed Jan 24, 2024
1 parent ebafceb commit b2bce38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (e *DpEbpfH) DpEbpfUnInit() {
e.ToFinCh[i] <- 1
}

tk.LogIt(tk.LogInfo, "ebpf uninit \n")
tk.LogIt(tk.LogInfo, "ebpf uninit : %s\n", debug.Stack())

// Make sure to unload eBPF programs
ifList, err := net.Interfaces()
Expand Down
21 changes: 10 additions & 11 deletions loxinet/loxinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,6 @@ func loxiNetInit() {
logLevel := LogString2Level(opts.Opts.LogLevel)
mh.logger = tk.LogItInit(logfile, logLevel, true)

// Stack trace logger
defer func() {
if e := recover(); e != nil {
tk.LogIt(tk.LogCritical, "%s: %s", e, debug.Stack())
}
if mh.dp != nil {
mh.dp.DpHooks.DpEbpfUnInit()
}
os.Exit(1)
}()

// It is important to make sure loxilb's eBPF filesystem
// is in place and mounted to make sure maps are pinned properly
if !FileExists(BpfFsCheckFile) {
Expand Down Expand Up @@ -327,6 +316,16 @@ func loxiNetInit() {

// loxiNetRun - This routine will not return
func loxiNetRun() {
// Stack trace logger
defer func() {
if e := recover(); e != nil {
tk.LogIt(tk.LogCritical, "%s: %s", e, debug.Stack())
}
if mh.dp != nil {
mh.dp.DpHooks.DpEbpfUnInit()
}
os.Exit(1)
}()
mh.wg.Wait()
}

Expand Down

0 comments on commit b2bce38

Please sign in to comment.