]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/net/tcpsock.go
net: mptcp: add TCPConn's MultipathTCP checker
[gostls13.git] / src / net / tcpsock.go
index f736f5a87819691341bc0b54981bdaf42268a2dd..358e48723b943772371061ac59c520d20808b04d 100644 (file)
@@ -219,6 +219,22 @@ func (c *TCPConn) SetNoDelay(noDelay bool) error {
        return nil
 }
 
+// MultipathTCP reports whether the ongoing connection is using MPTCP.
+//
+// If Multipath TCP is not supported by the host, by the other peer or
+// intentionally / accidentally filtered out by a device in between, a
+// fallback to TCP will be done. This method does its best to check if
+// MPTCP is still being used or not.
+//
+// On Linux, more conditions are verified on kernels >= v5.16, improving
+// the results.
+func (c *TCPConn) MultipathTCP() (bool, error) {
+       if !c.ok() {
+               return false, syscall.EINVAL
+       }
+       return isUsingMultipathTCP(c.fd), nil
+}
+
 func newTCPConn(fd *netFD, keepAlive time.Duration, keepAliveHook func(time.Duration)) *TCPConn {
        setNoDelay(fd, true)
        if keepAlive == 0 {