]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/net/mptcpsock_linux_test.go
net: mptcp: add TCPConn's MultipathTCP checker
[gostls13.git] / src / net / mptcpsock_linux_test.go
index 11543b0c8c947a2b91ef3d136c64bc5cb595f90b..bf8fc951c53ffc80faac6b5144937f1558837870 100644 (file)
@@ -40,11 +40,28 @@ func postAcceptMPTCP(ls *localServer, ch chan<- error) {
 
        c := ls.cl[0]
 
-       _, ok := c.(*TCPConn)
+       tcp, ok := c.(*TCPConn)
        if !ok {
                ch <- errors.New("struct is not a TCPConn")
                return
        }
+
+       mptcp, err := tcp.MultipathTCP()
+       if err != nil {
+               ch <- err
+               return
+       }
+
+       if !mptcp {
+               ch <- errors.New("incoming connection is not with MPTCP")
+               return
+       }
+
+       // Also check the method for the older kernels if not tested before
+       if hasSOLMPTCP && !isUsingMPTCPProto(tcp.fd) {
+               ch <- errors.New("incoming connection is not an MPTCP proto")
+               return
+       }
 }
 
 func dialerMPTCP(t *testing.T, addr string) {
@@ -64,7 +81,7 @@ func dialerMPTCP(t *testing.T, addr string) {
        }
        defer c.Close()
 
-       _, ok := c.(*TCPConn)
+       tcp, ok := c.(*TCPConn)
        if !ok {
                t.Fatal("struct is not a TCPConn")
        }
@@ -82,7 +99,21 @@ func dialerMPTCP(t *testing.T, addr string) {
                t.Errorf("sent bytes (%s) are different from received ones (%s)", snt, b)
        }
 
-       t.Logf("outgoing connection from %s with mptcp", addr)
+       mptcp, err := tcp.MultipathTCP()
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       t.Logf("outgoing connection from %s with mptcp: %t", addr, mptcp)
+
+       if !mptcp {
+               t.Error("outgoing connection is not with MPTCP")
+       }
+
+       // Also check the method for the older kernels if not tested before
+       if hasSOLMPTCP && !isUsingMPTCPProto(tcp.fd) {
+               t.Error("outgoing connection is not an MPTCP proto")
+       }
 }
 
 func canCreateMPTCPSocket() bool {