From f16c6a65170d77092f55b204cb7687202240c190 Mon Sep 17 00:00:00 2001 From: psondej Date: Tue, 10 Dec 2024 13:42:42 +0100 Subject: [PATCH 1/2] Fix incorrect size check in NFGenMsg, resolving TableFamily issue for rules in monitor --- util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] From 6904ccab40b58eca44bb969eaf95e77f3a37072a Mon Sep 17 00:00:00 2001 From: psondej Date: Wed, 11 Dec 2024 18:26:22 +0100 Subject: [PATCH 2/2] Add test for checking rule TableFamily --- monitor_test.go | 3 +++ 1 file changed, 3 insertions(+) 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") }