* Test creating and finding ACL contexts, and adding rules */
| 1133 | * Test creating and finding ACL contexts, and adding rules |
| 1134 | */ |
| 1135 | static int |
| 1136 | test_create_find_add(void) |
| 1137 | { |
| 1138 | struct rte_acl_param param; |
| 1139 | struct rte_acl_ctx *acx, *acx2, *tmp; |
| 1140 | struct rte_acl_ipv4vlan_rule rules[LEN]; |
| 1141 | |
| 1142 | const uint32_t layout[RTE_ACL_IPV4VLAN_NUM] = {0}; |
| 1143 | |
| 1144 | const char *acx_name = "acx"; |
| 1145 | const char *acx2_name = "acx2"; |
| 1146 | int i, ret; |
| 1147 | |
| 1148 | /* create two contexts */ |
| 1149 | memcpy(¶m, &acl_param, sizeof(param)); |
| 1150 | param.max_rule_num = 2; |
| 1151 | |
| 1152 | param.name = acx_name; |
| 1153 | acx = rte_acl_create(¶m); |
| 1154 | if (acx == NULL) { |
| 1155 | printf("Line %i: Error creating %s!\n", __LINE__, acx_name); |
| 1156 | return -1; |
| 1157 | } |
| 1158 | |
| 1159 | param.name = acx2_name; |
| 1160 | acx2 = rte_acl_create(¶m); |
| 1161 | if (acx2 == NULL || acx2 == acx) { |
| 1162 | printf("Line %i: Error creating %s!\n", __LINE__, acx2_name); |
| 1163 | rte_acl_free(acx); |
| 1164 | return -1; |
| 1165 | } |
| 1166 | |
| 1167 | /* try to create third one, with an existing name */ |
| 1168 | param.name = acx_name; |
| 1169 | tmp = rte_acl_create(¶m); |
| 1170 | if (tmp != acx) { |
| 1171 | printf("Line %i: Creating context with existing name " |
| 1172 | "test failed!\n", |
| 1173 | __LINE__); |
| 1174 | rte_acl_free(tmp); |
| 1175 | goto err; |
| 1176 | } |
| 1177 | |
| 1178 | param.name = acx2_name; |
| 1179 | tmp = rte_acl_create(¶m); |
| 1180 | if (tmp != acx2) { |
| 1181 | printf("Line %i: Creating context with existing " |
| 1182 | "name test 2 failed!\n", |
| 1183 | __LINE__); |
| 1184 | rte_acl_free(tmp); |
| 1185 | goto err; |
| 1186 | } |
| 1187 | |
| 1188 | /* try to find existing ACL contexts */ |
| 1189 | tmp = rte_acl_find_existing(acx_name); |
| 1190 | if (tmp != acx) { |
| 1191 | printf("Line %i: Finding %s failed!\n", __LINE__, acx_name); |
| 1192 | rte_acl_free(tmp); |
no test coverage detected