API: Updating an Existing Flow Rule

Link-Inline™ Software User Guide

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

Modifying an existing flow

An existing flow rule can be modified using the DPDK API, rte_flow_actions_update. The following example demonstrates how to modify an existing flow rule by changing its action from forwarding to a queue to transmitting to a specific port (port 1 in this case).

struct rte_flow_action_port_id port_id = { .id = 1 };
struct rte_flow_action action[] = {
  [0] = { .type = RTE_FLOW_ACTION_TYPE_PORT_ID, .conf = &port_id },
  [1] = { .type = RTE_FLOW_ACTION_TYPE_END }};

struct rte_flow_error error;
int ret = rte_flow_actions_update(PORT_ID, flow, action, &error);
if (ret) {
  /* Error handling */
}
flow that needs to be modified in rte_flow_actions_update is the existing flow rule that has been created using rte_flow_create (see Forwarding all traffic to a queue).
Note:
Modifying existing flow rules do not apply to the flow rules as follows.
  • Flow rules assigned to group 0.
  • Flow rules containing patterns without specific values.
For example, consider creating three flow rules to transmit frames with a specific IP address (8.8.8.8 in this case) on port 1 and forward the rest of the IPv4 traffic to queue 0 in the host:
  • Flow rule 1: Filters IPv4 traffic and jumps to group 1. See the following testpmd command.
    flow create 0 group 0 pattern ipv4 end actions jump group 1
  • Flow rule 2: Forwards IPv4 traffic to queue 0. See the following testpmd command.
    flow create 0 group 1 pattern end actions queue index 0 / end
  • Flow rule 3: Transmits frames with IP 8.8.8.8 on port 1. See the following testpmd command.
    flow create 0 group 1 pattern ipv4 dst is 8.8.8.8 / end action port_id id 1 / end
Flow rule 1 cannot be modified as it is assigned to group 0. Flow rule 2 cannot be modified since the pattern does not include any specific values. Flow rule 3 can be modified as the pattern includes the specific IP address (8.8.8.8).