mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-07 08:44:07 +01:00
Fix ebpf close function (#2672)
This commit is contained in:
parent
cfbcf507fb
commit
3dca6099d4
@ -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,8 +121,10 @@ func (p *WGEBPFProxy) Free() error {
|
||||
p.ctxCancel()
|
||||
|
||||
var result *multierror.Error
|
||||
if err := p.conn.Close(); err != nil {
|
||||
result = multierror.Append(result, err)
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user