From e87c7fa89d8eeb9566b0f79cf32f789d692ba64b Mon Sep 17 00:00:00 2001 From: mzz2017 <2017@duck.com> Date: Wed, 8 Feb 2023 21:50:47 +0800 Subject: [PATCH] fix: should correctly set dialer alive property --- component/outbound/dialer/connectivity_check.go | 3 ++- control/connectivity.go | 12 +++++++++++- control/udp.go | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/component/outbound/dialer/connectivity_check.go b/component/outbound/dialer/connectivity_check.go index 3cf55b7..1e6d3f6 100644 --- a/component/outbound/dialer/connectivity_check.go +++ b/component/outbound/dialer/connectivity_check.go @@ -39,7 +39,7 @@ func newCollection() *collection { return &collection{ AliveDialerSetSet: make(AliveDialerSetSet), Latencies10: NewLatenciesN(10), - Alive: false, + Alive: true, } } @@ -270,6 +270,7 @@ func (d *Dialer) Check(timeout time.Duration, } latencies10 := collection.Latencies10 latencies10.AppendLatency(timeout) + collection.Alive = false } // Inform DialerGroups to update state. // We use lock because AliveDialerSetSet is a reference of that in collection. diff --git a/control/connectivity.go b/control/connectivity.go index ea3044f..effd67c 100644 --- a/control/connectivity.go +++ b/control/connectivity.go @@ -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 diff --git a/control/udp.go b/control/udp.go index bc48ad6..a022475 100644 --- a/control/udp.go +++ b/control/udp.go @@ -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 }