diff options
author | Bhasker Hariharan <bhaskerh@google.com> | 2020-12-09 14:54:43 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2020-12-09 15:58:53 -0800 |
commit | 92ca72ecb73d91e9def31e7f9835adf7a50b3d65 (patch) | |
tree | 9884c48ff9039c0ff2ae249fedaa2633e9fa5032 /pkg/tcpip/checker/checker.go | |
parent | b4af9d4572707718514e66b7e537bc51216b60f6 (diff) |
Add support for IP_RECVORIGDSTADDR IP option.
Fixes #5004
PiperOrigin-RevId: 346643745
Diffstat (limited to 'pkg/tcpip/checker/checker.go')
-rw-r--r-- | pkg/tcpip/checker/checker.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/tcpip/checker/checker.go b/pkg/tcpip/checker/checker.go index d3ae56ac6..8830c45d7 100644 --- a/pkg/tcpip/checker/checker.go +++ b/pkg/tcpip/checker/checker.go @@ -321,6 +321,19 @@ func ReceiveIPPacketInfo(want tcpip.IPPacketInfo) ControlMessagesChecker { } } +// ReceiveOriginalDstAddr creates a checker that checks the OriginalDstAddress +// field in ControlMessages. +func ReceiveOriginalDstAddr(want tcpip.FullAddress) ControlMessagesChecker { + return func(t *testing.T, cm tcpip.ControlMessages) { + t.Helper() + if !cm.HasOriginalDstAddress { + t.Errorf("got cm.HasOriginalDstAddress = %t, want = true", cm.HasOriginalDstAddress) + } else if diff := cmp.Diff(want, cm.OriginalDstAddress); diff != "" { + t.Errorf("OriginalDstAddress mismatch (-want +got):\n%s", diff) + } + } +} + // TOS creates a checker that checks the TOS field. func TOS(tos uint8, label uint32) NetworkChecker { return func(t *testing.T, h []header.Network) { |