From 594585af331a41c4275f91fbac3b388ba19e85f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4r?= Date: Wed, 26 Feb 2025 12:18:20 +0100 Subject: [PATCH] Initialize registers in test Recent kernels disallow reads from uninitialized registers, which breaks this test. See https://github.com/torvalds/linux/commit/14fb07130c7ddd257e30079b87499b3f89097b09 --- nftables_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nftables_test.go b/nftables_test.go index ba317b4..d1603c1 100644 --- a/nftables_test.go +++ b/nftables_test.go @@ -622,6 +622,14 @@ func TestMasqMarshalUnmarshal(t *testing.T) { Table: filter, Chain: postrouting, Exprs: []expr.Any{ + &expr.Immediate{ + Register: min, + Data: binaryutil.BigEndian.PutUint16(4070), + }, + &expr.Immediate{ + Register: max, + Data: binaryutil.BigEndian.PutUint16(4090), + }, &expr.Masq{ ToPorts: true, RegProtoMin: min, @@ -652,13 +660,13 @@ func TestMasqMarshalUnmarshal(t *testing.T) { } rule := rules[0] - if got, want := len(rule.Exprs), 1; got != want { + if got, want := len(rule.Exprs), 3; got != want { t.Fatalf("unexpected number of exprs: got %d, want %d", got, want) } - me, ok := rule.Exprs[0].(*expr.Masq) + me, ok := rule.Exprs[2].(*expr.Masq) if !ok { - t.Fatalf("unexpected expression type: got %T, want *expr.Masq", rule.Exprs[0]) + t.Fatalf("unexpected expression type: got %T, want *expr.Masq", rule.Exprs[2]) } if got, want := me.ToPorts, true; got != want {