Skip to content

Commit c5c8653

Browse files
saschagrunertthaJeztah
authored andcommitted
Update sctp package
This commit updates the vendored ishidawataru/sctp and adapts its used types. Signed-off-by: Sascha Grunert <sgrunert@suse.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent d9ac962 commit c5c8653

File tree

11 files changed

+390
-100
lines changed

11 files changed

+390
-100
lines changed

libnetwork/cmd/proxy/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func parseHostContainerAddrs() (host net.Addr, container net.Addr) {
5151
host = &net.UDPAddr{IP: net.ParseIP(*hostIP), Port: *hostPort}
5252
container = &net.UDPAddr{IP: net.ParseIP(*containerIP), Port: *containerPort}
5353
case "sctp":
54-
host = &sctp.SCTPAddr{IP: []net.IP{net.ParseIP(*hostIP)}, Port: *hostPort}
55-
container = &sctp.SCTPAddr{IP: []net.IP{net.ParseIP(*containerIP)}, Port: *containerPort}
54+
host = &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: net.ParseIP(*hostIP)}}, Port: *hostPort}
55+
container = &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: net.ParseIP(*containerIP)}}, Port: *containerPort}
5656
default:
5757
log.Fatalf("unsupported protocol %s", *proto)
5858
}

libnetwork/cmd/proxy/network_proxy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func TestSCTP4Proxy(t *testing.T) {
285285
backend := NewEchoServer(t, "sctp", "127.0.0.1:0", EchoServerOptions{})
286286
defer backend.Close()
287287
backend.Run()
288-
frontendAddr := &sctp.SCTPAddr{IP: []net.IP{net.IPv4(127, 0, 0, 1)}, Port: 0}
288+
frontendAddr := &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: net.IPv4(127, 0, 0, 1)}}, Port: 0}
289289
proxy, err := NewProxy(frontendAddr, backend.LocalAddr())
290290
if err != nil {
291291
t.Fatal(err)
@@ -298,7 +298,7 @@ func TestSCTP6Proxy(t *testing.T) {
298298
backend := NewEchoServer(t, "sctp", "[::1]:0", EchoServerOptions{})
299299
defer backend.Close()
300300
backend.Run()
301-
frontendAddr := &sctp.SCTPAddr{IP: []net.IP{net.IPv6loopback}, Port: 0}
301+
frontendAddr := &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: net.IPv6loopback}}, Port: 0}
302302
proxy, err := NewProxy(frontendAddr, backend.LocalAddr())
303303
if err != nil {
304304
t.Fatal(err)

libnetwork/portmapper/mapper.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart,
115115

116116
m = &mapping{
117117
proto: proto,
118-
host: &sctp.SCTPAddr{IP: []net.IP{hostIP}, Port: allocatedHostPort},
118+
host: &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: hostIP}}, Port: allocatedHostPort},
119119
container: container,
120120
}
121121

122122
if useProxy {
123123
sctpAddr := container.(*sctp.SCTPAddr)
124-
if len(sctpAddr.IP) == 0 {
124+
if len(sctpAddr.IPAddrs) == 0 {
125125
return nil, ErrSCTPAddrNoIP
126126
}
127-
m.userlandProxy, err = newProxy(proto, hostIP, allocatedHostPort, sctpAddr.IP[0], sctpAddr.Port, pm.proxyPath)
127+
m.userlandProxy, err = newProxy(proto, hostIP, allocatedHostPort, sctpAddr.IPAddrs[0].IP, sctpAddr.Port, pm.proxyPath)
128128
if err != nil {
129129
return nil, err
130130
}
@@ -210,10 +210,10 @@ func (pm *PortMapper) Unmap(host net.Addr) error {
210210
case *net.UDPAddr:
211211
return pm.Allocator.ReleasePort(a.IP, "udp", a.Port)
212212
case *sctp.SCTPAddr:
213-
if len(a.IP) == 0 {
213+
if len(a.IPAddrs) == 0 {
214214
return ErrSCTPAddrNoIP
215215
}
216-
return pm.Allocator.ReleasePort(a.IP[0], "sctp", a.Port)
216+
return pm.Allocator.ReleasePort(a.IPAddrs[0].IP, "sctp", a.Port)
217217
}
218218
return ErrUnknownBackendAddressType
219219
}
@@ -239,11 +239,11 @@ func getKey(a net.Addr) string {
239239
case *net.UDPAddr:
240240
return fmt.Sprintf("%s:%d/%s", t.IP.String(), t.Port, "udp")
241241
case *sctp.SCTPAddr:
242-
if len(t.IP) == 0 {
242+
if len(t.IPAddrs) == 0 {
243243
logrus.Error(ErrSCTPAddrNoIP)
244244
return ""
245245
}
246-
return fmt.Sprintf("%s:%d/%s", t.IP[0].String(), t.Port, "sctp")
246+
return fmt.Sprintf("%s:%d/%s", t.IPAddrs[0].IP.String(), t.Port, "sctp")
247247
}
248248
return ""
249249
}
@@ -255,11 +255,11 @@ func getIPAndPort(a net.Addr) (net.IP, int) {
255255
case *net.UDPAddr:
256256
return t.IP, t.Port
257257
case *sctp.SCTPAddr:
258-
if len(t.IP) == 0 {
258+
if len(t.IPAddrs) == 0 {
259259
logrus.Error(ErrSCTPAddrNoIP)
260260
return nil, 0
261261
}
262-
return t.IP[0], t.Port
262+
return t.IPAddrs[0].IP, t.Port
263263
}
264264
return nil, 0
265265
}

libnetwork/portmapper/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func newDummyProxy(proto string, hostIP net.IP, hostPort int) (userlandProxy, er
9090
addr := &net.UDPAddr{IP: hostIP, Port: hostPort}
9191
return &dummyProxy{addr: addr}, nil
9292
case "sctp":
93-
addr := &sctp.SCTPAddr{IP: []net.IP{hostIP}, Port: hostPort}
93+
addr := &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: hostIP}}, Port: hostPort}
9494
return &dummyProxy{addr: addr}, nil
9595
default:
9696
return nil, fmt.Errorf("Unknown addr type: %s", proto)

libnetwork/types/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (p PortBinding) HostAddr() (net.Addr, error) {
9999
case TCP:
100100
return &net.TCPAddr{IP: p.HostIP, Port: int(p.HostPort)}, nil
101101
case SCTP:
102-
return &sctp.SCTPAddr{IP: []net.IP{p.HostIP}, Port: int(p.HostPort)}, nil
102+
return &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: p.HostIP}}, Port: int(p.HostPort)}, nil
103103
default:
104104
return nil, ErrInvalidProtocolBinding(p.Proto.String())
105105
}
@@ -113,7 +113,7 @@ func (p PortBinding) ContainerAddr() (net.Addr, error) {
113113
case TCP:
114114
return &net.TCPAddr{IP: p.IP, Port: int(p.Port)}, nil
115115
case SCTP:
116-
return &sctp.SCTPAddr{IP: []net.IP{p.IP}, Port: int(p.Port)}, nil
116+
return &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: p.IP}}, Port: int(p.Port)}, nil
117117
default:
118118
return nil, ErrInvalidProtocolBinding(p.Proto.String())
119119
}

libnetwork/vendor.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ golang.org/x/net a680a1efc54dd51c040b3b5ce4939ea3cf2ea0d1
4848
golang.org/x/sys d455e41777fca6e8a5a79e34a14b8368bc11d9ba
4949
golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca
5050
github.com/pkg/errors ba968bfe8b2f7e042a574c888954fccecfa385b4 # v0.8.1
51-
github.com/ishidawataru/sctp 07191f837fedd2f13d1ec7b5f885f0f3ec54b1cb
51+
github.com/ishidawataru/sctp 6e2cb1366111dcf547c13531e3a263a067715847
5252

5353
gotest.tools b6e20af1ed078cd01a6413b734051a292450b4cb # v2.1.0
5454
github.com/google/go-cmp 3af367b6b30c263d47e8895973edcca9a49cf029 # v0.2.0

libnetwork/vendor/github.com/ishidawataru/sctp/GO_LICENSE

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libnetwork/vendor/github.com/ishidawataru/sctp/ipsock_linux.go

Lines changed: 218 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)