Fix ebpf close function (#2672)

This commit is contained in:
Zoltan Papp 2024-09-30 10:34:57 +02:00 committed by GitHub
parent cfbcf507fb
commit 3dca6099d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,8 +81,7 @@ func (p *WGEBPFProxy) Listen() error {
conn, err := nbnet.ListenUDP("udp", &addr)
if err != nil {
cErr := p.Free()
if cErr != nil {
if cErr := p.Free(); cErr != nil {
log.Errorf("Failed to close the wgproxy: %s", cErr)
}
return err
@ -122,9 +121,11 @@ func (p *WGEBPFProxy) Free() error {
p.ctxCancel()
var result *multierror.Error
if p.conn != nil { // p.conn will be nil if we have failed to listen
if err := p.conn.Close(); err != nil {
result = multierror.Append(result, err)
}
}
if err := p.ebpfManager.FreeWGProxy(); err != nil {
result = multierror.Append(result, err)