MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tap_flow_implicit_create

Function tap_flow_implicit_create

dpdk/drivers/net/tap/tap_flow.c:1680–1775  ·  view source on GitHub ↗

* Add an implicit flow rule on the remote device to make sure traffic gets to * the tap netdevice from there. * * @param pmd * Pointer to private structure. * @param[in] idx * The idx in the implicit_rte_flows array specifying which rule to apply. * * @return -1 if the rule couldn't be applied, 0 otherwise. */

Source from the content-addressed store, hash-verified

1678 * @return -1 if the rule couldn't be applied, 0 otherwise.
1679 */
1680int tap_flow_implicit_create(struct pmd_internals *pmd,
1681 enum implicit_rule_index idx)
1682{
1683 uint16_t flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_EXCL | NLM_F_CREATE;
1684 struct rte_flow_action *actions = implicit_rte_flows[idx].actions;
1685 struct rte_flow_action isolate_actions[2] = {
1686 [1] = {
1687 .type = RTE_FLOW_ACTION_TYPE_END,
1688 },
1689 };
1690 struct rte_flow_item *items = implicit_rte_flows[idx].items;
1691 struct rte_flow_attr *attr = &implicit_rte_flows[idx].attr;
1692 struct rte_flow_item_eth eth_local = { .hdr.ether_type = 0 };
1693 unsigned int if_index = pmd->remote_if_index;
1694 struct rte_flow *remote_flow = NULL;
1695 struct nlmsg *msg = NULL;
1696 int err = 0;
1697 struct rte_flow_item items_local[2] = {
1698 [0] = {
1699 .type = items[0].type,
1700 .spec = &eth_local,
1701 .mask = items[0].mask,
1702 },
1703 [1] = {
1704 .type = items[1].type,
1705 }
1706 };
1707
1708 remote_flow = rte_zmalloc(__func__, sizeof(struct rte_flow), 0);
1709 if (!remote_flow) {
1710 TAP_LOG(ERR, "Cannot allocate memory for rte_flow");
1711 goto fail;
1712 }
1713 msg = &remote_flow->msg;
1714 if (idx == TAP_REMOTE_TX) {
1715 if_index = pmd->if_index;
1716 } else if (idx == TAP_ISOLATE) {
1717 if_index = pmd->if_index;
1718 /* Don't be exclusive for this rule, it can be changed later. */
1719 flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE;
1720 isolate_actions[0].type = pmd->flow_isolate ?
1721 RTE_FLOW_ACTION_TYPE_DROP :
1722 RTE_FLOW_ACTION_TYPE_PASSTHRU;
1723 actions = isolate_actions;
1724 } else if (idx == TAP_REMOTE_LOCAL_MAC) {
1725 /*
1726 * eth addr couldn't be set in implicit_rte_flows[] as it is not
1727 * known at compile time.
1728 */
1729 memcpy(&eth_local.hdr.dst_addr, &pmd->eth_addr, sizeof(pmd->eth_addr));
1730 items = items_local;
1731 }
1732 tc_init_msg(msg, if_index, RTM_NEWTFILTER, flags);
1733 msg->t.tcm_info = TC_H_MAKE(0, htons(ETH_P_ALL));
1734 /*
1735 * The ISOLATE rule is always present and must have a static handle, as
1736 * the action is changed whether the feature is enabled (DROP) or
1737 * disabled (PASSTHRU).

Callers 5

tap_flow_isolateFunction · 0.85
tap_promisc_enableFunction · 0.85
tap_allmulti_enableFunction · 0.85
tap_mac_setFunction · 0.85
eth_dev_tap_createFunction · 0.85

Calls 8

rte_zmallocFunction · 0.85
tc_init_msgFunction · 0.85
tap_flow_set_handleFunction · 0.85
priv_flow_processFunction · 0.85
tap_nl_sendFunction · 0.85
tap_nl_recv_ackFunction · 0.85
rte_freeFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected