From c01b84ada3ef318df480b7a2539724606aea535b Mon Sep 17 00:00:00 2001 From: Sonika Jindal Date: Fri, 21 Nov 2025 01:41:09 +0000 Subject: [PATCH 1/2] Fix: Adjust ICMPv6 minimum header length check --- dataplane/forwarding/protocol/icmp/icmp.go | 3 ++- dataplane/forwarding/protocol/icmp/icmp6.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dataplane/forwarding/protocol/icmp/icmp.go b/dataplane/forwarding/protocol/icmp/icmp.go index 55b48f0e7..76b4118b4 100644 --- a/dataplane/forwarding/protocol/icmp/icmp.go +++ b/dataplane/forwarding/protocol/icmp/icmp.go @@ -31,7 +31,8 @@ const ( 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 + 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 { From 4d44b3d6d1e0b269dbf292c9dbd5dfcfcd778307 Mon Sep 17 00:00:00 2001 From: Sonika Jindal Date: Fri, 21 Nov 2025 06:05:28 +0000 Subject: [PATCH 2/2] Style: Run gofmt on icmp.go --- dataplane/forwarding/protocol/icmp/icmp.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dataplane/forwarding/protocol/icmp/icmp.go b/dataplane/forwarding/protocol/icmp/icmp.go index 76b4118b4..4c2109d13 100644 --- a/dataplane/forwarding/protocol/icmp/icmp.go +++ b/dataplane/forwarding/protocol/icmp/icmp.go @@ -25,14 +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 ICMPv4 header - icmpv6Bytes = 4 // Number of bytes in an ICMPv6 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