diff options
author | Nick Brown <nickbrow@google.com> | 2021-05-19 12:09:54 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-19 12:13:09 -0700 |
commit | b8b43f70c898861a6fd642ded069dd33d35f17f9 (patch) | |
tree | cc78171174e81454a2d761cec23f0812f95d56ee /pkg/tcpip/network/internal/testutil | |
parent | 2f3eda37a4dd64f1202fac1c69ab819fb0bd7a5e (diff) |
Send ICMP errors when link address resolution fails
Before this change, we would silently drop packets when link resolution
failed. This change brings us into line with RFC 792 (IPv4) and RFC 4443 (IPv6),
both of which specify that gateways should return an ICMP error to the sender
when link resolution fails.
PiperOrigin-RevId: 374699789
Diffstat (limited to 'pkg/tcpip/network/internal/testutil')
-rw-r--r-- | pkg/tcpip/network/internal/testutil/BUILD | 2 | ||||
-rw-r--r-- | pkg/tcpip/network/internal/testutil/testutil.go | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/pkg/tcpip/network/internal/testutil/BUILD b/pkg/tcpip/network/internal/testutil/BUILD index cec3e62c4..b36134ddd 100644 --- a/pkg/tcpip/network/internal/testutil/BUILD +++ b/pkg/tcpip/network/internal/testutil/BUILD @@ -10,10 +10,12 @@ go_library( "//pkg/tcpip/network/internal/fragmentation:__pkg__", "//pkg/tcpip/network/ipv4:__pkg__", "//pkg/tcpip/network/ipv6:__pkg__", + "//pkg/tcpip/tests/integration:__pkg__", ], deps = [ "//pkg/tcpip", "//pkg/tcpip/buffer", + "//pkg/tcpip/faketime", "//pkg/tcpip/header", "//pkg/tcpip/stack", ], diff --git a/pkg/tcpip/network/internal/testutil/testutil.go b/pkg/tcpip/network/internal/testutil/testutil.go index 605e9ef8d..328d5efee 100644 --- a/pkg/tcpip/network/internal/testutil/testutil.go +++ b/pkg/tcpip/network/internal/testutil/testutil.go @@ -19,13 +19,27 @@ package testutil import ( "fmt" "math/rand" + "time" "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/buffer" + "gvisor.dev/gvisor/pkg/tcpip/faketime" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/stack" ) +const ( + // immediateDuration is a duration of zero for scheduling work that needs to + // be done immediately but asynchronously to avoid deadlock. + immediateDuration time.Duration = 0 +) + +// RunImmediatelyScheduledJobs runs all jobs scheduled to run at the current +// time. +func RunImmediatelyScheduledJobs(clock *faketime.ManualClock) { + clock.Advance(immediateDuration) +} + // MockLinkEndpoint is an endpoint used for testing, it stores packets written // to it and can mock errors. type MockLinkEndpoint struct { |