From 92ca72ecb73d91e9def31e7f9835adf7a50b3d65 Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Wed, 9 Dec 2020 14:54:43 -0800 Subject: Add support for IP_RECVORIGDSTADDR IP option. Fixes #5004 PiperOrigin-RevId: 346643745 --- pkg/tcpip/checker/checker.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pkg/tcpip/checker/checker.go') 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) { -- cgit v1.2.3