]> Cypherpunks.ru repositories - govpn.git/blobdiff - tap.go
Explicitly store payload size in each message
[govpn.git] / tap.go
diff --git a/tap.go b/tap.go
index 6b298f713861ec621183dd4f546d00f2fd7afe77..8a19df344530ef7e181a92ce4790c68b9ad2fe44 100644 (file)
--- a/tap.go
+++ b/tap.go
@@ -24,6 +24,10 @@ import (
        "golang.org/x/crypto/poly1305"
 )
 
+const (
+       EtherSize = 14
+)
+
 type TAP struct {
        Name   string
        dev    io.ReadWriter
@@ -33,8 +37,12 @@ type TAP struct {
        synced bool
 }
 
+func TAPMaxMTU() int {
+       return MTU - poly1305.TagSize - NonceSize - PktSizeSize - EtherSize
+}
+
 func NewTAP(ifaceName string) (*TAP, error) {
-       maxIfacePktSize := MTU - poly1305.TagSize - NonceSize
+       maxIfacePktSize := TAPMaxMTU() + EtherSize
        tapRaw, err := newTAPer(ifaceName)
        if err != nil {
                return nil, err