* test various invalid rules */
| 1268 | * test various invalid rules |
| 1269 | */ |
| 1270 | static int |
| 1271 | test_invalid_rules(void) |
| 1272 | { |
| 1273 | struct rte_acl_ctx *acx; |
| 1274 | int ret; |
| 1275 | |
| 1276 | struct rte_acl_ipv4vlan_rule rule; |
| 1277 | |
| 1278 | acx = rte_acl_create(&acl_param); |
| 1279 | if (acx == NULL) { |
| 1280 | printf("Line %i: Error creating ACL context!\n", __LINE__); |
| 1281 | return -1; |
| 1282 | } |
| 1283 | |
| 1284 | /* test inverted high/low source and destination ports. |
| 1285 | * originally, there was a problem with memory consumption when using |
| 1286 | * such rules. |
| 1287 | */ |
| 1288 | /* create dummy acl */ |
| 1289 | memcpy(&rule, &acl_rule, sizeof(struct rte_acl_ipv4vlan_rule)); |
| 1290 | rule.data.userdata = 1; |
| 1291 | rule.dst_port_low = 0xfff0; |
| 1292 | rule.dst_port_high = 0x0010; |
| 1293 | |
| 1294 | /* add rules to context and try to build it */ |
| 1295 | ret = rte_acl_ipv4vlan_add_rules(acx, &rule, 1); |
| 1296 | if (ret == 0) { |
| 1297 | printf("Line %i: Adding rules to ACL context " |
| 1298 | "should have failed!\n", __LINE__); |
| 1299 | goto err; |
| 1300 | } |
| 1301 | |
| 1302 | rule.dst_port_low = 0x0; |
| 1303 | rule.dst_port_high = 0xffff; |
| 1304 | rule.src_port_low = 0xfff0; |
| 1305 | rule.src_port_high = 0x0010; |
| 1306 | |
| 1307 | /* add rules to context and try to build it */ |
| 1308 | ret = rte_acl_ipv4vlan_add_rules(acx, &rule, 1); |
| 1309 | if (ret == 0) { |
| 1310 | printf("Line %i: Adding rules to ACL context " |
| 1311 | "should have failed!\n", __LINE__); |
| 1312 | goto err; |
| 1313 | } |
| 1314 | |
| 1315 | rule.dst_port_low = 0x0; |
| 1316 | rule.dst_port_high = 0xffff; |
| 1317 | rule.src_port_low = 0x0; |
| 1318 | rule.src_port_high = 0xffff; |
| 1319 | |
| 1320 | rule.dst_mask_len = 33; |
| 1321 | |
| 1322 | /* add rules to context and try to build it */ |
| 1323 | ret = rte_acl_ipv4vlan_add_rules(acx, &rule, 1); |
| 1324 | if (ret == 0) { |
| 1325 | printf("Line %i: Adding rules to ACL context " |
| 1326 | "should have failed!\n", __LINE__); |
| 1327 | goto err; |
no test coverage detected