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

Function test17

dpdk/app/test/test_lpm.c:1134–1206  ·  view source on GitHub ↗

* Test for overwriting of tbl8: * - add rule /32 and lookup * - add new rule /24 and lookup * - add third rule /25 and lookup * - lookup /32 and /24 rule to ensure the table has not been overwritten. */

Source from the content-addressed store, hash-verified

1132 * - lookup /32 and /24 rule to ensure the table has not been overwritten.
1133 */
1134int32_t
1135test17(void)
1136{
1137 struct rte_lpm *lpm = NULL;
1138 struct rte_lpm_config config;
1139
1140 config.max_rules = MAX_RULES;
1141 config.number_tbl8s = NUMBER_TBL8S;
1142 config.flags = 0;
1143 const uint32_t ip_10_32 = RTE_IPV4(10, 10, 10, 2);
1144 const uint32_t ip_10_24 = RTE_IPV4(10, 10, 10, 0);
1145 const uint32_t ip_20_25 = RTE_IPV4(10, 10, 20, 2);
1146 const uint8_t d_ip_10_32 = 32,
1147 d_ip_10_24 = 24,
1148 d_ip_20_25 = 25;
1149 const uint32_t next_hop_ip_10_32 = 100,
1150 next_hop_ip_10_24 = 105,
1151 next_hop_ip_20_25 = 111;
1152 uint32_t next_hop_return = 0;
1153 int32_t status = 0;
1154
1155 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1156 TEST_LPM_ASSERT(lpm != NULL);
1157
1158 if ((status = rte_lpm_add(lpm, ip_10_32, d_ip_10_32,
1159 next_hop_ip_10_32)) < 0)
1160 return -1;
1161
1162 status = rte_lpm_lookup(lpm, ip_10_32, &next_hop_return);
1163 uint32_t test_hop_10_32 = next_hop_return;
1164 TEST_LPM_ASSERT(status == 0);
1165 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_10_32);
1166
1167 if ((status = rte_lpm_add(lpm, ip_10_24, d_ip_10_24,
1168 next_hop_ip_10_24)) < 0)
1169 return -1;
1170
1171 status = rte_lpm_lookup(lpm, ip_10_24, &next_hop_return);
1172 uint32_t test_hop_10_24 = next_hop_return;
1173 TEST_LPM_ASSERT(status == 0);
1174 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_10_24);
1175
1176 if ((status = rte_lpm_add(lpm, ip_20_25, d_ip_20_25,
1177 next_hop_ip_20_25)) < 0)
1178 return -1;
1179
1180 status = rte_lpm_lookup(lpm, ip_20_25, &next_hop_return);
1181 uint32_t test_hop_20_25 = next_hop_return;
1182 TEST_LPM_ASSERT(status == 0);
1183 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_20_25);
1184
1185 if (test_hop_10_32 == test_hop_10_24) {
1186 printf("Next hop return equal\n");
1187 return -1;
1188 }
1189
1190 if (test_hop_10_24 == test_hop_20_25) {
1191 printf("Next hop return equal\n");

Callers

nothing calls this directly

Calls 5

rte_lpm_createFunction · 0.50
rte_lpm_addFunction · 0.50
rte_lpm_lookupFunction · 0.50
printfFunction · 0.50
rte_lpm_freeFunction · 0.50

Tested by

no test coverage detected