File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,9 @@ type Set struct {
261261 Timeout time.Duration
262262 KeyType SetDatatype
263263 DataType SetDatatype
264+ // Either host (binaryutil.NativeEndian) or big (binaryutil.BigEndian) endian as per
265+ // https://git.netfilter.org/nftables/tree/include/datatype.h?id=d486c9e626405e829221b82d7355558005b26d8a#n109
266+ KeyByteOrder binaryutil.ByteOrder
264267}
265268
266269// SetElement represents a data point within a set.
@@ -560,11 +563,11 @@ func (cc *Conn) AddSet(s *Set, vals []SetElement) error {
560563 // Marshal concat size description as set description
561564 tableInfo = append (tableInfo , netlink.Attribute {Type : unix .NLA_F_NESTED | unix .NFTA_SET_DESC , Data : concatBytes })
562565 }
563- if s .Anonymous || s .Constant || s .Interval {
566+ if s .Anonymous || s .Constant || s .Interval || s . KeyByteOrder == binaryutil . BigEndian {
564567 tableInfo = append (tableInfo ,
565568 // Semantically useless - kept for binary compatability with nft
566569 netlink.Attribute {Type : unix .NFTA_SET_USERDATA , Data : []byte ("\x00 \x04 \x02 \x00 \x00 \x00 " )})
567- } else if ! s . IsMap {
570+ } else if s . KeyByteOrder == binaryutil . NativeEndian {
568571 // Per https://git.netfilter.org/nftables/tree/src/mnl.c?id=187c6d01d35722618c2711bbc49262c286472c8f#n1165
569572 tableInfo = append (tableInfo ,
570573 netlink.Attribute {Type : unix .NFTA_SET_USERDATA , Data : []byte ("\x00 \x04 \x01 \x00 \x00 \x00 " )})
You can’t perform that action at this time.
0 commit comments