Compare commits

..

2 Commits

Author SHA1 Message Date
Jan Schär acda3fc5fe
Merge a086a5b137 into 385f80f4ef 2025-02-26 18:39:29 +01:00
Jan Schär a086a5b137 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-26 18:27:57 +01:00
1 changed files with 1 additions and 2 deletions

3
set.go
View File

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