Compare commits

..

2 Commits

Author SHA1 Message Date
Jan Schär f41a68b3df
Merge ed6f39bae8 into 385f80f4ef 2025-02-28 16:01:56 +00:00
Jan Schär ed6f39bae8 Split set elements into batches if needed
If the number of elements to be added to or removed from a set is large,
they may not all fit into one message, because the size field of a
netlink attribute is a uint16 and would overflow. To support this case,
the elements need to be split into multiple batches.
2025-02-28 17:01:21 +01:00
1 changed files with 2 additions and 1 deletions

3
set.go
View File

@ -18,6 +18,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"math"
"strings"
"time"
@ -395,7 +396,7 @@ func (cc *Conn) SetDeleteElements(s *Set, vals []SetElement) error {
// maxElemBatchSize is the maximum size in bytes of encoded set elements which
// are sent in one netlink message. The size field of a netlink attribute is a
// uint16, and 1024 bytes is more than enough for the per-message headers.
const maxElemBatchSize = 0x10000 - 1024
const maxElemBatchSize = math.MaxUint16 - 1024
func (cc *Conn) appendElemList(s *Set, vals []SetElement, hdrType uint16) error {
if len(vals) == 0 {