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

Function tap_flow_create_eth

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

* Make as much checks as possible on an Ethernet item, and if a flow is * provided, fill it appropriately with Ethernet info. * * @param[in] item * Item specification. * @param[in, out] data * Additional data structure to tell next layers we've been here. * * @return * 0 if checks are alright, -1 otherwise. */

Source from the content-addressed store, hash-verified

516 * 0 if checks are alright, -1 otherwise.
517 */
518static int
519tap_flow_create_eth(const struct rte_flow_item *item, void *data)
520{
521 struct convert_data *info = (struct convert_data *)data;
522 const struct rte_flow_item_eth *spec = item->spec;
523 const struct rte_flow_item_eth *mask = item->mask;
524 struct rte_flow *flow = info->flow;
525 struct nlmsg *msg;
526
527 /* use default mask if none provided */
528 if (!mask)
529 mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_ETH].default_mask;
530 /* TC does not support eth_type masking. Only accept if exact match. */
531 if (mask->hdr.ether_type && mask->hdr.ether_type != 0xffff)
532 return -1;
533 if (!spec)
534 return 0;
535 /* store eth_type for consistency if ipv4/6 pattern item comes next */
536 if (spec->hdr.ether_type & mask->hdr.ether_type)
537 info->eth_type = spec->hdr.ether_type;
538 if (!flow)
539 return 0;
540 msg = &flow->msg;
541 if (!rte_is_zero_ether_addr(&mask->hdr.dst_addr)) {
542 tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_DST,
543 RTE_ETHER_ADDR_LEN,
544 &spec->hdr.dst_addr.addr_bytes);
545 tap_nlattr_add(&msg->nh,
546 TCA_FLOWER_KEY_ETH_DST_MASK, RTE_ETHER_ADDR_LEN,
547 &mask->hdr.dst_addr.addr_bytes);
548 }
549 if (!rte_is_zero_ether_addr(&mask->hdr.src_addr)) {
550 tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_SRC,
551 RTE_ETHER_ADDR_LEN,
552 &spec->hdr.src_addr.addr_bytes);
553 tap_nlattr_add(&msg->nh,
554 TCA_FLOWER_KEY_ETH_SRC_MASK, RTE_ETHER_ADDR_LEN,
555 &mask->hdr.src_addr.addr_bytes);
556 }
557 return 0;
558}
559
560/**
561 * Make as much checks as possible on a VLAN item, and if a flow is provided,

Callers

nothing calls this directly

Calls 2

rte_is_zero_ether_addrFunction · 0.85
tap_nlattr_addFunction · 0.85

Tested by

no test coverage detected