From bed34f94be612a8e59f51d4b6e1f019f4b0b038d Mon Sep 17 00:00:00 2001 From: Haruue Date: Mon, 26 Feb 2024 16:46:50 +0800 Subject: [PATCH 1/2] 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 { From 8bd34d779873c6f51e0d4b080313fe806107995e Mon Sep 17 00:00:00 2001 From: Haruue Date: Mon, 26 Feb 2024 16:48:39 +0800 Subject: [PATCH 2/2] chore: go mod tidy --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index dc0ca53..e3e739e 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.26.0 golang.org/x/crypto v0.19.0 + golang.org/x/sys v0.17.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -43,7 +44,6 @@ require ( golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect )