From bed34f94be612a8e59f51d4b6e1f019f4b0b038d Mon Sep 17 00:00:00 2001 From: Haruue Date: Mon, 26 Feb 2024 16:46:50 +0800 Subject: [PATCH] fix: engine exit when too many packets hit NFQUEUE --- io/nfqueue.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/io/nfqueue.go b/io/nfqueue.go index a4e5e2f..d299479 100644 --- a/io/nfqueue.go +++ b/io/nfqueue.go @@ -12,6 +12,7 @@ import ( "github.com/coreos/go-iptables/iptables" "github.com/florianl/go-nfqueue" "github.com/mdlayher/netlink" + "golang.org/x/sys/unix" ) const ( @@ -152,6 +153,12 @@ func (n *nfqueuePacketIO) Register(ctx context.Context, cb PacketCallback) error return okBoolToInt(cb(p, nil)) }, func(e error) int { + if opErr := (*netlink.OpError)(nil); errors.As(e, &opErr) { + if errors.Is(opErr.Err, unix.ENOBUFS) { + // Kernel buffer temporarily full, ignore + return 0 + } + } return okBoolToInt(cb(nil, e)) }) if err != nil {