summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/testutil/testutil.go
diff options
context:
space:
mode:
authorNick Brown <nickbrow@google.com>2021-05-19 12:09:54 -0700
committergVisor bot <gvisor-bot@google.com>2021-05-19 12:13:09 -0700
commitb8b43f70c898861a6fd642ded069dd33d35f17f9 (patch)
treecc78171174e81454a2d761cec23f0812f95d56ee /pkg/tcpip/testutil/testutil.go
parent2f3eda37a4dd64f1202fac1c69ab819fb0bd7a5e (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/testutil/testutil.go')
-rw-r--r--pkg/tcpip/testutil/testutil.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/tcpip/testutil/testutil.go b/pkg/tcpip/testutil/testutil.go
index f84d399fb..94b580a70 100644
--- a/pkg/tcpip/testutil/testutil.go
+++ b/pkg/tcpip/testutil/testutil.go
@@ -109,3 +109,15 @@ func ValidateMultiCounterStats(multi reflect.Value, counters []reflect.Value) er
return nil
}
+
+// MustParseLink parses a Link string into a tcpip.LinkAddress, panicking on
+// error.
+//
+// The string must be in the format aa:bb:cc:dd:ee:ff or aa-bb-cc-dd-ee-ff.
+func MustParseLink(addr string) tcpip.LinkAddress {
+ parsed, err := tcpip.ParseMACAddress(addr)
+ if err != nil {
+ panic(fmt.Sprintf("tcpip.ParseMACAddress(%s): %s", addr, err))
+ }
+ return parsed
+}