* Enable/disable flow isolation. * * @see rte_flow_isolate() * @see rte_flow_ops */
| 1576 | * @see rte_flow_ops |
| 1577 | */ |
| 1578 | static int |
| 1579 | tap_flow_isolate(struct rte_eth_dev *dev, |
| 1580 | int set, |
| 1581 | struct rte_flow_error *error __rte_unused) |
| 1582 | { |
| 1583 | struct pmd_internals *pmd = dev->data->dev_private; |
| 1584 | struct pmd_process_private *process_private = dev->process_private; |
| 1585 | |
| 1586 | /* normalize 'set' variable to contain 0 or 1 values */ |
| 1587 | if (set) |
| 1588 | set = 1; |
| 1589 | /* if already in the right isolation mode - nothing to do */ |
| 1590 | if ((set ^ pmd->flow_isolate) == 0) |
| 1591 | return 0; |
| 1592 | /* mark the isolation mode for tap_flow_implicit_create() */ |
| 1593 | pmd->flow_isolate = set; |
| 1594 | /* |
| 1595 | * If netdevice is there, setup appropriate flow rules immediately. |
| 1596 | * Otherwise it will be set when bringing up the netdevice (tun_alloc). |
| 1597 | */ |
| 1598 | if (process_private->rxq_fds[0] == -1) |
| 1599 | return 0; |
| 1600 | if (set) { |
| 1601 | struct rte_flow *remote_flow; |
| 1602 | |
| 1603 | while (1) { |
| 1604 | remote_flow = LIST_FIRST(&pmd->implicit_flows); |
| 1605 | if (!remote_flow) |
| 1606 | break; |
| 1607 | /* |
| 1608 | * Remove all implicit rules on the remote. |
| 1609 | * Keep the local rule to redirect packets on TX. |
| 1610 | * Keep also the last implicit local rule: ISOLATE. |
| 1611 | */ |
| 1612 | if (remote_flow->msg.t.tcm_ifindex == pmd->if_index) |
| 1613 | break; |
| 1614 | if (tap_flow_destroy_pmd(pmd, remote_flow, NULL) < 0) |
| 1615 | goto error; |
| 1616 | } |
| 1617 | /* Switch the TC rule according to pmd->flow_isolate */ |
| 1618 | if (tap_flow_implicit_create(pmd, TAP_ISOLATE) == -1) |
| 1619 | goto error; |
| 1620 | } else { |
| 1621 | /* Switch the TC rule according to pmd->flow_isolate */ |
| 1622 | if (tap_flow_implicit_create(pmd, TAP_ISOLATE) == -1) |
| 1623 | goto error; |
| 1624 | if (!pmd->remote_if_index) |
| 1625 | return 0; |
| 1626 | if (tap_flow_implicit_create(pmd, TAP_REMOTE_TX) < 0) |
| 1627 | goto error; |
| 1628 | if (tap_flow_implicit_create(pmd, TAP_REMOTE_LOCAL_MAC) < 0) |
| 1629 | goto error; |
| 1630 | if (tap_flow_implicit_create(pmd, TAP_REMOTE_BROADCAST) < 0) |
| 1631 | goto error; |
| 1632 | if (tap_flow_implicit_create(pmd, TAP_REMOTE_BROADCASTV6) < 0) |
| 1633 | goto error; |
| 1634 | if (dev->data->promiscuous && |
| 1635 | tap_flow_implicit_create(pmd, TAP_REMOTE_PROMISC) < 0) |
nothing calls this directly
no test coverage detected