summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/header
diff options
context:
space:
mode:
authorBhasker Hariharan <bhaskerh@google.com>2018-11-09 14:37:42 -0800
committerShentubot <shentubot@google.com>2018-11-09 14:38:46 -0800
commit33089561b1d53dada959a312ab69574cd6635b4b (patch)
tree7b497da71c6c238eafe4faf49bb2a9bbb0b4cddf /pkg/tcpip/header
parent93e88760b0d0c9c6656f7773f68540b1853d169b (diff)
Add an implementation of a SACK scoreboard as per RFC6675.
PiperOrigin-RevId: 220866996 Change-Id: I89d48215df57c00d6a6ec512fc18712a2ea9080b
Diffstat (limited to 'pkg/tcpip/header')
-rw-r--r--pkg/tcpip/header/BUILD1
-rw-r--r--pkg/tcpip/header/tcp.go11
2 files changed, 12 insertions, 0 deletions
diff --git a/pkg/tcpip/header/BUILD b/pkg/tcpip/header/BUILD
index 66b37720c..8e455fe1e 100644
--- a/pkg/tcpip/header/BUILD
+++ b/pkg/tcpip/header/BUILD
@@ -24,6 +24,7 @@ go_library(
"//pkg/tcpip",
"//pkg/tcpip/buffer",
"//pkg/tcpip/seqnum",
+ "@com_github_google_btree//:go_default_library",
],
)
diff --git a/pkg/tcpip/header/tcp.go b/pkg/tcpip/header/tcp.go
index 567a21167..207046b36 100644
--- a/pkg/tcpip/header/tcp.go
+++ b/pkg/tcpip/header/tcp.go
@@ -17,6 +17,7 @@ package header
import (
"encoding/binary"
+ "github.com/google/btree"
"gvisor.googlesource.com/gvisor/pkg/tcpip"
"gvisor.googlesource.com/gvisor/pkg/tcpip/seqnum"
)
@@ -131,6 +132,16 @@ type SACKBlock struct {
End seqnum.Value
}
+// Less returns true if r.Start < b.Start.
+func (r SACKBlock) Less(b btree.Item) bool {
+ return r.Start.LessThan(b.(SACKBlock).Start)
+}
+
+// Contains returns true if b is completely contained in r.
+func (r SACKBlock) Contains(b SACKBlock) bool {
+ return r.Start.LessThanEq(b.Start) && b.End.LessThanEq(r.End)
+}
+
// TCPOptions are used to parse and cache the TCP segment options for a non
// syn/syn-ack segment.
//