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

support mptcp #2520

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ type SocketConfig struct {
TCPUserTimeout int32 `json:"tcpUserTimeout"`
V6only bool `json:"v6only"`
Interface string `json:"interface"`
TcpMptcp bool `json:"tcpMptcp"`
}

// Build implements Buildable.
Expand Down Expand Up @@ -677,6 +678,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
TcpUserTimeout: c.TCPUserTimeout,
V6Only: c.V6only,
Interface: c.Interface,
TcpMptcp: c.TcpMptcp,
}, nil
}

Expand Down
58 changes: 34 additions & 24 deletions transport/internet/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions transport/internet/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ message SocketConfig {
int32 tcp_max_seg = 17;

bool tcp_no_delay = 18;

bool tcp_mptcp = 19;
}
3 changes: 3 additions & 0 deletions transport/internet/system_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
}

if sockopt != nil || len(d.controllers) > 0 {
if sockopt != nil && sockopt.TcpMptcp {
dialer.SetMultipathTCP(true)
}
dialer.Control = func(network, address string, c syscall.RawConn) error {
for _, ctl := range d.controllers {
if err := ctl(network, address, c); err != nil {
Expand Down
9 changes: 7 additions & 2 deletions transport/internet/system_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S
network = addr.Network()
address = addr.String()
lc.Control = getControlFunc(ctx, sockopt, dl.controllers)
if sockopt != nil && (sockopt.TcpKeepAliveInterval != 0 || sockopt.TcpKeepAliveIdle != 0) {
lc.KeepAlive = time.Duration(-1)
if sockopt != nil {
if sockopt.TcpKeepAliveInterval != 0 || sockopt.TcpKeepAliveIdle != 0 {
lc.KeepAlive = time.Duration(-1)
}
if sockopt.TcpMptcp {
lc.SetMultipathTCP(true)
}
}
case *net.UnixAddr:
lc.Control = nil
Expand Down
Loading