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

Function tap_flow_create_tcp

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

* Make as much checks as possible on a TCP item, and if a flow is provided, * fill it appropriately with TCP 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

787 * 0 if checks are alright, -1 otherwise.
788 */
789static int
790tap_flow_create_tcp(const struct rte_flow_item *item, void *data)
791{
792 struct convert_data *info = (struct convert_data *)data;
793 const struct rte_flow_item_tcp *spec = item->spec;
794 const struct rte_flow_item_tcp *mask = item->mask;
795 struct rte_flow *flow = info->flow;
796 struct nlmsg *msg;
797
798 /* use default mask if none provided */
799 if (!mask)
800 mask = tap_flow_items[RTE_FLOW_ITEM_TYPE_TCP].default_mask;
801 /* check that previous ip_proto is compatible with tcp */
802 if (info->ip_proto && info->ip_proto != IPPROTO_TCP)
803 return -1;
804 /* TC does not support TCP port masking. Only accept if exact match. */
805 if ((mask->hdr.src_port && mask->hdr.src_port != 0xffff) ||
806 (mask->hdr.dst_port && mask->hdr.dst_port != 0xffff))
807 return -1;
808 if (!flow)
809 return 0;
810 msg = &flow->msg;
811 tap_nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_TCP);
812 if (!spec)
813 return 0;
814 if (mask->hdr.dst_port)
815 tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_DST,
816 spec->hdr.dst_port);
817 if (mask->hdr.src_port)
818 tap_nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_SRC,
819 spec->hdr.src_port);
820 return 0;
821}
822
823/**
824 * Check support for a given item.

Callers

nothing calls this directly

Calls 2

tap_nlattr_add8Function · 0.85
tap_nlattr_add16Function · 0.85

Tested by

no test coverage detected