summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/network/ipv4
diff options
context:
space:
mode:
authorJulian Elischer <jrelis@google.com>2020-11-12 18:36:45 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-12 18:38:43 -0800
commit638d64c6337d05b91f0bde81de8e1c8d6d9908d8 (patch)
treea837ab0ff956aff7d058005059510fa49d1fa89e /pkg/tcpip/network/ipv4
parent62db1fad2cb7d2249720e157aa79c84b7531a2e9 (diff)
Change AllocationSize to SizeWithPadding as requested
RELNOTES: n/a PiperOrigin-RevId: 342176296
Diffstat (limited to 'pkg/tcpip/network/ipv4')
-rw-r--r--pkg/tcpip/network/ipv4/ipv4.go4
-rw-r--r--pkg/tcpip/network/ipv4/ipv4_test.go4
2 files changed, 4 insertions, 4 deletions
diff --git a/pkg/tcpip/network/ipv4/ipv4.go b/pkg/tcpip/network/ipv4/ipv4.go
index 0af646df9..0c828004a 100644
--- a/pkg/tcpip/network/ipv4/ipv4.go
+++ b/pkg/tcpip/network/ipv4/ipv4.go
@@ -206,12 +206,12 @@ func (e *endpoint) addIPHeader(r *stack.Route, pkt *stack.PacketBuffer, params s
if opts, ok = params.Options.(header.IPv4Options); !ok {
panic(fmt.Sprintf("want IPv4Options, got %T", params.Options))
}
- hdrLen += opts.AllocationSize()
+ hdrLen += opts.SizeWithPadding()
if hdrLen > header.IPv4MaximumHeaderSize {
// Since we have no way to report an error we must either panic or create
// a packet which is different to what was requested. Choose panic as this
// would be a programming error that should be caught in testing.
- panic(fmt.Sprintf("IPv4 Options %d bytes, Max %d", params.Options.AllocationSize(), header.IPv4MaximumOptionsSize))
+ panic(fmt.Sprintf("IPv4 Options %d bytes, Max %d", params.Options.SizeWithPadding(), header.IPv4MaximumOptionsSize))
}
}
ip := header.IPv4(pkt.NetworkHeader().Push(hdrLen))
diff --git a/pkg/tcpip/network/ipv4/ipv4_test.go b/pkg/tcpip/network/ipv4/ipv4_test.go
index 2abfccbf3..a7100b971 100644
--- a/pkg/tcpip/network/ipv4/ipv4_test.go
+++ b/pkg/tcpip/network/ipv4/ipv4_test.go
@@ -167,7 +167,7 @@ func TestIPv4EncodeOptions(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
- paddedOptionLength := test.options.AllocationSize()
+ paddedOptionLength := test.options.SizeWithPadding()
ipHeaderLength := header.IPv4MinimumSize + paddedOptionLength
if ipHeaderLength > header.IPv4MaximumHeaderSize {
t.Fatalf("IP header length too large: got = %d, want <= %d ", ipHeaderLength, header.IPv4MaximumHeaderSize)
@@ -706,7 +706,7 @@ func TestIPv4Sanity(t *testing.T) {
},
})
- paddedOptionLength := test.options.AllocationSize()
+ paddedOptionLength := test.options.SizeWithPadding()
ipHeaderLength := header.IPv4MinimumSize + paddedOptionLength
if ipHeaderLength > header.IPv4MaximumHeaderSize {
t.Fatalf("IP header length too large: got = %d, want <= %d ", ipHeaderLength, header.IPv4MaximumHeaderSize)