From 16a134723a9679a5cc4a63fe37f7624ccf7c07f9 Mon Sep 17 00:00:00 2001 From: Tommie Gannert Date: Wed, 8 Sep 2021 20:54:47 +0200 Subject: [PATCH] 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. --- set.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/set.go b/set.go index ea385d9..ca956c8 100644 --- a/set.go +++ b/set.go @@ -591,6 +591,13 @@ func setsFromMsg(msg netlink.Message) (*Set, error) { return nil, fmt.Errorf("could not determine key type %+v", invalidMagic) } 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: nftMagic := ad.Uint32() // Special case for the data type verdict, in the message it is stored as 0xffffff00 but it is defined as 1