-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MPTCP support #898
base: dev
Are you sure you want to change the base?
Add MPTCP support #898
Conversation
c20b5c0
to
6b6241f
Compare
channel.go
Outdated
var l net.Listener | ||
var err error | ||
if ch.enableMPTCP { | ||
lc := &net.ListenConfig{} | ||
lc.SetMultipathTCP(true) | ||
l, err = lc.Listen(context.Background(), "tcp", hostPort) | ||
} else { | ||
l, err = net.Listen("tcp", hostPort) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I can confirm the correctness of existing code. The source code:
func Listen(network, address string) (Listener, error) {
var lc ListenConfig
return lc.Listen(context.Background(), network, address)
}
We can simplify this block and skip the if/else check. When the option is false, it is safe to set it as well.
lc := &net.ListenConfig{}
lc.SetMultipathTCP(ch.enableMPTCP)
l, err := lc.Listen(context.Background(), "tcp", hostPort)
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev #898 +/- ##
==========================================
+ Coverage 88.78% 89.14% +0.36%
==========================================
Files 43 43
Lines 4440 4514 +74
==========================================
+ Hits 3942 4024 +82
+ Misses 379 374 -5
+ Partials 119 116 -3
☔ View full report in Codecov by Sentry. |
aab00ca
to
66fb29f
Compare
66fb29f
to
810b98d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please get approval from another reviewer
if opts.Dialer != nil { | ||
dialCtx = func(ctx context.Context, hostPort string) (net.Conn, error) { | ||
return opts.Dialer(ctx, "tcp", hostPort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if I set both EnableMPTCP
and Dialer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we added a comment regarding this
channel.go
Outdated
@@ -402,7 +415,9 @@ func (ch *Channel) ListenAndServe(hostPort string) error { | |||
return errAlreadyListening | |||
} | |||
|
|||
l, err := net.Listen("tcp", hostPort) | |||
lc := &net.ListenConfig{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AllenLuUber @jronak do you know how we handle configuring ingress mTLS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We create listener wrapped around tls server around it and pass the wrapped listener into tchannel Serve
. To enable mptcp, we need to set the flags on listener in yarpc
@@ -402,7 +415,9 @@ func (ch *Channel) ListenAndServe(hostPort string) error { | |||
return errAlreadyListening | |||
} | |||
|
|||
l, err := net.Listen("tcp", hostPort) | |||
lc := net.ListenConfig{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Yarpc does not hit this method for tchannel servers, it creates a listener of its own and passes into Serve
. You add this under EnableMPTCP
flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I'm aware of that. But for the sake of completeness of this feature, I think we need to do this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my understanding, if a Channel
is passed in as options to create a ChannelTransport
, yarpc will use ListenAndServe: https://github.com/yarpc/yarpc-go/blob/dev/transport/tchannel/channel_transport.go#L168
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we actually use Transport
in yarpc: https://github.com/yarpc/yarpc-go/blob/dev/transport/tchannel/transport.go#L285. It uses Serve()
This PR adds MPTCP support. It's based on go 1.21 net package.
When EnableMPTCP is passed with ChannelOptions to create a new channel, tchannel will use MPTCP instead TCP for network connection.
MPTCP requires underlying system support MPTCP.
tchannel will use normal TCP connection if EnableMPTCP is in one of following cases: