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

Function add_cb_rules

dpdk/app/test-acl/main.c:907–956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

905typedef int (*parse_5tuple)(char *text, struct acl_rule *rule);
906
907static int
908add_cb_rules(FILE *f, struct rte_acl_ctx *ctx)
909{
910 int rc;
911 uint32_t i, k, n;
912 struct acl_rule v;
913 parse_5tuple parser;
914
915 static const parse_5tuple parser_func[] = {
916 [IPV6_FRMT_NONE] = parse_cb_ipv4_rule,
917 [IPV6_FRMT_U32] = parse_cb_ipv6_u32_rule,
918 [IPV6_FRMT_U64] = parse_cb_ipv6_u64_rule,
919 };
920
921 memset(&v, 0, sizeof(v));
922 parser = parser_func[config.ipv6];
923
924 k = 0;
925 for (i = 1; fgets(line, sizeof(line), f) != NULL; i++) {
926
927 if (skip_line(line) != 0) {
928 k++;
929 continue;
930 }
931
932 n = i - k;
933 rc = parser(line, &v);
934 if (rc != 0) {
935 RTE_LOG(ERR, TESTACL, "line %u: parse_cb_ipv4vlan_rule"
936 " failed, error code: %d (%s)\n",
937 i, rc, strerror(-rc));
938 return rc;
939 }
940
941 v.data.category_mask = RTE_LEN2MASK(RTE_ACL_MAX_CATEGORIES,
942 typeof(v.data.category_mask));
943 v.data.priority = RTE_ACL_MAX_PRIORITY - n;
944 v.data.userdata = n;
945
946 rc = rte_acl_add_rules(ctx, (struct rte_acl_rule *)&v, 1);
947 if (rc != 0) {
948 RTE_LOG(ERR, TESTACL, "line %u: failed to add rules "
949 "into ACL context, error code: %d (%s)\n",
950 i, rc, strerror(-rc));
951 return rc;
952 }
953 }
954
955 return 0;
956}
957
958static void
959acx_init(void)

Callers 1

acx_initFunction · 0.85

Calls 3

memsetFunction · 0.85
skip_lineFunction · 0.85
rte_acl_add_rulesFunction · 0.85

Tested by

no test coverage detected