@@ -911,13 +911,15 @@ net_rx_packet( fd_net_ctx_t * ctx,
911911 ctx -> metrics .rx_gre_ignored_cnt ++ ; // drop. No gre interface in netdev table
912912 return ;
913913 }
914- if ( FD_UNLIKELY ( FD_IP4_GET_VERSION ( * iphdr )!= 0x4 ) ) {
915- ctx -> metrics .rx_gre_inv_pkt_cnt ++ ; // drop. IP version!=IPv4
914+ ulong gre_ipver = FD_IP4_GET_VERSION ( * iphdr );
915+ ulong gre_iplen = FD_IP4_GET_LEN ( * iphdr );
916+ if ( FD_UNLIKELY ( gre_ipver != 0x4 || gre_iplen < 20 ) ) {
917+ FD_DTRACE_PROBE ( net_tile_err_rx_noip );
918+ ctx -> metrics .rx_gre_inv_pkt_cnt ++ ; /* drop IPv6 packets */
916919 return ;
917920 }
918921
919- ulong overhead = FD_IP4_GET_LEN ( * iphdr ) + sizeof (fd_gre_hdr_t );
920-
922+ ulong overhead = gre_iplen + sizeof (fd_gre_hdr_t );
921923 if ( FD_UNLIKELY ( (uchar * )iphdr + overhead + sizeof (fd_ip4_hdr_t )> packet_end ) ) {
922924 FD_DTRACE_PROBE ( net_tile_err_rx_undersz );
923925 ctx -> metrics .rx_undersz_cnt ++ ; // inner ip4 header invalid
@@ -939,13 +941,16 @@ net_rx_packet( fd_net_ctx_t * ctx,
939941 ulong ctl = umem_off & 0x3fUL ;
940942
941943 /* Filter for UDP/IPv4 packets. */
942- if ( FD_UNLIKELY ( ( FD_IP4_GET_VERSION ( * iphdr )!= 0x4 ) ||
943- ( iphdr -> protocol != FD_IP4_HDR_PROTOCOL_UDP ) ) ) return ;
944+ ulong ipver = FD_IP4_GET_VERSION ( * iphdr );
945+ ulong iplen = FD_IP4_GET_LEN ( * iphdr );
946+ if ( FD_UNLIKELY ( ipver != 0x4 || iplen < 20 ||
947+ iphdr -> protocol != FD_IP4_HDR_PROTOCOL_UDP ) ) {
948+ FD_DTRACE_PROBE ( net_tile_err_rx_noip );
949+ ctx -> metrics .rx_undersz_cnt ++ ; /* drop IPv6 packets */
950+ return ;
951+ }
944952
945- /* IPv4 is variable-length, so lookup IHL to find start of UDP */
946- uint iplen = FD_IP4_GET_LEN ( * iphdr );
947953 uchar const * udp = (uchar * )iphdr + iplen ;
948-
949954 if ( FD_UNLIKELY ( udp + sizeof (fd_udp_hdr_t ) > packet_end ) ) {
950955 FD_DTRACE_PROBE ( net_tile_err_rx_undersz );
951956 ctx -> metrics .rx_undersz_cnt ++ ;
0 commit comments