@@ -854,8 +854,8 @@ func testRoute(t *testing.T, s *stack.Stack, nic tcpip.NICID, srcAddr, dstAddr,
854
854
855
855
func testNoRoute (t * testing.T , s * stack.Stack , nic tcpip.NICID , srcAddr , dstAddr tcpip.Address ) {
856
856
_ , err := s .FindRoute (nic , srcAddr , dstAddr , fakeNetNumber , false /* multicastLoop */ )
857
- if _ , ok := err .(* tcpip.ErrHostUnreachable ); ! ok {
858
- t .Fatalf ("FindRoute returned unexpected error, got = %v, want = %s" , err , & tcpip.ErrHostUnreachable {})
857
+ if _ , ok := err .(* tcpip.ErrNetworkUnreachable ); ! ok {
858
+ t .Fatalf ("FindRoute returned unexpected error, got = %v, want = %s" , err , & tcpip.ErrNetworkUnreachable {})
859
859
}
860
860
}
861
861
@@ -1383,7 +1383,7 @@ func TestAddressRemoval(t *testing.T) {
1383
1383
t .Fatal ("RemoveAddress failed:" , err )
1384
1384
}
1385
1385
testFailingRecv (t , fakeNet , localAddrByte , ep , buf )
1386
- testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrHostUnreachable {})
1386
+ testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrNetworkUnreachable {})
1387
1387
1388
1388
// Check that removing the same address fails.
1389
1389
err := s .RemoveAddress (1 , localAddr )
@@ -1443,7 +1443,7 @@ func TestAddressRemovalWithRouteHeld(t *testing.T) {
1443
1443
}
1444
1444
testFailingRecv (t , fakeNet , localAddrByte , ep , buf )
1445
1445
testFailingSend (t , r , nil , & tcpip.ErrInvalidEndpointState {})
1446
- testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrHostUnreachable {})
1446
+ testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrNetworkUnreachable {})
1447
1447
1448
1448
// Check that removing the same address fails.
1449
1449
{
@@ -1546,7 +1546,7 @@ func TestEndpointExpiration(t *testing.T) {
1546
1546
// FIXME(b/139841518):Spoofing doesn't work if there is no primary address.
1547
1547
// testSendTo(t, s, remoteAddr, ep, nil)
1548
1548
} else {
1549
- testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrHostUnreachable {})
1549
+ testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrNetworkUnreachable {})
1550
1550
}
1551
1551
1552
1552
// 2. Add Address, everything should work.
@@ -1581,7 +1581,7 @@ func TestEndpointExpiration(t *testing.T) {
1581
1581
// FIXME(b/139841518):Spoofing doesn't work if there is no primary address.
1582
1582
// testSendTo(t, s, remoteAddr, ep, nil)
1583
1583
} else {
1584
- testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrHostUnreachable {})
1584
+ testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrNetworkUnreachable {})
1585
1585
}
1586
1586
1587
1587
// 4. Add Address back, everything should work again.
@@ -1621,7 +1621,7 @@ func TestEndpointExpiration(t *testing.T) {
1621
1621
testSendTo (t , s , string (remoteAddr .AsSlice ()), ep , nil )
1622
1622
} else {
1623
1623
testFailingSend (t , r , nil , & tcpip.ErrInvalidEndpointState {})
1624
- testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrHostUnreachable {})
1624
+ testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrNetworkUnreachable {})
1625
1625
}
1626
1626
1627
1627
// 7. Add Address back, everything should work again.
@@ -1657,7 +1657,7 @@ func TestEndpointExpiration(t *testing.T) {
1657
1657
// FIXME(b/139841518):Spoofing doesn't work if there is no primary address.
1658
1658
// testSendTo(t, s, remoteAddr, ep, nil)
1659
1659
} else {
1660
- testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrHostUnreachable {})
1660
+ testFailingSendTo (t , s , remoteAddr , nil , & tcpip.ErrNetworkUnreachable {})
1661
1661
}
1662
1662
})
1663
1663
}
@@ -1700,8 +1700,8 @@ func TestPromiscuousMode(t *testing.T) {
1700
1700
1701
1701
// Check that we can't get a route as there is no local address.
1702
1702
_ , err := s .FindRoute (0 , tcpip.Address {}, tcpip .AddrFromSlice ([]byte ("\x02 \x00 \x00 \x00 " )), fakeNetNumber , false /* multicastLoop */ )
1703
- if _ , ok := err .(* tcpip.ErrHostUnreachable ); ! ok {
1704
- t .Fatalf ("FindRoute returned unexpected error: got = %v, want = %s" , err , & tcpip.ErrHostUnreachable {})
1703
+ if _ , ok := err .(* tcpip.ErrNetworkUnreachable ); ! ok {
1704
+ t .Fatalf ("FindRoute returned unexpected error: got = %v, want = %s" , err , & tcpip.ErrNetworkUnreachable {})
1705
1705
}
1706
1706
1707
1707
// Set promiscuous mode to false, then check that packet can't be
@@ -1922,7 +1922,7 @@ func TestSpoofingNoAddress(t *testing.T) {
1922
1922
t .Errorf ("FindRoute succeeded with route %+v when it should have failed" , r )
1923
1923
}
1924
1924
// Sending a packet fails.
1925
- testFailingSendTo (t , s , dstAddr , nil , & tcpip.ErrHostUnreachable {})
1925
+ testFailingSendTo (t , s , dstAddr , nil , & tcpip.ErrNetworkUnreachable {})
1926
1926
1927
1927
// With address spoofing enabled, FindRoute permits any address to be used
1928
1928
// as the source.
@@ -2130,9 +2130,6 @@ func TestMulticastOrIPv6LinkLocalNeedsNoRoute(t *testing.T) {
2130
2130
}
2131
2131
2132
2132
var want tcpip.Error = & tcpip.ErrNetworkUnreachable {}
2133
- if tc .routeNeeded {
2134
- want = & tcpip.ErrHostUnreachable {}
2135
- }
2136
2133
2137
2134
// If there is no endpoint, it won't work.
2138
2135
address := tcpip .AddrFromSlice ([]byte (tc .address ))
@@ -2153,8 +2150,8 @@ func TestMulticastOrIPv6LinkLocalNeedsNoRoute(t *testing.T) {
2153
2150
2154
2151
if r , err := s .FindRoute (1 , anyAddr , address , fakeNetNumber , false /* multicastLoop */ ); tc .routeNeeded {
2155
2152
// Route table is empty but we need a route, this should cause an error.
2156
- if _ , ok := err .(* tcpip.ErrHostUnreachable ); ! ok {
2157
- t .Fatalf ("got FindRoute(1, %v, %v, %v) = %v, want = %v" , anyAddr , address , fakeNetNumber , err , & tcpip.ErrHostUnreachable {})
2153
+ if _ , ok := err .(* tcpip.ErrNetworkUnreachable ); ! ok {
2154
+ t .Fatalf ("got FindRoute(1, %v, %v, %v) = %v, want = %v" , anyAddr , address , fakeNetNumber , err , & tcpip.ErrNetworkUnreachable {})
2158
2155
}
2159
2156
} else {
2160
2157
if err != nil {
@@ -4548,7 +4545,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
4548
4545
forwardingEnabled : false ,
4549
4546
addrNIC : nicID1 ,
4550
4547
localAddrWithPrefix : fakeNetCfg .nic2AddrWithPrefix ,
4551
- findRouteErr : & tcpip.ErrHostUnreachable {},
4548
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4552
4549
dependentOnForwarding : false ,
4553
4550
},
4554
4551
{
@@ -4557,7 +4554,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
4557
4554
forwardingEnabled : true ,
4558
4555
addrNIC : nicID1 ,
4559
4556
localAddrWithPrefix : fakeNetCfg .nic2AddrWithPrefix ,
4560
- findRouteErr : & tcpip.ErrHostUnreachable {},
4557
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4561
4558
dependentOnForwarding : false ,
4562
4559
},
4563
4560
{
@@ -4566,7 +4563,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
4566
4563
forwardingEnabled : false ,
4567
4564
addrNIC : nicID1 ,
4568
4565
localAddrWithPrefix : fakeNetCfg .nic1AddrWithPrefix ,
4569
- findRouteErr : & tcpip.ErrHostUnreachable {},
4566
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4570
4567
dependentOnForwarding : false ,
4571
4568
},
4572
4569
{
@@ -4602,7 +4599,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
4602
4599
forwardingEnabled : false ,
4603
4600
addrNIC : nicID2 ,
4604
4601
localAddrWithPrefix : fakeNetCfg .nic1AddrWithPrefix ,
4605
- findRouteErr : & tcpip.ErrHostUnreachable {},
4602
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4606
4603
dependentOnForwarding : false ,
4607
4604
},
4608
4605
{
@@ -4611,7 +4608,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
4611
4608
forwardingEnabled : true ,
4612
4609
addrNIC : nicID2 ,
4613
4610
localAddrWithPrefix : fakeNetCfg .nic1AddrWithPrefix ,
4614
- findRouteErr : & tcpip.ErrHostUnreachable {},
4611
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4615
4612
dependentOnForwarding : false ,
4616
4613
},
4617
4614
{
@@ -4635,7 +4632,7 @@ func TestFindRouteWithForwarding(t *testing.T) {
4635
4632
netCfg : fakeNetCfg ,
4636
4633
forwardingEnabled : false ,
4637
4634
localAddrWithPrefix : fakeNetCfg .nic1AddrWithPrefix ,
4638
- findRouteErr : & tcpip.ErrHostUnreachable {},
4635
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4639
4636
dependentOnForwarding : false ,
4640
4637
},
4641
4638
{
@@ -4651,31 +4648,31 @@ func TestFindRouteWithForwarding(t *testing.T) {
4651
4648
netCfg : ipv6LinkLocalNIC1WithGlobalRemote ,
4652
4649
forwardingEnabled : false ,
4653
4650
addrNIC : nicID1 ,
4654
- findRouteErr : & tcpip.ErrHostUnreachable {},
4651
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4655
4652
dependentOnForwarding : false ,
4656
4653
},
4657
4654
{
4658
4655
name : "forwarding enabled and specified NIC only has link-local addr with route on different NIC" ,
4659
4656
netCfg : ipv6LinkLocalNIC1WithGlobalRemote ,
4660
4657
forwardingEnabled : true ,
4661
4658
addrNIC : nicID1 ,
4662
- findRouteErr : & tcpip.ErrHostUnreachable {},
4659
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4663
4660
dependentOnForwarding : false ,
4664
4661
},
4665
4662
{
4666
4663
name : "forwarding disabled and link-local local addr with route on different NIC" ,
4667
4664
netCfg : ipv6LinkLocalNIC1WithGlobalRemote ,
4668
4665
forwardingEnabled : false ,
4669
4666
localAddrWithPrefix : ipv6LinkLocalNIC1WithGlobalRemote .nic1AddrWithPrefix ,
4670
- findRouteErr : & tcpip.ErrHostUnreachable {},
4667
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4671
4668
dependentOnForwarding : false ,
4672
4669
},
4673
4670
{
4674
4671
name : "forwarding enabled and link-local local addr with route on same NIC" ,
4675
4672
netCfg : ipv6LinkLocalNIC1WithGlobalRemote ,
4676
4673
forwardingEnabled : true ,
4677
4674
localAddrWithPrefix : ipv6LinkLocalNIC1WithGlobalRemote .nic1AddrWithPrefix ,
4678
- findRouteErr : & tcpip.ErrHostUnreachable {},
4675
+ findRouteErr : & tcpip.ErrNetworkUnreachable {},
4679
4676
dependentOnForwarding : false ,
4680
4677
},
4681
4678
{
@@ -5793,7 +5790,7 @@ func TestFindRoute(t *testing.T) {
5793
5790
false , /* multicastLoop */
5794
5791
)
5795
5792
if err != nil {
5796
- if _ , ok := err .(* tcpip.ErrHostUnreachable ); query .wantErr && ok {
5793
+ if _ , ok := err .(* tcpip.ErrNetworkUnreachable ); query .wantErr && ok {
5797
5794
return
5798
5795
}
5799
5796
t .Fatalf ("FoundRoute failed: %v" , err )
0 commit comments