fix: should correctly set dialer alive property

This commit is contained in:
mzz2017
2023-02-08 21:50:47 +08:00
committed by mzz
parent 410bfd0691
commit e87c7fa89d
3 changed files with 19 additions and 2 deletions

View File

@ -5,10 +5,20 @@
package control
import "github.com/cilium/ebpf"
import (
"github.com/cilium/ebpf"
"github.com/sirupsen/logrus"
)
func (c *ControlPlaneCore) OutboundAliveChangeCallback(outbound uint8) func(alive bool, l4proto uint8, ipversion uint8) {
return func(alive bool, l4proto uint8, ipversion uint8) {
c.log.WithFields(logrus.Fields{
"alive": alive,
"l4proto": l4proto,
"ipversion": ipversion,
"outbound_id": outbound,
}).Tracef("outbound alive state changed")
value := uint32(0)
if alive {
value = 1

View File

@ -206,6 +206,12 @@ getNew:
}
// If the udp endpoint has been not alive, remove it from pool and get a new one.
if !isNew && !ue.Dialer.MustGetAlive(l4proto, ipversion) {
c.log.WithFields(logrus.Fields{
"src": src.String(),
"l4proto": l4proto,
"ipversion": ipversion,
"dialer": ue.Dialer.Name(),
}).Debugln("Old udp endpoint is not alive and removed")
_ = DefaultUdpEndpointPool.Remove(src, ue)
goto getNew
}