ping: Fix stale flows kept alive by unrelated ICMP traffic

Unconnected raw ICMP sockets receive every ICMP packet arriving at the
host, so any ICMP traffic refreshed the read deadline of every flow and
stale flows (with their raw sockets and goroutines) accumulated forever,
making per-ping cost grow linearly with uptime.

Expire flows based on their own activity only, and on Linux attach a
classic BPF ident filter to each raw socket so other flows' packets are
dropped in the kernel instead of waking every flow.
This commit is contained in:
世界 2026-07-09 21:28:10 +08:00
parent b0188bc3f1
commit 23a39c59be
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 16 additions and 4 deletions

View file

@ -4,7 +4,7 @@ import (
"sync"
"syscall"
"github.com/sagernet/sing-tun/internal/gtcpip/header"
"github.com/sagernet/sing-tun/gtcpip/header"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/control"