mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Rename ErrNoRoute to ErrHostUnreachable
ErrNoRoute gets translated to EHOSTUNREACH which causes some code paths to produce different errors unexpectedly. Rename the error so we can clean up some sites to return ENETUNREACH more clearly where needed. Updates #8105 PiperOrigin-RevId: 482355099
This commit is contained in:
@@ -335,7 +335,7 @@ func fillRoute(routes []inet.Route, addr []byte) (inet.Route, *syserr.Error) {
|
||||
idx = idxDef
|
||||
}
|
||||
if idx == -1 {
|
||||
return inet.Route{}, syserr.ErrNoRoute
|
||||
return inet.Route{}, syserr.ErrHostUnreachable
|
||||
}
|
||||
|
||||
route := routes[idx]
|
||||
|
||||
@@ -74,8 +74,8 @@ func TranslateNetstackError(err tcpip.Error) *Error {
|
||||
return ErrDuplicateNICID
|
||||
case *tcpip.ErrDuplicateAddress:
|
||||
return ErrDuplicateAddress
|
||||
case *tcpip.ErrNoRoute:
|
||||
return ErrNoRoute
|
||||
case *tcpip.ErrHostUnreachable:
|
||||
return ErrHostUnreachable
|
||||
case *tcpip.ErrAlreadyBound:
|
||||
return ErrAlreadyBound
|
||||
case *tcpip.ErrInvalidEndpointState:
|
||||
|
||||
@@ -210,7 +210,7 @@ var (
|
||||
ErrTimedOut = newWithHost("connection timed out", errno.ETIMEDOUT, unix.ETIMEDOUT)
|
||||
ErrConnectionRefused = newWithHost("connection refused", errno.ECONNREFUSED, unix.ECONNREFUSED)
|
||||
ErrHostDown = newWithHost("host is down", errno.EHOSTDOWN, unix.EHOSTDOWN)
|
||||
ErrNoRoute = newWithHost("no route to host", errno.EHOSTUNREACH, unix.EHOSTUNREACH)
|
||||
ErrHostUnreachable = newWithHost("no route to host", errno.EHOSTUNREACH, unix.EHOSTUNREACH)
|
||||
ErrAlreadyInProgress = newWithHost("operation already in progress", errno.EALREADY, unix.EALREADY)
|
||||
ErrInProgress = newWithHost("operation now in progress", errno.EINPROGRESS, unix.EINPROGRESS)
|
||||
ErrStaleFileHandle = newWithHost("stale file handle", errno.ESTALE, unix.ESTALE)
|
||||
|
||||
@@ -737,11 +737,11 @@ func TestTCPDialError(t *testing.T) {
|
||||
|
||||
switch _, err := DialTCP(s, addr, ipv4.ProtocolNumber); err := err.(type) {
|
||||
case *net.OpError:
|
||||
if err.Err.Error() != (&tcpip.ErrNoRoute{}).String() {
|
||||
t.Errorf("got DialTCP() = %s, want = %s", err, &tcpip.ErrNoRoute{})
|
||||
if err.Err.Error() != (&tcpip.ErrHostUnreachable{}).String() {
|
||||
t.Errorf("got DialTCP() = %s, want = %s", err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
default:
|
||||
t.Errorf("got DialTCP(...) = %v, want %s", err, &tcpip.ErrNoRoute{})
|
||||
t.Errorf("got DialTCP(...) = %v, want %s", err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -380,19 +380,19 @@ func (*ErrNoPortAvailable) IgnoreStats() bool {
|
||||
}
|
||||
func (*ErrNoPortAvailable) String() string { return "no ports are available" }
|
||||
|
||||
// ErrNoRoute indicates the operation is not able to find a route to the
|
||||
// destination.
|
||||
// ErrHostUnreachable indicates that a destination host could not be
|
||||
// reached.
|
||||
//
|
||||
// +stateify savable
|
||||
type ErrNoRoute struct{}
|
||||
type ErrHostUnreachable struct{}
|
||||
|
||||
func (*ErrNoRoute) isError() {}
|
||||
func (*ErrHostUnreachable) isError() {}
|
||||
|
||||
// IgnoreStats implements Error.
|
||||
func (*ErrNoRoute) IgnoreStats() bool {
|
||||
func (*ErrHostUnreachable) IgnoreStats() bool {
|
||||
return false
|
||||
}
|
||||
func (*ErrNoRoute) String() string { return "no route" }
|
||||
func (*ErrHostUnreachable) String() string { return "no route to host" }
|
||||
|
||||
// ErrNoSuchFile is used to indicate that ENOENT should be returned the to
|
||||
// calling application.
|
||||
|
||||
@@ -93,7 +93,7 @@ func (m *InjectableEndpoint) WritePackets(pkts stack.PacketBufferList) (int, tcp
|
||||
for _, pkt := range pkts.AsSlice() {
|
||||
endpoint, ok := m.routes[pkt.EgressRoute.RemoteAddress]
|
||||
if !ok {
|
||||
return i, &tcpip.ErrNoRoute{}
|
||||
return i, &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
var tmpPkts stack.PacketBufferList
|
||||
@@ -115,7 +115,7 @@ func (m *InjectableEndpoint) WritePackets(pkts stack.PacketBufferList) (int, tcp
|
||||
func (m *InjectableEndpoint) InjectOutbound(dest tcpip.Address, packet *bufferv2.View) tcpip.Error {
|
||||
endpoint, ok := m.routes[dest]
|
||||
if !ok {
|
||||
return &tcpip.ErrNoRoute{}
|
||||
return &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
return endpoint.InjectOutbound(dest, packet)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func TranslateErrno(e unix.Errno) tcpip.Error {
|
||||
case unix.EEXIST:
|
||||
return &tcpip.ErrDuplicateAddress{}
|
||||
case unix.ENETUNREACH:
|
||||
return &tcpip.ErrNoRoute{}
|
||||
return &tcpip.ErrHostUnreachable{}
|
||||
case unix.EINVAL:
|
||||
return &tcpip.ErrInvalidEndpointState{}
|
||||
case unix.EALREADY:
|
||||
|
||||
@@ -58,12 +58,12 @@ func (*ErrLinkLocalDestinationAddress) isForwardingError() {}
|
||||
|
||||
func (*ErrLinkLocalDestinationAddress) String() string { return "link local destination address" }
|
||||
|
||||
// ErrNoRoute indicates that a route for the received packet couldn't be found.
|
||||
type ErrNoRoute struct{}
|
||||
// ErrHostUnreachable indicates that the destinatino host could not be reached.
|
||||
type ErrHostUnreachable struct{}
|
||||
|
||||
func (*ErrNoRoute) isForwardingError() {}
|
||||
func (*ErrHostUnreachable) isForwardingError() {}
|
||||
|
||||
func (*ErrNoRoute) String() string { return "no route" }
|
||||
func (*ErrHostUnreachable) String() string { return "no route to host" }
|
||||
|
||||
// ErrMessageTooLong indicates the packet was too big for the outgoing MTU.
|
||||
//
|
||||
|
||||
@@ -744,12 +744,14 @@ func (e *endpoint) forwardUnicastPacket(pkt stack.PacketBufferPtr) ip.Forwarding
|
||||
r, err := stk.FindRoute(0, "", dstAddr, ProtocolNumber, false /* multicastLoop */)
|
||||
switch err.(type) {
|
||||
case nil:
|
||||
case *tcpip.ErrNoRoute, *tcpip.ErrNetworkUnreachable:
|
||||
// TODO(https://gvisor.dev/issues/8105): We should not observe ErrHostUnreachable from route
|
||||
// lookups.
|
||||
case *tcpip.ErrHostUnreachable, *tcpip.ErrNetworkUnreachable:
|
||||
// We return the original error rather than the result of returning
|
||||
// the ICMP packet because the original error is more relevant to
|
||||
// the caller.
|
||||
_ = e.protocol.returnError(&icmpReasonNetworkUnreachable{}, pkt, false /* deliveredLocally */)
|
||||
return &ip.ErrNoRoute{}
|
||||
return &ip.ErrHostUnreachable{}
|
||||
default:
|
||||
return &ip.ErrOther{Err: err}
|
||||
}
|
||||
@@ -918,7 +920,7 @@ func (e *endpoint) forwardMulticastPacket(h header.IPv4, pkt stack.PacketBufferP
|
||||
default:
|
||||
panic(fmt.Sprintf("unexpected GetRouteResultState: %s", result.GetRouteResultState))
|
||||
}
|
||||
return &ip.ErrNoRoute{}
|
||||
return &ip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
func (e *endpoint) updateOptionsForForwarding(pkt stack.PacketBufferPtr) ip.ForwardingError {
|
||||
@@ -1009,7 +1011,7 @@ func (e *endpoint) forwardMulticastPacketForOutgoingInterface(pkt stack.PacketBu
|
||||
if route == nil {
|
||||
// Failed to convert to a stack.Route. This likely means that the outgoing
|
||||
// endpoint no longer exists.
|
||||
return &ip.ErrNoRoute{}
|
||||
return &ip.ErrHostUnreachable{}
|
||||
}
|
||||
defer route.Release()
|
||||
|
||||
@@ -1105,7 +1107,7 @@ func (e *endpoint) handleForwardingError(err ip.ForwardingError) {
|
||||
stats.Forwarding.LinkLocalDestination.Increment()
|
||||
case *ip.ErrTTLExceeded:
|
||||
stats.Forwarding.ExhaustedTTL.Increment()
|
||||
case *ip.ErrNoRoute:
|
||||
case *ip.ErrHostUnreachable:
|
||||
stats.Forwarding.Unrouteable.Increment()
|
||||
case *ip.ErrParameterProblem:
|
||||
stats.MalformedPacketsReceived.Increment()
|
||||
@@ -1583,7 +1585,7 @@ func (p *protocol) RemoveMulticastRoute(addresses stack.UnicastSourceAndMulticas
|
||||
}
|
||||
|
||||
if removed := p.multicastRouteTable.RemoveInstalledRoute(addresses); !removed {
|
||||
return &tcpip.ErrNoRoute{}
|
||||
return &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1627,7 +1629,7 @@ func (p *protocol) MulticastRouteLastUsedTime(addresses stack.UnicastSourceAndMu
|
||||
timestamp, found := p.multicastRouteTable.GetLastUsedTimestamp(addresses)
|
||||
|
||||
if !found {
|
||||
return tcpip.MonotonicTime{}, &tcpip.ErrNoRoute{}
|
||||
return tcpip.MonotonicTime{}, &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
return timestamp, nil
|
||||
|
||||
@@ -118,8 +118,8 @@ func TestExcludeBroadcast(t *testing.T) {
|
||||
// Cannot connect using a broadcast address as the source.
|
||||
{
|
||||
err := ep.Connect(randomAddr)
|
||||
if _, ok := err.(*tcpip.ErrNoRoute); !ok {
|
||||
t.Errorf("got ep.Connect(...) = %v, want = %v", err, &tcpip.ErrNoRoute{})
|
||||
if _, ok := err.(*tcpip.ErrHostUnreachable); !ok {
|
||||
t.Errorf("got ep.Connect(...) = %v, want = %v", err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -968,11 +968,13 @@ func (e *endpoint) forwardUnicastPacket(pkt stack.PacketBufferPtr) ip.Forwarding
|
||||
r, err := stk.FindRoute(0, "", dstAddr, ProtocolNumber, false /* multicastLoop */)
|
||||
switch err.(type) {
|
||||
case nil:
|
||||
case *tcpip.ErrNoRoute, *tcpip.ErrNetworkUnreachable:
|
||||
// TODO(https://gvisor.dev/issues/8105): We should not observe ErrHostUnreachable from route
|
||||
// lookups.
|
||||
case *tcpip.ErrHostUnreachable, *tcpip.ErrNetworkUnreachable:
|
||||
// We return the original error rather than the result of returning the
|
||||
// ICMP packet because the original error is more relevant to the caller.
|
||||
_ = e.protocol.returnError(&icmpReasonNetUnreachable{}, pkt, false /* deliveredLocally */)
|
||||
return &ip.ErrNoRoute{}
|
||||
return &ip.ErrHostUnreachable{}
|
||||
default:
|
||||
return &ip.ErrOther{Err: err}
|
||||
}
|
||||
@@ -1151,7 +1153,7 @@ func (e *endpoint) forwardMulticastPacket(h header.IPv6, pkt stack.PacketBufferP
|
||||
default:
|
||||
panic(fmt.Sprintf("unexpected GetRouteResultState: %s", result.GetRouteResultState))
|
||||
}
|
||||
return &ip.ErrNoRoute{}
|
||||
return &ip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
// forwardValidatedMulticastPacket attempts to forward the pkt using the
|
||||
@@ -1211,7 +1213,7 @@ func (e *endpoint) forwardMulticastPacketForOutgoingInterface(pkt stack.PacketBu
|
||||
if route == nil {
|
||||
// Failed to convert to a stack.Route. This likely means that the outgoing
|
||||
// endpoint no longer exists.
|
||||
return &ip.ErrNoRoute{}
|
||||
return &ip.ErrHostUnreachable{}
|
||||
}
|
||||
defer route.Release()
|
||||
return e.forwardPacketWithRoute(route, pkt)
|
||||
@@ -1230,7 +1232,7 @@ func (e *endpoint) handleForwardingError(err ip.ForwardingError) {
|
||||
stats.Forwarding.LinkLocalDestination.Increment()
|
||||
case *ip.ErrTTLExceeded:
|
||||
stats.Forwarding.ExhaustedTTL.Increment()
|
||||
case *ip.ErrNoRoute:
|
||||
case *ip.ErrHostUnreachable:
|
||||
stats.Forwarding.Unrouteable.Increment()
|
||||
case *ip.ErrParameterProblem:
|
||||
stats.Forwarding.ExtensionHeaderProblem.Increment()
|
||||
@@ -2460,7 +2462,7 @@ func (p *protocol) RemoveMulticastRoute(addresses stack.UnicastSourceAndMulticas
|
||||
}
|
||||
|
||||
if removed := p.multicastRouteTable.RemoveInstalledRoute(addresses); !removed {
|
||||
return &tcpip.ErrNoRoute{}
|
||||
return &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -2476,7 +2478,7 @@ func (p *protocol) MulticastRouteLastUsedTime(addresses stack.UnicastSourceAndMu
|
||||
timestamp, found := p.multicastRouteTable.GetLastUsedTimestamp(addresses)
|
||||
|
||||
if !found {
|
||||
return tcpip.MonotonicTime{}, &tcpip.ErrNoRoute{}
|
||||
return tcpip.MonotonicTime{}, &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
return timestamp, nil
|
||||
|
||||
@@ -626,8 +626,8 @@ func TestDADResolve(t *testing.T) {
|
||||
// tentative address.
|
||||
{
|
||||
r, err := s.FindRoute(nicID, "", addr2, header.IPv6ProtocolNumber, false)
|
||||
if _, ok := err.(*tcpip.ErrNoRoute); !ok {
|
||||
t.Errorf("got FindRoute(%d, '', %s, %d, false) = (%+v, %v), want = (_, %s)", nicID, addr2, header.IPv6ProtocolNumber, r, err, &tcpip.ErrNoRoute{})
|
||||
if _, ok := err.(*tcpip.ErrHostUnreachable); !ok {
|
||||
t.Errorf("got FindRoute(%d, '', %s, %d, false) = (%+v, %v), want = (_, %s)", nicID, addr2, header.IPv6ProtocolNumber, r, err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
if r != nil {
|
||||
r.Release()
|
||||
@@ -635,8 +635,8 @@ func TestDADResolve(t *testing.T) {
|
||||
}
|
||||
{
|
||||
r, err := s.FindRoute(nicID, addr1, addr2, header.IPv6ProtocolNumber, false)
|
||||
if _, ok := err.(*tcpip.ErrNoRoute); !ok {
|
||||
t.Errorf("got FindRoute(%d, %s, %s, %d, false) = (%+v, %v), want = (_, %s)", nicID, addr1, addr2, header.IPv6ProtocolNumber, r, err, &tcpip.ErrNoRoute{})
|
||||
if _, ok := err.(*tcpip.ErrHostUnreachable); !ok {
|
||||
t.Errorf("got FindRoute(%d, %s, %s, %d, false) = (%+v, %v), want = (_, %s)", nicID, addr1, addr2, header.IPv6ProtocolNumber, r, err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
if r != nil {
|
||||
r.Release()
|
||||
@@ -3813,8 +3813,8 @@ func TestAutoGenAddrJobDeprecation(t *testing.T) {
|
||||
|
||||
{
|
||||
err := ep.Connect(dstAddr)
|
||||
if _, ok := err.(*tcpip.ErrNoRoute); !ok {
|
||||
t.Errorf("got ep.Connect(%+v) = %s, want = %s", dstAddr, err, &tcpip.ErrNoRoute{})
|
||||
if _, ok := err.(*tcpip.ErrHostUnreachable); !ok {
|
||||
t.Errorf("got ep.Connect(%+v) = %s, want = %s", dstAddr, err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ func (t *TransportEndpointInfo) AddrNetProtoLocked(addr tcpip.FullAddress, v6onl
|
||||
case netProto == t.NetProto:
|
||||
case netProto == header.IPv4ProtocolNumber && t.NetProto == header.IPv6ProtocolNumber:
|
||||
if v6only {
|
||||
return tcpip.FullAddress{}, 0, &tcpip.ErrNoRoute{}
|
||||
return tcpip.FullAddress{}, 0, &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
default:
|
||||
return tcpip.FullAddress{}, 0, &tcpip.ErrInvalidEndpointState{}
|
||||
@@ -1384,7 +1384,8 @@ func (s *Stack) FindRoute(id tcpip.NICID, localAddr, remoteAddr tcpip.Address, n
|
||||
}
|
||||
}
|
||||
|
||||
return nil, &tcpip.ErrNoRoute{}
|
||||
// TODO(https://gvisor.dev/issues/8105): This should be ErrNetworkUnreachable.
|
||||
return nil, &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
if id == 0 {
|
||||
@@ -1404,11 +1405,13 @@ func (s *Stack) FindRoute(id tcpip.NICID, localAddr, remoteAddr tcpip.Address, n
|
||||
}
|
||||
|
||||
if needRoute {
|
||||
return nil, &tcpip.ErrNoRoute{}
|
||||
// TODO(https://gvisor.dev/issues/8105): This should be ErrNetworkUnreachable.
|
||||
return nil, &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
if header.IsV6LoopbackAddress(remoteAddr) {
|
||||
return nil, &tcpip.ErrBadLocalAddress{}
|
||||
}
|
||||
// TODO(https://gvisor.dev/issues/8105): This should be ErrNetworkUnreachable.
|
||||
return nil, &tcpip.ErrNetworkUnreachable{}
|
||||
}
|
||||
|
||||
|
||||
@@ -849,8 +849,8 @@ func testRoute(t *testing.T, s *stack.Stack, nic tcpip.NICID, srcAddr, dstAddr,
|
||||
|
||||
func testNoRoute(t *testing.T, s *stack.Stack, nic tcpip.NICID, srcAddr, dstAddr tcpip.Address) {
|
||||
_, err := s.FindRoute(nic, srcAddr, dstAddr, fakeNetNumber, false /* multicastLoop */)
|
||||
if _, ok := err.(*tcpip.ErrNoRoute); !ok {
|
||||
t.Fatalf("FindRoute returned unexpected error, got = %v, want = %s", err, &tcpip.ErrNoRoute{})
|
||||
if _, ok := err.(*tcpip.ErrHostUnreachable); !ok {
|
||||
t.Fatalf("FindRoute returned unexpected error, got = %v, want = %s", err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1378,7 +1378,7 @@ func TestAddressRemoval(t *testing.T) {
|
||||
t.Fatal("RemoveAddress failed:", err)
|
||||
}
|
||||
testFailingRecv(t, fakeNet, localAddrByte, ep, buf)
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrNoRoute{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrHostUnreachable{})
|
||||
|
||||
// Check that removing the same address fails.
|
||||
err := s.RemoveAddress(1, localAddr)
|
||||
@@ -1438,7 +1438,7 @@ func TestAddressRemovalWithRouteHeld(t *testing.T) {
|
||||
}
|
||||
testFailingRecv(t, fakeNet, localAddrByte, ep, buf)
|
||||
testFailingSend(t, r, nil, &tcpip.ErrInvalidEndpointState{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrNoRoute{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrHostUnreachable{})
|
||||
|
||||
// Check that removing the same address fails.
|
||||
{
|
||||
@@ -1539,7 +1539,7 @@ func TestEndpointExpiration(t *testing.T) {
|
||||
// FIXME(b/139841518):Spoofing doesn't work if there is no primary address.
|
||||
// testSendTo(t, s, remoteAddr, ep, nil)
|
||||
} else {
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrNoRoute{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
|
||||
// 2. Add Address, everything should work.
|
||||
@@ -1574,7 +1574,7 @@ func TestEndpointExpiration(t *testing.T) {
|
||||
// FIXME(b/139841518):Spoofing doesn't work if there is no primary address.
|
||||
// testSendTo(t, s, remoteAddr, ep, nil)
|
||||
} else {
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrNoRoute{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
|
||||
// 4. Add Address back, everything should work again.
|
||||
@@ -1614,7 +1614,7 @@ func TestEndpointExpiration(t *testing.T) {
|
||||
testSendTo(t, s, remoteAddr, ep, nil)
|
||||
} else {
|
||||
testFailingSend(t, r, nil, &tcpip.ErrInvalidEndpointState{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrNoRoute{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
|
||||
// 7. Add Address back, everything should work again.
|
||||
@@ -1650,7 +1650,7 @@ func TestEndpointExpiration(t *testing.T) {
|
||||
// FIXME(b/139841518):Spoofing doesn't work if there is no primary address.
|
||||
// testSendTo(t, s, remoteAddr, ep, nil)
|
||||
} else {
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrNoRoute{})
|
||||
testFailingSendTo(t, s, remoteAddr, nil, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1693,8 +1693,8 @@ func TestPromiscuousMode(t *testing.T) {
|
||||
|
||||
// Check that we can't get a route as there is no local address.
|
||||
_, err := s.FindRoute(0, "", "\x02", fakeNetNumber, false /* multicastLoop */)
|
||||
if _, ok := err.(*tcpip.ErrNoRoute); !ok {
|
||||
t.Fatalf("FindRoute returned unexpected error: got = %v, want = %s", err, &tcpip.ErrNoRoute{})
|
||||
if _, ok := err.(*tcpip.ErrHostUnreachable); !ok {
|
||||
t.Fatalf("FindRoute returned unexpected error: got = %v, want = %s", err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
|
||||
// Set promiscuous mode to false, then check that packet can't be
|
||||
@@ -1914,7 +1914,7 @@ func TestSpoofingNoAddress(t *testing.T) {
|
||||
t.Errorf("FindRoute succeeded with route %+v when it should have failed", r)
|
||||
}
|
||||
// Sending a packet fails.
|
||||
testFailingSendTo(t, s, dstAddr, nil, &tcpip.ErrNoRoute{})
|
||||
testFailingSendTo(t, s, dstAddr, nil, &tcpip.ErrHostUnreachable{})
|
||||
|
||||
// With address spoofing enabled, FindRoute permits any address to be used
|
||||
// as the source.
|
||||
@@ -2123,7 +2123,7 @@ func TestMulticastOrIPv6LinkLocalNeedsNoRoute(t *testing.T) {
|
||||
|
||||
var want tcpip.Error = &tcpip.ErrNetworkUnreachable{}
|
||||
if tc.routeNeeded {
|
||||
want = &tcpip.ErrNoRoute{}
|
||||
want = &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
// If there is no endpoint, it won't work.
|
||||
@@ -2144,8 +2144,8 @@ func TestMulticastOrIPv6LinkLocalNeedsNoRoute(t *testing.T) {
|
||||
|
||||
if r, err := s.FindRoute(1, anyAddr, tc.address, fakeNetNumber, false /* multicastLoop */); tc.routeNeeded {
|
||||
// Route table is empty but we need a route, this should cause an error.
|
||||
if _, ok := err.(*tcpip.ErrNoRoute); !ok {
|
||||
t.Fatalf("got FindRoute(1, %v, %v, %v) = %v, want = %v", anyAddr, tc.address, fakeNetNumber, err, &tcpip.ErrNoRoute{})
|
||||
if _, ok := err.(*tcpip.ErrHostUnreachable); !ok {
|
||||
t.Fatalf("got FindRoute(1, %v, %v, %v) = %v, want = %v", anyAddr, tc.address, fakeNetNumber, err, &tcpip.ErrHostUnreachable{})
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
@@ -4521,7 +4521,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
forwardingEnabled: false,
|
||||
addrNIC: nicID1,
|
||||
localAddrWithPrefix: fakeNetCfg.nic2AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4530,7 +4530,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
forwardingEnabled: true,
|
||||
addrNIC: nicID1,
|
||||
localAddrWithPrefix: fakeNetCfg.nic2AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4539,7 +4539,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
forwardingEnabled: false,
|
||||
addrNIC: nicID1,
|
||||
localAddrWithPrefix: fakeNetCfg.nic1AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4575,7 +4575,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
forwardingEnabled: false,
|
||||
addrNIC: nicID2,
|
||||
localAddrWithPrefix: fakeNetCfg.nic1AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4584,7 +4584,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
forwardingEnabled: true,
|
||||
addrNIC: nicID2,
|
||||
localAddrWithPrefix: fakeNetCfg.nic1AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4608,7 +4608,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
netCfg: fakeNetCfg,
|
||||
forwardingEnabled: false,
|
||||
localAddrWithPrefix: fakeNetCfg.nic1AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4624,7 +4624,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
netCfg: ipv6LinkLocalNIC1WithGlobalRemote,
|
||||
forwardingEnabled: false,
|
||||
addrNIC: nicID1,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4632,7 +4632,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
netCfg: ipv6LinkLocalNIC1WithGlobalRemote,
|
||||
forwardingEnabled: true,
|
||||
addrNIC: nicID1,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4640,7 +4640,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
netCfg: ipv6LinkLocalNIC1WithGlobalRemote,
|
||||
forwardingEnabled: false,
|
||||
localAddrWithPrefix: ipv6LinkLocalNIC1WithGlobalRemote.nic1AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
@@ -4648,7 +4648,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
|
||||
netCfg: ipv6LinkLocalNIC1WithGlobalRemote,
|
||||
forwardingEnabled: true,
|
||||
localAddrWithPrefix: ipv6LinkLocalNIC1WithGlobalRemote.nic1AddrWithPrefix,
|
||||
findRouteErr: &tcpip.ErrNoRoute{},
|
||||
findRouteErr: &tcpip.ErrHostUnreachable{},
|
||||
dependentOnForwarding: false,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -95,7 +95,7 @@ func (*fakeTransportEndpoint) Read(io.Writer, tcpip.ReadOptions) (tcpip.ReadResu
|
||||
|
||||
func (f *fakeTransportEndpoint) Write(p tcpip.Payloader, opts tcpip.WriteOptions) (int64, tcpip.Error) {
|
||||
if len(f.route.RemoteAddress()) == 0 {
|
||||
return 0, &tcpip.ErrNoRoute{}
|
||||
return 0, &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
v := make([]byte, p.Len())
|
||||
@@ -146,7 +146,7 @@ func (f *fakeTransportEndpoint) Connect(addr tcpip.FullAddress) tcpip.Error {
|
||||
// Find the route.
|
||||
r, err := f.proto.stack.FindRoute(addr.NIC, "", addr.Addr, fakeNetNumber, false /* multicastLoop */)
|
||||
if err != nil {
|
||||
return &tcpip.ErrNoRoute{}
|
||||
return &tcpip.ErrHostUnreachable{}
|
||||
}
|
||||
|
||||
// Try to register so that we can start receiving packets.
|
||||
|
||||
@@ -246,9 +246,9 @@ func TestTCPLinkResolutionFailure(t *testing.T) {
|
||||
name: "IPv4 without resolvable remote",
|
||||
netProto: ipv4.ProtocolNumber,
|
||||
remoteAddr: utils.Ipv4Addr3.AddressWithPrefix.Address,
|
||||
expectedWriteErr: &tcpip.ErrNoRoute{},
|
||||
expectedWriteErr: &tcpip.ErrHostUnreachable{},
|
||||
sockError: tcpip.SockError{
|
||||
Err: &tcpip.ErrNoRoute{},
|
||||
Err: &tcpip.ErrHostUnreachable{},
|
||||
Dst: tcpip.FullAddress{
|
||||
NIC: host1NICID,
|
||||
Addr: utils.Ipv4Addr3.AddressWithPrefix.Address,
|
||||
@@ -271,9 +271,9 @@ func TestTCPLinkResolutionFailure(t *testing.T) {
|
||||
name: "IPv6 without resolvable remote",
|
||||
netProto: ipv6.ProtocolNumber,
|
||||
remoteAddr: utils.Ipv6Addr3.AddressWithPrefix.Address,
|
||||
expectedWriteErr: &tcpip.ErrNoRoute{},
|
||||
expectedWriteErr: &tcpip.ErrHostUnreachable{},
|
||||
sockError: tcpip.SockError{
|
||||
Err: &tcpip.ErrNoRoute{},
|
||||
Err: &tcpip.ErrHostUnreachable{},
|
||||
Dst: tcpip.FullAddress{
|
||||
NIC: host1NICID,
|
||||
Addr: utils.Ipv6Addr3.AddressWithPrefix.Address,
|
||||
|
||||
@@ -587,7 +587,7 @@ func TestMulticastRouteLastUsedTime(t *testing.T) {
|
||||
name: "no matching route",
|
||||
srcAddr: remoteUnicastAddr,
|
||||
dstAddr: otherMulticastAddr,
|
||||
wantErr: &tcpip.ErrNoRoute{},
|
||||
wantErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "multicast source",
|
||||
@@ -745,7 +745,7 @@ func TestRemoveMulticastRoute(t *testing.T) {
|
||||
name: "no matching route",
|
||||
srcAddr: remoteUnicastAddr,
|
||||
dstAddr: otherMulticastAddr,
|
||||
wantErr: &tcpip.ErrNoRoute{},
|
||||
wantErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "multicast source",
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestLocalPing(t *testing.T) {
|
||||
netProto: ipv4.ProtocolNumber,
|
||||
linkEndpoint: loopback.New,
|
||||
icmpBuf: ipv4ICMPBuf,
|
||||
expectedConnectErr: &tcpip.ErrNoRoute{},
|
||||
expectedConnectErr: &tcpip.ErrHostUnreachable{},
|
||||
checkLinkEndpoint: func(*testing.T, stack.LinkEndpoint) {},
|
||||
},
|
||||
{
|
||||
@@ -140,7 +140,7 @@ func TestLocalPing(t *testing.T) {
|
||||
netProto: ipv6.ProtocolNumber,
|
||||
linkEndpoint: loopback.New,
|
||||
icmpBuf: ipv6ICMPBuf,
|
||||
expectedConnectErr: &tcpip.ErrNoRoute{},
|
||||
expectedConnectErr: &tcpip.ErrHostUnreachable{},
|
||||
checkLinkEndpoint: func(*testing.T, stack.LinkEndpoint) {},
|
||||
},
|
||||
{
|
||||
@@ -149,7 +149,7 @@ func TestLocalPing(t *testing.T) {
|
||||
netProto: ipv4.ProtocolNumber,
|
||||
linkEndpoint: channelEP,
|
||||
icmpBuf: ipv4ICMPBuf,
|
||||
expectedConnectErr: &tcpip.ErrNoRoute{},
|
||||
expectedConnectErr: &tcpip.ErrHostUnreachable{},
|
||||
checkLinkEndpoint: channelEPCheck,
|
||||
},
|
||||
{
|
||||
@@ -158,7 +158,7 @@ func TestLocalPing(t *testing.T) {
|
||||
netProto: ipv6.ProtocolNumber,
|
||||
linkEndpoint: channelEP,
|
||||
icmpBuf: ipv6ICMPBuf,
|
||||
expectedConnectErr: &tcpip.ErrNoRoute{},
|
||||
expectedConnectErr: &tcpip.ErrHostUnreachable{},
|
||||
checkLinkEndpoint: channelEPCheck,
|
||||
},
|
||||
}
|
||||
@@ -281,7 +281,7 @@ func TestLocalUDP(t *testing.T) {
|
||||
{
|
||||
name: "Unassigned local address",
|
||||
addAddress: false,
|
||||
expectedWriteErr: &tcpip.ErrNoRoute{},
|
||||
expectedWriteErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "Assigned local address",
|
||||
|
||||
@@ -740,7 +740,7 @@ func TestIPv6PacketInfo(t *testing.T) {
|
||||
pktInfo: tcpip.IPv6PacketInfo{
|
||||
NIC: nicID1,
|
||||
},
|
||||
expectedErr: &tcpip.ErrNoRoute{},
|
||||
expectedErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "Bind wildcard and NIC & SendTo with packet info NIC matching",
|
||||
@@ -773,7 +773,7 @@ func TestIPv6PacketInfo(t *testing.T) {
|
||||
pktInfo: tcpip.IPv6PacketInfo{
|
||||
NIC: nicID1,
|
||||
},
|
||||
expectedErr: &tcpip.ErrNoRoute{},
|
||||
expectedErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "Bind specified & SendTo with packet info NIC not matching bound addr",
|
||||
@@ -857,7 +857,7 @@ func TestIPv6PacketInfo(t *testing.T) {
|
||||
pktInfo: tcpip.IPv6PacketInfo{
|
||||
NIC: nicID1,
|
||||
},
|
||||
expectedErr: &tcpip.ErrNoRoute{},
|
||||
expectedErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "Bind wildcard & Connect with NIC then Send with packet info NIC matching",
|
||||
@@ -890,7 +890,7 @@ func TestIPv6PacketInfo(t *testing.T) {
|
||||
pktInfo: tcpip.IPv6PacketInfo{
|
||||
NIC: nicID1,
|
||||
},
|
||||
expectedErr: &tcpip.ErrNoRoute{},
|
||||
expectedErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "Bind specified & Connect then Send with packet info NIC not matching but local addr specified",
|
||||
@@ -907,7 +907,7 @@ func TestIPv6PacketInfo(t *testing.T) {
|
||||
NIC: nicID1,
|
||||
Addr: ipv6Addr1,
|
||||
},
|
||||
expectedErr: &tcpip.ErrNoRoute{},
|
||||
expectedErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
|
||||
// Connect
|
||||
@@ -950,7 +950,7 @@ func TestIPv6PacketInfo(t *testing.T) {
|
||||
pktInfo: tcpip.IPv6PacketInfo{
|
||||
NIC: nicID1,
|
||||
},
|
||||
expectedErr: &tcpip.ErrNoRoute{},
|
||||
expectedErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
{
|
||||
name: "Connect then Send with packet info NIC not matching",
|
||||
@@ -962,7 +962,7 @@ func TestIPv6PacketInfo(t *testing.T) {
|
||||
pktInfo: tcpip.IPv6PacketInfo{
|
||||
NIC: nicID1,
|
||||
},
|
||||
expectedErr: &tcpip.ErrNoRoute{},
|
||||
expectedErr: &tcpip.ErrHostUnreachable{},
|
||||
},
|
||||
|
||||
// Connect and SendTo
|
||||
|
||||
@@ -300,7 +300,7 @@ func (e *endpoint) Write(p tcpip.Payloader, opts tcpip.WriteOptions) (int64, tcp
|
||||
e.stats.WriteErrors.WriteClosed.Increment()
|
||||
case *tcpip.ErrInvalidEndpointState:
|
||||
e.stats.WriteErrors.InvalidEndpointState.Increment()
|
||||
case *tcpip.ErrNoRoute, *tcpip.ErrBroadcastDisabled, *tcpip.ErrNetworkUnreachable:
|
||||
case *tcpip.ErrHostUnreachable, *tcpip.ErrBroadcastDisabled, *tcpip.ErrNetworkUnreachable:
|
||||
// Errors indicating any problem with IP routing of the packet.
|
||||
e.stats.SendErrors.NoRoute.Increment()
|
||||
default:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user