[PATCH mptcp-next 3/7] Add MPTCP client socket creation support

Geliang Tang posted 7 patches 6 months, 2 weeks ago
There is a newer version of this series
[PATCH mptcp-next 3/7] Add MPTCP client socket creation support
Posted by Geliang Tang 6 months, 2 weeks ago
This patch extends the socket creation API to support Multipath TCP
(MPTCP) for client sockets:

1. Added an overloaded 'socket' method that accepts an 'mptcp' parameter
   to explicitly enable/disable MPTCP
2. Introduced a convenience method 'mptcpSocket()' for creating
   MPTCP-enabled client sockets using the unspecified protocol family by
   default

The changes maintain consistency with the existing socket API while
providing first-class support for MPTCP client sockets. The implementation
builds upon the foundation laid in previous patches, utilizing the socket0
infrastructure with MPTCP protocol support.

Co-Developed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Geliang Tang <geliang@kernel.org>
---
 src/java.base/share/classes/sun/nio/ch/Net.java | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java
index aa3ed087d2c..cf5dbddc28c 100644
--- a/src/java.base/share/classes/sun/nio/ch/Net.java
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java
@@ -491,6 +491,16 @@ static FileDescriptor socket(ProtocolFamily family, boolean stream) throws IOExc
         return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK, false));
     }
 
+    static FileDescriptor socket(ProtocolFamily family, boolean stream, boolean mptcp) throws IOException {
+        boolean preferIPv6 = isIPv6Available() &&
+            (family != StandardProtocolFamily.INET);
+        return IOUtil.newFD(socket0(preferIPv6, stream, false, FAST_LOOPBACK, mptcp));
+    }
+
+    static FileDescriptor mptcpSocket() throws IOException {
+        return socket(UNSPEC, true, true);
+    }
+
     static FileDescriptor serverSocket() {
         return serverSocket(UNSPEC);
     }
-- 
2.48.1