Compare commits

...

4 Commits

Author SHA1 Message Date
Mikhail Sennikovsky 0a25fcafd0
Merge a0423c9897 into 0420ffbf57 2025-02-24 18:23:30 +01:00
Marten Seemann 0420ffbf57
fix unmarshalling of expr.Ct source register (#301) 2025-02-21 09:34:44 +01:00
Alexander 6f574e7fd1
added numgen case in exprFromName (#297) 2025-02-03 16:23:31 +01:00
Mikhail Sennikovsky a0423c9897 Fix set verdict data type unmarshalling
Currently unmarshalling sets with "verdict" data type results in
the "verdict" type to be set as the key type, and the data type
remaining zero.

Properly set the verdict type to Set DataType field instead of
the KeyType.

Signed-off-by: Mikhail Sennikovsky <mikhail.sennikovskii@ionos.com>
2024-11-18 16:23:28 +01:00
4 changed files with 14 additions and 1 deletions

View File

@ -186,6 +186,9 @@ func (e *Ct) unmarshal(fam byte, data []byte) error {
e.Register = ad.Uint32()
case unix.NFTA_CT_DIRECTION:
e.Direction = ad.Uint32()
case unix.NFTA_CT_SREG:
e.SourceRegister = true
e.Register = ad.Uint32()
}
}
return ad.Err()

View File

@ -38,6 +38,14 @@ func TestCt(t *testing.T) {
Direction: 1, // direction: reply
},
},
{
name: "Unmarshal Ct source register case",
ct: Ct{
Register: 1,
Key: CtKeySRC,
SourceRegister: true,
},
},
}
for _, tt := range tests {

View File

@ -209,6 +209,8 @@ func exprFromName(name string) Any {
e = &CtTimeout{}
case "fib":
e = &Fib{}
case "numgen":
e = &Numgen{}
}
return e
}

2
set.go
View File

@ -784,7 +784,7 @@ func setsFromMsg(msg netlink.Message) (*Set, error) {
nftMagic := ad.Uint32()
// Special case for the data type verdict, in the message it is stored as 0xffffff00 but it is defined as 1
if nftMagic == 0xffffff00 {
set.KeyType = TypeVerdict
set.DataType = TypeVerdict
break
}
dt, err := parseSetDatatype(nftMagic)