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

Function test_invalid_layout

dpdk/app/test/test_acl.c:1015–1130  ·  view source on GitHub ↗

* Test wrong layout behavior * This test supplies the ACL context with invalid layout, which results in * ACL matching the wrong stuff. However, it should match the wrong stuff * the right way. We switch around source and destination addresses, * source and destination ports, and protocol will point to first byte of * destination port. */

Source from the content-addressed store, hash-verified

1013 * destination port.
1014 */
1015static int
1016test_invalid_layout(void)
1017{
1018 struct rte_acl_ctx *acx;
1019 int ret, i;
1020
1021 uint32_t results[RTE_DIM(invalid_layout_data)];
1022 const uint8_t *data[RTE_DIM(invalid_layout_data)];
1023
1024 const uint32_t layout[RTE_ACL_IPV4VLAN_NUM] = {
1025 /* proto points to destination port's first byte */
1026 offsetof(struct ipv4_7tuple, port_dst),
1027
1028 0, /* VLAN not used */
1029
1030 /* src and dst addresses are swapped */
1031 offsetof(struct ipv4_7tuple, ip_dst),
1032 offsetof(struct ipv4_7tuple, ip_src),
1033
1034 /*
1035 * we can't swap ports here, so we will swap
1036 * them in the data
1037 */
1038 offsetof(struct ipv4_7tuple, port_src),
1039 };
1040
1041 acx = rte_acl_create(&acl_param);
1042 if (acx == NULL) {
1043 printf("Line %i: Error creating ACL context!\n", __LINE__);
1044 return -1;
1045 }
1046
1047 /* putting a lot of rules into the context results in greater
1048 * coverage numbers. it doesn't matter if they are identical */
1049 for (i = 0; i < 1000; i++) {
1050 /* add rules to the context */
1051 ret = rte_acl_ipv4vlan_add_rules(acx, invalid_layout_rules,
1052 RTE_DIM(invalid_layout_rules));
1053 if (ret != 0) {
1054 printf("Line %i: Adding rules to ACL context failed!\n",
1055 __LINE__);
1056 rte_acl_free(acx);
1057 return -1;
1058 }
1059 }
1060
1061 /* try building the context */
1062 ret = rte_acl_ipv4vlan_build(acx, layout, 1);
1063 if (ret != 0) {
1064 printf("Line %i: Building ACL context failed!\n", __LINE__);
1065 rte_acl_free(acx);
1066 return -1;
1067 }
1068
1069 /* swap all bytes in the data to network order */
1070 bswap_test_data(invalid_layout_data, RTE_DIM(invalid_layout_data), 1);
1071
1072 /* prepare data */

Callers 1

test_aclFunction · 0.85

Calls 7

rte_acl_createFunction · 0.85
rte_acl_freeFunction · 0.85
rte_acl_ipv4vlan_buildFunction · 0.85
bswap_test_dataFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected