Tries to fully populate Set.KeyType if it's a simple type.

Set.DataType also gets the full type descriptor. No changes in
behavior for concatenated datatypes.
This commit is contained in:
Tommie Gannert 2021-09-08 20:54:47 +02:00 committed by Michael Stapelberg
parent 3a4a2bce5f
commit 16a134723a
1 changed files with 7 additions and 0 deletions

7
set.go
View File

@ -591,6 +591,13 @@ func setsFromMsg(msg netlink.Message) (*Set, error) {
return nil, fmt.Errorf("could not determine key type %+v", invalidMagic) return nil, fmt.Errorf("could not determine key type %+v", invalidMagic)
} }
set.KeyType.nftMagic = nftMagic set.KeyType.nftMagic = nftMagic
for _, dt := range nftDatatypes {
// If this is a non-concatenated type, we can assign the descriptor.
if nftMagic == dt.nftMagic {
set.KeyType = dt
break
}
}
case unix.NFTA_SET_DATA_TYPE: case unix.NFTA_SET_DATA_TYPE:
nftMagic := ad.Uint32() nftMagic := ad.Uint32()
// Special case for the data type verdict, in the message it is stored as 0xffffff00 but it is defined as 1 // Special case for the data type verdict, in the message it is stored as 0xffffff00 but it is defined as 1