diff --git a/dataplane/forwarding/protocol/icmp/icmp.go b/dataplane/forwarding/protocol/icmp/icmp.go index 55b48f0e7..4c2109d13 100644 --- a/dataplane/forwarding/protocol/icmp/icmp.go +++ b/dataplane/forwarding/protocol/icmp/icmp.go @@ -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 diff --git a/dataplane/forwarding/protocol/icmp/icmp6.go b/dataplane/forwarding/protocol/icmp/icmp6.go index a93dd09f4..d775bb275 100644 --- a/dataplane/forwarding/protocol/icmp/icmp6.go +++ b/dataplane/forwarding/protocol/icmp/icmp6.go @@ -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 {