mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 23:46:52 +01:00
tio: Count superpacket segments on Packet
Move the staged transmit segment count onto tio.Packet, next to IsSuperpacket and SegmentSuperpacket, which it predicts.
This commit is contained in:
1 parent
eb073d6c23
commit
ffb2835f70
3 files changed
+15
-15
No files matched your search
@@ -75,6 +75,15 @@ type GSOInfo struct {
|
||||
// superpacket that needs segmentation before its bytes can be encrypted and sent on the wire.
|
||||
func (g GSOInfo) IsSuperpacket() bool { return g.Size > 0 }
|
||||
|
||||
// SegmentCount reports how many segments SegmentSuperpacket will cut p into, without touching its bytes.
|
||||
func (p Packet) SegmentCount() int {
|
||||
if !p.GSO.IsSuperpacket() {
|
||||
return 1
|
||||
}
|
||||
n := (len(p.Bytes) - int(p.GSO.HdrLen) + int(p.GSO.Size) - 1) / int(p.GSO.Size)
|
||||
return max(n, 1)
|
||||
}
|
||||
|
||||
// Clone returns a Packet whose Bytes is a freshly allocated copy of p.Bytes,
|
||||
// safe to retain past the next Read or Close on the originating Queue.
|
||||
// GSO metadata is copied verbatim.
|
||||
|
||||
Reference in new issue
Block a user