Matching ICMP Traffic

Link-Inline™ Software User Guide

Platform
Napatech SmartNIC
Content Type
User Guide
Capture Software Version
Link-Inline™ Software 3.2

Filtering ICMP or ICMPv6 frames can be useful for managing them separately in the DPDK application, prioritizing their processing or handling based on the ICMP/ICMPv6 type and code.

Filtering ICMP frames

The following testpmd command creates a flow rule that matches ICMP frames received on port 0 and forwards them to queue 0.
flow create 0 group 0 pattern icmp / end actions queue index 0 / end
It is also possible to match ICMPv6 traffic. For example:
flow create 0 group 0 pattern icmp6 / end actions port_id id 1 / end
This example creates a flow rule that matches ICMPv6 frames received on port 0 and transmits them on port 1.
For matching ICMP traffic on the inner layer, use any num is 3 as follows:
flow create 0 group 0 pattern pattern any num is 3 / icmp / end actions queue index 0 / end
To match this flow rule, the frame can have any protocols in the first three layers, such as Ethernet, IPv4, and UDP or TCP. After these initial layers, the SmartNIC looks for an ICMP header.
ICMP frames based on a specific ICMP code can be handled as follows.
flow create 0 group 0 pattern icmp code is 65 / end actions queue index 0 / end
This command creates a flow rule that matches ICMP frames with ICMP code 65 received on port 0 and forwards them to queue 0 for further processing.
For scenarios requiring multiple flow rules for ICMP frames, it is recommended to use the jump action. The following testpmd commands demonstrate how to create multiple flow rules to handle ICMP frames based on their type and code.
flow create 0 pattern icmp / end actions jump group 1 / end
flow create 0 group 1 pattern end actions queue index 0 / end 
flow create 0 group 1 pattern icmp type is 1 code is 3 / end actions port_id id 1 / end
flow create 0 group 1 pattern icmp type is 4 code is 0 / end actions port_id id 1 / end
  • The first command creates a flow rule that matches any ICMP frames and forwards them to group 1.
  • The third command in group 1 matches ICMP frames with ICMP type 1 and code 3. The action is to transmit frames on port 1.
  • The fourth command in group 1 matches ICMP frames with ICMP type 4 and code 0. The action is to transmit frames on port 1.
  • The second command creates a flow rule that forwards the remaining ICMP frames to queue 0.
The following example configures flow rules to handle ICMPv6 frames with echo request and echo reply messages using type spec and type mask.
flow create 0 group 0 pattern icmp6 / end actions jump group 1 / end
flow create 0 group 1 pattern icmp6 type spec 128 type mask 254 / end actions port_id id 1 / end
  • The first command creates a flow rule for ICMPv6 frames. When a frame matches, it is redirected to group 1.
  • The second command creates a flow rule for ICMPv6 frames with specific types. type spec 128 type mask 254 matches 128 (ICMPv6 echo request) and 129 (ICMPv6 echo reply). When a frame matches, it is transmitted on port 1.