chore: allow set nfqueue num to 0

This commit is contained in:
Haruue 2024-10-27 15:44:04 +09:00
parent d3f1785ac9
commit d8d7c5b477
No known key found for this signature in database
GPG Key ID: F6083B28CBCBC148
2 changed files with 13 additions and 12 deletions

View File

@ -174,7 +174,7 @@ type cliConfig struct {
type cliConfigIO struct { type cliConfigIO struct {
QueueSize uint32 `mapstructure:"queueSize"` QueueSize uint32 `mapstructure:"queueSize"`
QueueNum uint16 `mapstructure:"queueNum"` QueueNum *uint16 `mapstructure:"queueNum"`
Table string `mapstructure:"table"` Table string `mapstructure:"table"`
ReadBuffer int `mapstructure:"rcvBuf"` ReadBuffer int `mapstructure:"rcvBuf"`
WriteBuffer int `mapstructure:"sndBuf"` WriteBuffer int `mapstructure:"sndBuf"`

View File

@ -110,7 +110,7 @@ type nfqueuePacketIO struct {
type NFQueuePacketIOConfig struct { type NFQueuePacketIOConfig struct {
QueueSize uint32 QueueSize uint32
QueueNum uint16 QueueNum *uint16
Table string Table string
ReadBuffer int ReadBuffer int
WriteBuffer int WriteBuffer int
@ -122,8 +122,9 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
if config.QueueSize == 0 { if config.QueueSize == 0 {
config.QueueSize = nfqueueDefaultQueueSize config.QueueSize = nfqueueDefaultQueueSize
} }
if config.QueueNum == 0 { if config.QueueNum == nil {
config.QueueNum = nfqueueDefaultQueueNum queueNum := uint16(nfqueueDefaultQueueNum)
config.QueueNum = &queueNum
} }
if config.Table == "" { if config.Table == "" {
config.Table = nftDefaultTable config.Table = nftDefaultTable
@ -142,7 +143,7 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
} }
} }
n, err := nfqueue.Open(&nfqueue.Config{ n, err := nfqueue.Open(&nfqueue.Config{
NfQueue: config.QueueNum, NfQueue: *config.QueueNum,
MaxPacketLen: nfqueueMaxPacketLen, MaxPacketLen: nfqueueMaxPacketLen,
MaxQueueLen: config.QueueSize, MaxQueueLen: config.QueueSize,
Copymode: nfqueue.NfQnlCopyPacket, Copymode: nfqueue.NfQnlCopyPacket,
@ -169,7 +170,7 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
n: n, n: n,
local: config.Local, local: config.Local,
rst: config.RST, rst: config.RST,
queueNum: int(config.QueueNum), queueNum: int(*config.QueueNum),
table: config.Table, table: config.Table,
ipt4: ipt4, ipt4: ipt4,
ipt6: ipt6, ipt6: ipt6,