From eb340357409e90e57f49ce65fef9a233f17c4a24 Mon Sep 17 00:00:00 2001 From: patryk4815 Date: Fri, 13 Dec 2024 07:30:25 +0100 Subject: [PATCH] Fix incorrect size check in NFGenMsg (#287) Fix incorrect size check in NFGenMsg, resolving TableFamily issue for rules in monitor --- monitor_test.go | 3 +++ util.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/monitor_test.go b/monitor_test.go index d690432..5640e13 100644 --- a/monitor_test.go +++ b/monitor_test.go @@ -156,6 +156,9 @@ func TestMonitor(t *testing.T) { *gotChain.Hooknum != *postrouting.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) { t.Fatal("no want rule") } diff --git a/util.go b/util.go index 4f03dc0..b040ae4 100644 --- a/util.go +++ b/util.go @@ -38,7 +38,7 @@ type NFGenMsg struct { } func (genmsg *NFGenMsg) Decode(b []byte) { - if len(b) < 16 { + if len(b) < 4 { return } genmsg.NFGenFamily = b[0]