Fix incorrect size check in NFGenMsg (#287)

Fix incorrect size check in NFGenMsg, resolving TableFamily issue for rules in monitor
This commit is contained in:
patryk4815 2024-12-13 07:30:25 +01:00 committed by GitHub
parent c96bb6363f
commit eb34035740
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -156,6 +156,9 @@ func TestMonitor(t *testing.T) {
*gotChain.Hooknum != *postrouting.Hooknum { *gotChain.Hooknum != *postrouting.Hooknum {
t.Fatal("no want chain", gotChain.Type, gotChain.Name, gotChain.Hooknum) t.Fatal("no want chain", gotChain.Type, gotChain.Name, gotChain.Hooknum)
} }
if gotRule.Table.Family != nat.Family {
t.Fatal("rule wrong family", gotRule.Table.Family, gotRule.Table.Name)
}
if len(gotRule.Exprs) != len(rule.Exprs) { if len(gotRule.Exprs) != len(rule.Exprs) {
t.Fatal("no want rule") t.Fatal("no want rule")
} }

View File

@ -38,7 +38,7 @@ type NFGenMsg struct {
} }
func (genmsg *NFGenMsg) Decode(b []byte) { func (genmsg *NFGenMsg) Decode(b []byte) {
if len(b) < 16 { if len(b) < 4 {
return return
} }
genmsg.NFGenFamily = b[0] genmsg.NFGenFamily = b[0]