mirror of
https://github.com/vishvananda/netlink
synced 2025-03-25 04:26:51 +00:00
Clarify ESN bitmap length construction logic
Signed-off-by: Alessandro Boch <aboch@tetrationanalytics.com>
This commit is contained in:
parent
a2af46a09c
commit
d35d6b58e1
@ -69,8 +69,10 @@ func writeReplayEsn(replayWindow int) []byte {
|
||||
ReplayWindow: uint32(replayWindow),
|
||||
}
|
||||
|
||||
// taken from iproute2/ip/xfrm_state.c:
|
||||
replayEsn.BmpLen = uint32((replayWindow + (4 * 8) - 1) / (4 * 8))
|
||||
// Linux stores the bitmap to identify the already received sequence packets in blocks of uint32 elements.
|
||||
// Therefore bitmap length is the minimum number of uint32 elements needed. The following is a ceiling operation.
|
||||
bytesPerElem := int(unsafe.Sizeof(replayEsn.BmpLen)) // Any uint32 variable is good for this
|
||||
replayEsn.BmpLen = uint32((replayWindow + (bytesPerElem * 8) - 1) / (bytesPerElem * 8))
|
||||
|
||||
return replayEsn.Serialize()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user