Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions dataplane/forwarding/protocol/icmp/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import (
)

const (
typeBytes = 1 // Number of bytes in the ICMP type
typeOffset = 0 // Offset in bytes of the ICMP type
codeBytes = 1 // Number of bytes in the ICMP code
codeOffset = 1 // Offset in bytes of the ICMP code
csumBytes = 2 // Number of bytes in the ICMP checksum
csumOffset = 2 // Offset in bytes of the ICMP checksum
icmpBytes = 8 // Number of bytes in an ICMP header
typeBytes = 1 // Number of bytes in the ICMP type
typeOffset = 0 // Offset in bytes of the ICMP type
codeBytes = 1 // Number of bytes in the ICMP code
codeOffset = 1 // Offset in bytes of the ICMP code
csumBytes = 2 // Number of bytes in the ICMP checksum
csumOffset = 2 // Offset in bytes of the ICMP checksum
icmpBytes = 8 // Number of bytes in an ICMPv4 header
icmpv6Bytes = 4 // Number of bytes in an ICMPv6 header
)

// An ICMP represents the ICMP header in the packet. Its state and functions
Expand Down
4 changes: 2 additions & 2 deletions dataplane/forwarding/protocol/icmp/icmp6.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func (i *ICMP6) Rebuild() error {
// parseICMP6 parses an ICMPv6 header in the packet. All data following the ICMP
// header is assumed to be a part of the ICMP message.
func parseICMP6(frame *frame.Frame, desc *protocol.Desc) (protocol.Handler, fwdpb.PacketHeaderId, error) {
if frame.Len() < icmpBytes {
return nil, fwdpb.PacketHeaderId_PACKET_HEADER_ID_NONE, fmt.Errorf("icmp6: parse failed, invalid frame length %v, expected size is greater than %v bytes", frame.Len(), icmpBytes)
if frame.Len() < icmpv6Bytes {
return nil, fwdpb.PacketHeaderId_PACKET_HEADER_ID_NONE, fmt.Errorf("icmp6: parse failed, invalid frame length %v, expected size is greater than %v bytes", frame.Len(), icmpv6Bytes)
}
header, err := frame.ReadHeader(frame.Len())
if err != nil {
Expand Down
Loading