@@ -101,6 +101,17 @@ type ListenerSocketOptions struct {
101101 // Available on Linux, macOS, FreeBSD, and Windows.
102102 TCPFastOpen bool
103103
104+ // MultipathTCP enables multipath TCP on the listener.
105+ //
106+ // Unlike Go std, we make MPTCP strictly opt-in.
107+ // That is, if this field is false, MPTCP will be explicitly disabled.
108+ // This ensures that if Go std suddenly decides to enable MPTCP by default,
109+ // existing configurations won't encounter issues due to missing features in the kernel MPTCP stack,
110+ // such as TCP keepalive (as of Linux 6.5), and failed connect attempts won't always be retried once.
111+ //
112+ // Available on platforms supported by Go std's MPTCP implementation.
113+ MultipathTCP bool
114+
104115 // ReceivePacketInfo enables the reception of packet information control messages on the listener.
105116 //
106117 // Available on Linux, macOS, and Windows.
@@ -114,12 +125,14 @@ type ListenerSocketOptions struct {
114125
115126// ListenConfig returns a [ListenConfig] with a control function that sets the socket options.
116127func (lso ListenerSocketOptions ) ListenConfig () ListenConfig {
117- return ListenConfig {
128+ lc := ListenConfig {
118129 ListenConfig : net.ListenConfig {
119130 Control : lso .buildSetFns ().controlFunc (),
120131 },
121132 DisableTFO : ! lso .TCPFastOpen ,
122133 }
134+ lc .SetMultipathTCP (lso .MultipathTCP )
135+ return lc
123136}
124137
125138var (
@@ -186,16 +199,29 @@ type DialerSocketOptions struct {
186199 //
187200 // Available on Linux, macOS, FreeBSD, and Windows.
188201 TCPFastOpen bool
202+
203+ // MultipathTCP enables multipath TCP on the dialer.
204+ //
205+ // Unlike Go std, we make MPTCP strictly opt-in.
206+ // That is, if this field is false, MPTCP will be explicitly disabled.
207+ // This ensures that if Go std suddenly decides to enable MPTCP by default,
208+ // existing configurations won't encounter issues due to missing features in the kernel MPTCP stack,
209+ // such as TCP keepalive (as of Linux 6.5), and failed connect attempts won't always be retried once.
210+ //
211+ // Available on platforms supported by Go std's MPTCP implementation.
212+ MultipathTCP bool
189213}
190214
191215// Dialer returns a [Dialer] with a control function that sets the socket options.
192216func (dso DialerSocketOptions ) Dialer () Dialer {
193- return Dialer {
217+ d := Dialer {
194218 Dialer : net.Dialer {
195219 ControlContext : dso .buildSetFns ().controlContextFunc (),
196220 },
197221 DisableTFO : ! dso .TCPFastOpen ,
198222 }
223+ d .SetMultipathTCP (dso .MultipathTCP )
224+ return d
199225}
200226
201227var (
0 commit comments