mirror of
https://github.com/apernet/OpenGFW.git
synced 2024-12-23 01:19:21 +08:00
fix: engine exit when too many packets hit NFQUEUE
This commit is contained in:
parent
bc2e21e35d
commit
bed34f94be
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/coreos/go-iptables/iptables"
|
"github.com/coreos/go-iptables/iptables"
|
||||||
"github.com/florianl/go-nfqueue"
|
"github.com/florianl/go-nfqueue"
|
||||||
"github.com/mdlayher/netlink"
|
"github.com/mdlayher/netlink"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -152,6 +153,12 @@ func (n *nfqueuePacketIO) Register(ctx context.Context, cb PacketCallback) error
|
|||||||
return okBoolToInt(cb(p, nil))
|
return okBoolToInt(cb(p, nil))
|
||||||
},
|
},
|
||||||
func(e error) int {
|
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))
|
return okBoolToInt(cb(nil, e))
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user