Skip to content
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

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

Add MPTCP support #898

wants to merge 5 commits into from

Conversation

zhiyipanuber
Copy link
Contributor

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:

  1. sets to false.
  2. not passed in ChannelOptions.
  3. not supported by underlying system.

@zhiyipanuber zhiyipanuber marked this pull request as ready for review August 21, 2023 20:57
channel.go Show resolved Hide resolved
channel.go Outdated
Comment on lines 417 to 425
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)
}
Copy link
Collaborator

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)

channel_test.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Patch coverage: 74.69% and project coverage change: +0.36% 🎉

Comparison is base (0c11cc2) 88.78% compared to head (ff84931) 89.14%.
Report is 5 commits behind head on dev.

❗ Current head ff84931 differs from pull request most recent head 890da60. Consider uploading reports for the commit 890da60 to get more accurate results

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     
Files Changed Coverage Δ
dial_17.go 42.85% <0.00%> (-57.15%) ⬇️
outbound.go 89.01% <33.33%> (+1.88%) ⬆️
messages.go 91.58% <50.00%> (-6.27%) ⬇️
mex.go 72.88% <76.00%> (+0.36%) ⬆️
connection.go 89.28% <88.88%> (+4.29%) ⬆️
channel.go 89.28% <100.00%> (+0.13%) ⬆️
inbound.go 83.00% <100.00%> (+0.61%) ⬆️
relay.go 86.62% <100.00%> (+0.90%) ⬆️
relay_messages.go 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@AllenLuUber AllenLuUber left a 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

Comment on lines 291 to 293
if opts.Dialer != nil {
dialCtx = func(ctx context.Context, hostPort string) (net.Conn, error) {
return opts.Dialer(ctx, "tcp", hostPort)
Copy link

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?

Copy link
Collaborator

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{}
Copy link

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?

Copy link
Member

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{}
Copy link
Member

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Collaborator

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants