mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-25 01:23:22 +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)
|
conn, err := nbnet.ListenUDP("udp", &addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cErr := p.Free()
|
if cErr := p.Free(); cErr != nil {
|
||||||
if cErr != nil {
|
|
||||||
log.Errorf("Failed to close the wgproxy: %s", cErr)
|
log.Errorf("Failed to close the wgproxy: %s", cErr)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@ -122,8 +121,10 @@ func (p *WGEBPFProxy) Free() error {
|
|||||||
p.ctxCancel()
|
p.ctxCancel()
|
||||||
|
|
||||||
var result *multierror.Error
|
var result *multierror.Error
|
||||||
if err := p.conn.Close(); err != nil {
|
if p.conn != nil { // p.conn will be nil if we have failed to listen
|
||||||
result = multierror.Append(result, err)
|
if err := p.conn.Close(); err != nil {
|
||||||
|
result = multierror.Append(result, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.ebpfManager.FreeWGProxy(); err != nil {
|
if err := p.ebpfManager.FreeWGProxy(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user