Remove unused commit() function argument to Bind.

PiperOrigin-RevId: 236926132
Change-Id: I5cf103f22766e6e65a581de780c7bb9ca0fa3181
This commit is contained in:
Kevin Krakauer 2019-03-05 14:52:35 -08:00 committed by Shentubot
parent bd46185e24
commit 23e66ee96d
18 changed files with 67 additions and 94 deletions

View File

@ -140,7 +140,7 @@ func (c *Client) Request(ctx context.Context, requestedAddr tcpip.Address) (cfg
Addr: tcpipHeader.IPv4Any,
Port: ClientPort,
NIC: c.nicid,
}, nil); err != nil {
}); err != nil {
return Config{}, fmt.Errorf("dhcp: Bind(): %s", err)
}

View File

@ -284,7 +284,7 @@ func TestTwoServers(t *testing.T) {
if err != nil {
t.Fatalf("dhcp: server endpoint: %v", err)
}
if err = ep.Bind(tcpip.FullAddress{Port: ServerPort}, nil); err != nil {
if err = ep.Bind(tcpip.FullAddress{Port: ServerPort}); err != nil {
t.Fatalf("dhcp: server bind: %v", err)
}
if err = ep.SetSockOpt(tcpip.BroadcastOption(1)); err != nil {

View File

@ -120,7 +120,7 @@ func newEPConnServer(ctx context.Context, stack *stack.Stack, addrs []tcpip.Addr
if err != nil {
return nil, fmt.Errorf("dhcp: server endpoint: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{Port: ServerPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: ServerPort}); err != nil {
return nil, fmt.Errorf("dhcp: server bind: %v", err)
}
if err := ep.SetSockOpt(tcpip.BroadcastOption(1)); err != nil {

View File

@ -423,7 +423,7 @@ func (s *SocketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error {
}
// Issue the bind request to the endpoint.
return syserr.TranslateNetstackError(s.Endpoint.Bind(addr, nil))
return syserr.TranslateNetstackError(s.Endpoint.Bind(addr))
}
// Listen implements the linux syscall listen(2) for sockets backed by

View File

@ -60,7 +60,7 @@ func NewListener(s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkPr
return nil, errors.New(err.String())
}
if err := ep.Bind(addr, nil); err != nil {
if err := ep.Bind(addr); err != nil {
ep.Close()
return nil, &net.OpError{
Op: "bind",
@ -524,7 +524,7 @@ func NewPacketConn(s *stack.Stack, addr tcpip.FullAddress, network tcpip.Network
return nil, errors.New(err.String())
}
if err := ep.Bind(addr, nil); err != nil {
if err := ep.Bind(addr); err != nil {
ep.Close()
return nil, &net.OpError{
Op: "bind",

View File

@ -69,7 +69,7 @@ func TestExcludeBroadcast(t *testing.T) {
}
// However, we can bind to a broadcast address to listen.
if err := ep.Bind(tcpip.FullAddress{Addr: header.IPv4Broadcast, Port: 53, NIC: 1}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Addr: header.IPv4Broadcast, Port: 53, NIC: 1}); err != nil {
t.Errorf("Bind failed: %v", err)
}
})

View File

@ -165,7 +165,7 @@ func main() {
// Bind if a port is specified.
if localPort != 0 {
if err := ep.Bind(tcpip.FullAddress{0, "", localPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{0, "", localPort}); err != nil {
log.Fatal("Bind failed: ", err)
}
}

View File

@ -165,7 +165,7 @@ func main() {
defer ep.Close()
if err := ep.Bind(tcpip.FullAddress{0, "", uint16(localPort)}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{0, "", uint16(localPort)}); err != nil {
log.Fatal("Bind failed: ", err)
}

View File

@ -145,7 +145,7 @@ func (f *fakeTransportEndpoint) Accept() (tcpip.Endpoint, *waiter.Queue, *tcpip.
return &a, nil, nil
}
func (f *fakeTransportEndpoint) Bind(a tcpip.FullAddress, commit func() *tcpip.Error) *tcpip.Error {
func (f *fakeTransportEndpoint) Bind(a tcpip.FullAddress) *tcpip.Error {
if err := f.stack.RegisterTransportEndpoint(
a.NIC,
[]tcpip.NetworkProtocolNumber{fakeNetNumber},
@ -157,7 +157,7 @@ func (f *fakeTransportEndpoint) Bind(a tcpip.FullAddress, commit func() *tcpip.E
return err
}
f.acceptQueue = []fakeTransportEndpoint{}
return commit()
return nil
}
func (*fakeTransportEndpoint) GetLocalAddress() (tcpip.FullAddress, *tcpip.Error) {
@ -483,7 +483,7 @@ func TestTransportForwarding(t *testing.T) {
t.Fatalf("NewEndpoint failed: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{Addr: "\x01", NIC: 1}, func() *tcpip.Error { return nil }); err != nil {
if err := ep.Bind(tcpip.FullAddress{Addr: "\x01", NIC: 1}); err != nil {
t.Fatalf("Bind failed: %v", err)
}

View File

@ -356,11 +356,7 @@ type Endpoint interface {
// Bind binds the endpoint to a specific local address and port.
// Specifying a NIC is optional.
//
// An optional commit function will be executed atomically with respect
// to binding the endpoint. If this returns an error, the bind will not
// occur and the error will be propagated back to the caller.
Bind(address FullAddress, commit func() *Error) *Error
Bind(address FullAddress) *Error
// GetLocalAddress returns the address to which the endpoint is bound.
GetLocalAddress() (FullAddress, *Error)

View File

@ -100,7 +100,7 @@ func newEndpoint(stack *stack.Stack, netProto tcpip.NetworkProtocolNumber, trans
// Raw endpoints must be immediately bound because they receive all
// ICMP traffic starting from when they're created via socket().
if raw {
if err := e.bindLocked(tcpip.FullAddress{}, nil); err != nil {
if err := e.bindLocked(tcpip.FullAddress{}); err != nil {
return nil, err
}
}
@ -202,7 +202,7 @@ func (e *endpoint) prepareForWrite(to *tcpip.FullAddress) (retry bool, err *tcpi
}
// The state is still 'initial', so try to bind the endpoint.
if err := e.bindLocked(tcpip.FullAddress{}, nil); err != nil {
if err := e.bindLocked(tcpip.FullAddress{}); err != nil {
return false, err
}
@ -576,7 +576,7 @@ func (e *endpoint) registerWithStack(nicid tcpip.NICID, netProtos []tcpip.Networ
return id, err
}
func (e *endpoint) bindLocked(addr tcpip.FullAddress, commit func() *tcpip.Error) *tcpip.Error {
func (e *endpoint) bindLocked(addr tcpip.FullAddress) *tcpip.Error {
// Don't allow binding once endpoint is not in the initial state
// anymore.
if e.state != stateInitial {
@ -608,13 +608,6 @@ func (e *endpoint) bindLocked(addr tcpip.FullAddress, commit func() *tcpip.Error
if err != nil {
return err
}
if commit != nil {
if err := commit(); err != nil {
// Unregister, the commit failed.
e.stack.UnregisterTransportEndpoint(addr.NIC, netProtos, e.transProto, id, e)
return err
}
}
e.id = id
e.regNICID = addr.NIC
@ -631,11 +624,11 @@ func (e *endpoint) bindLocked(addr tcpip.FullAddress, commit func() *tcpip.Error
// Bind binds the endpoint to a specific local address and port.
// Specifying a NIC is optional.
func (e *endpoint) Bind(addr tcpip.FullAddress, commit func() *tcpip.Error) *tcpip.Error {
func (e *endpoint) Bind(addr tcpip.FullAddress) *tcpip.Error {
e.mu.Lock()
defer e.mu.Unlock()
err := e.bindLocked(addr, commit)
err := e.bindLocked(addr)
if err != nil {
return err
}

View File

@ -113,7 +113,7 @@ func TestV4ConnectWhenBoundToWildcard(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind to wildcard.
if err := c.EP.Bind(tcpip.FullAddress{}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -128,7 +128,7 @@ func TestV4ConnectWhenBoundToV4MappedWildcard(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind to v4 mapped wildcard.
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.V4MappedWildcardAddr}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.V4MappedWildcardAddr}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -143,7 +143,7 @@ func TestV4ConnectWhenBoundToV4Mapped(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind to v4 mapped address.
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.StackV4MappedAddr}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.StackV4MappedAddr}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -233,7 +233,7 @@ func TestV6ConnectWhenBoundToWildcard(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind to wildcard.
if err := c.EP.Bind(tcpip.FullAddress{}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -248,7 +248,7 @@ func TestV6ConnectWhenBoundToLocalAddress(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind to local address.
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.StackV6Addr}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.StackV6Addr}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -263,7 +263,7 @@ func TestV4RefuseOnV6Only(t *testing.T) {
c.CreateV6Endpoint(true)
// Bind to wildcard.
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -300,7 +300,7 @@ func TestV6RefuseOnBoundToV4Mapped(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind and listen.
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.V4MappedWildcardAddr, Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.V4MappedWildcardAddr, Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -415,7 +415,7 @@ func TestV4AcceptOnV6(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind to wildcard.
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -430,7 +430,7 @@ func TestV4AcceptOnBoundToV4MappedWildcard(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind to v4 mapped wildcard.
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.V4MappedWildcardAddr, Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.V4MappedWildcardAddr, Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -445,7 +445,7 @@ func TestV4AcceptOnBoundToV4Mapped(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind and listen.
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.StackV4MappedAddr, Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Addr: context.StackV4MappedAddr, Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -460,7 +460,7 @@ func TestV6AcceptOnV6(t *testing.T) {
c.CreateV6Endpoint(false)
// Bind and listen.
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -551,7 +551,7 @@ func TestV4AcceptOnV4(t *testing.T) {
}
// Bind to wildcard.
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}

View File

@ -1336,7 +1336,7 @@ func (e *endpoint) Accept() (tcpip.Endpoint, *waiter.Queue, *tcpip.Error) {
}
// Bind binds the endpoint to a specific local port and optionally address.
func (e *endpoint) Bind(addr tcpip.FullAddress, commit func() *tcpip.Error) (err *tcpip.Error) {
func (e *endpoint) Bind(addr tcpip.FullAddress) (err *tcpip.Error) {
e.mu.Lock()
defer e.mu.Unlock()
@ -1397,14 +1397,6 @@ func (e *endpoint) Bind(addr tcpip.FullAddress, commit func() *tcpip.Error) (err
e.id.LocalAddress = addr.Addr
}
// Check the commit function.
if commit != nil {
if err := commit(); err != nil {
// The defer takes care of unwind.
return err
}
}
// Mark endpoint as bound.
e.state = stateBound

View File

@ -185,7 +185,7 @@ func (e *endpoint) afterLoad() {
if len(e.bindAddress) == 0 {
e.bindAddress = e.id.LocalAddress
}
if err := e.Bind(tcpip.FullAddress{Addr: e.bindAddress, Port: e.id.LocalPort}, nil); err != nil {
if err := e.Bind(tcpip.FullAddress{Addr: e.bindAddress, Port: e.id.LocalPort}); err != nil {
panic("endpoint binding failed: " + err.String())
}
}

View File

@ -135,7 +135,7 @@ func TestPassiveConnectionAttemptIncrement(t *testing.T) {
t.Fatalf("NewEndpoint failed: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{Addr: context.StackAddr, Port: context.StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Addr: context.StackAddr, Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
if err := ep.Listen(1); err != nil {
@ -193,7 +193,7 @@ func TestTCPResetsSentIncrement(t *testing.T) {
}
want := stats.TCP.SegmentsSent.Value() + 1
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -1042,7 +1042,7 @@ func TestScaledWindowAccept(t *testing.T) {
t.Fatalf("SetSockOpt failed failed: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -1115,7 +1115,7 @@ func TestNonScaledWindowAccept(t *testing.T) {
t.Fatalf("SetSockOpt failed failed: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -1618,7 +1618,7 @@ func TestPassiveSendMSSLessThanMTU(t *testing.T) {
t.Fatalf("SetSockOpt failed failed: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -1675,7 +1675,7 @@ func TestSynCookiePassiveSendMSSLessThanMTU(t *testing.T) {
}
defer ep.Close()
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -1840,7 +1840,7 @@ func TestCloseListener(t *testing.T) {
t.Fatalf("NewEndpoint failed: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -2824,7 +2824,7 @@ func TestUpdateListenBacklog(t *testing.T) {
t.Fatalf("NewEndpoint failed: %v", err)
}
if err := ep.Bind(tcpip.FullAddress{}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -3096,7 +3096,7 @@ func TestReusePort(t *testing.T) {
if err != nil {
t.Fatalf("NewEndpoint failed; %v", err)
}
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -3105,7 +3105,7 @@ func TestReusePort(t *testing.T) {
if err != nil {
t.Fatalf("NewEndpoint failed; %v", err)
}
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
c.EP.Close()
@ -3115,7 +3115,7 @@ func TestReusePort(t *testing.T) {
if err != nil {
t.Fatalf("NewEndpoint failed; %v", err)
}
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
if err := c.EP.Connect(tcpip.FullAddress{Addr: context.TestAddr, Port: context.TestPort}); err != tcpip.ErrConnectStarted {
@ -3127,7 +3127,7 @@ func TestReusePort(t *testing.T) {
if err != nil {
t.Fatalf("NewEndpoint failed; %v", err)
}
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
c.EP.Close()
@ -3137,7 +3137,7 @@ func TestReusePort(t *testing.T) {
if err != nil {
t.Fatalf("NewEndpoint failed; %v", err)
}
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
if err := c.EP.Listen(10); err != nil {
@ -3149,7 +3149,7 @@ func TestReusePort(t *testing.T) {
if err != nil {
t.Fatalf("NewEndpoint failed; %v", err)
}
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
if err := c.EP.Listen(10); err != nil {
@ -3337,7 +3337,7 @@ func TestSelfConnect(t *testing.T) {
}
defer ep.Close()
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
@ -3508,7 +3508,7 @@ func TestConnectAvoidsBoundPorts(t *testing.T) {
}
for i := ports.FirstEphemeral; i <= math.MaxUint16; i++ {
if makeEP(exhaustedNetwork).Bind(tcpip.FullAddress{Addr: address(t, exhaustedAddressType, isAny), Port: uint16(i)}, nil); err != nil {
if makeEP(exhaustedNetwork).Bind(tcpip.FullAddress{Addr: address(t, exhaustedAddressType, isAny), Port: uint16(i)}); err != nil {
t.Fatalf("Bind(%d) failed: %v", i, err)
}
}

View File

@ -796,7 +796,7 @@ func (c *Context) AcceptWithOptions(wndScale int, synOptions header.TCPSynOption
}
defer ep.Close()
if err := ep.Bind(tcpip.FullAddress{Port: StackPort}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: StackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}

View File

@ -247,7 +247,7 @@ func (e *endpoint) prepareForWrite(to *tcpip.FullAddress) (retry bool, err *tcpi
}
// The state is still 'initial', so try to bind the endpoint.
if err := e.bindLocked(tcpip.FullAddress{}, nil); err != nil {
if err := e.bindLocked(tcpip.FullAddress{}); err != nil {
return false, err
}
@ -806,7 +806,7 @@ func (e *endpoint) registerWithStack(nicid tcpip.NICID, netProtos []tcpip.Networ
return id, err
}
func (e *endpoint) bindLocked(addr tcpip.FullAddress, commit func() *tcpip.Error) *tcpip.Error {
func (e *endpoint) bindLocked(addr tcpip.FullAddress) *tcpip.Error {
// Don't allow binding once endpoint is not in the initial state
// anymore.
if e.state != stateInitial {
@ -846,14 +846,6 @@ func (e *endpoint) bindLocked(addr tcpip.FullAddress, commit func() *tcpip.Error
if err != nil {
return err
}
if commit != nil {
if err := commit(); err != nil {
// Unregister, the commit failed.
e.stack.UnregisterTransportEndpoint(nicid, netProtos, ProtocolNumber, id, e)
e.stack.ReleasePort(netProtos, ProtocolNumber, id.LocalAddress, id.LocalPort)
return err
}
}
e.id = id
e.regNICID = nicid
@ -871,11 +863,11 @@ func (e *endpoint) bindLocked(addr tcpip.FullAddress, commit func() *tcpip.Error
// Bind binds the endpoint to a specific local address and port.
// Specifying a NIC is optional.
func (e *endpoint) Bind(addr tcpip.FullAddress, commit func() *tcpip.Error) *tcpip.Error {
func (e *endpoint) Bind(addr tcpip.FullAddress) *tcpip.Error {
e.mu.Lock()
defer e.mu.Unlock()
err := e.bindLocked(addr, commit)
err := e.bindLocked(addr)
if err != nil {
return err
}

View File

@ -289,7 +289,7 @@ func TestBindPortReuse(t *testing.T) {
if err := eps[i].SetSockOpt(reusePortOpt); err != nil {
c.t.Fatalf("SetSockOpt failed failed: %v", err)
}
if err := eps[i].Bind(tcpip.FullAddress{Addr: stackV6Addr, Port: stackPort}, nil); err != nil {
if err := eps[i].Bind(tcpip.FullAddress{Addr: stackV6Addr, Port: stackPort}); err != nil {
t.Fatalf("ep.Bind(...) failed: %v", err)
}
}
@ -385,7 +385,7 @@ func TestBindEphemeralPort(t *testing.T) {
c.createV6Endpoint(false)
if err := c.ep.Bind(tcpip.FullAddress{}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{}); err != nil {
t.Fatalf("ep.Bind(...) failed: %v", err)
}
}
@ -412,7 +412,7 @@ func TestBindReservedPort(t *testing.T) {
t.Fatalf("NewEndpoint failed: %v", err)
}
defer ep.Close()
if got, want := ep.Bind(addr, nil), tcpip.ErrPortInUse; got != want {
if got, want := ep.Bind(addr), tcpip.ErrPortInUse; got != want {
t.Fatalf("got ep.Bind(...) = %v, want = %v", got, want)
}
}
@ -425,11 +425,11 @@ func TestBindReservedPort(t *testing.T) {
defer ep.Close()
// We can't bind ipv4-any on the port reserved by the connected endpoint
// above, since the endpoint is dual-stack.
if got, want := ep.Bind(tcpip.FullAddress{Port: addr.Port}, nil), tcpip.ErrPortInUse; got != want {
if got, want := ep.Bind(tcpip.FullAddress{Port: addr.Port}), tcpip.ErrPortInUse; got != want {
t.Fatalf("got ep.Bind(...) = %v, want = %v", got, want)
}
// We can bind an ipv4 address on this port, though.
if err := ep.Bind(tcpip.FullAddress{Addr: stackAddr, Port: addr.Port}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Addr: stackAddr, Port: addr.Port}); err != nil {
t.Fatalf("ep.Bind(...) failed: %v", err)
}
}()
@ -443,7 +443,7 @@ func TestBindReservedPort(t *testing.T) {
t.Fatalf("NewEndpoint failed: %v", err)
}
defer ep.Close()
if err := ep.Bind(tcpip.FullAddress{Port: addr.Port}, nil); err != nil {
if err := ep.Bind(tcpip.FullAddress{Port: addr.Port}); err != nil {
t.Fatalf("ep.Bind(...) failed: %v", err)
}
}()
@ -456,7 +456,7 @@ func TestV4ReadOnV6(t *testing.T) {
c.createV6Endpoint(false)
// Bind to wildcard.
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}
@ -471,7 +471,7 @@ func TestV4ReadOnBoundToV4MappedWildcard(t *testing.T) {
c.createV6Endpoint(false)
// Bind to v4 mapped wildcard.
if err := c.ep.Bind(tcpip.FullAddress{Addr: V4MappedWildcardAddr, Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Addr: V4MappedWildcardAddr, Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}
@ -486,7 +486,7 @@ func TestV4ReadOnBoundToV4Mapped(t *testing.T) {
c.createV6Endpoint(false)
// Bind to local address.
if err := c.ep.Bind(tcpip.FullAddress{Addr: stackV4MappedAddr, Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Addr: stackV4MappedAddr, Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}
@ -501,7 +501,7 @@ func TestV6ReadOnV6(t *testing.T) {
c.createV6Endpoint(false)
// Bind to wildcard.
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}
@ -556,7 +556,7 @@ func TestV4ReadOnV4(t *testing.T) {
}
// Bind to wildcard.
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}
@ -650,7 +650,7 @@ func TestDualWriteBoundToWildcard(t *testing.T) {
c.createV6Endpoint(false)
// Bind to wildcard.
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}
@ -729,7 +729,7 @@ func TestV6WriteOnBoundToV4Mapped(t *testing.T) {
c.createV6Endpoint(false)
// Bind to v4 mapped address.
if err := c.ep.Bind(tcpip.FullAddress{Addr: stackV4MappedAddr, Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Addr: stackV4MappedAddr, Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}
@ -827,7 +827,7 @@ func TestReadIncrementsPacketsReceived(t *testing.T) {
}
// Bind to wildcard.
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}, nil); err != nil {
if err := c.ep.Bind(tcpip.FullAddress{Port: stackPort}); err != nil {
c.t.Fatalf("Bind failed: %v", err)
}