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

Function test_ipsec_proto_process

dpdk/app/test/test_cryptodev.c:10126–10397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10124}
10125
10126static int
10127test_ipsec_proto_process(const struct ipsec_test_data td[],
10128 struct ipsec_test_data res_d[],
10129 int nb_td,
10130 bool silent,
10131 const struct ipsec_test_flags *flags)
10132{
10133 uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10134 0x0000, 0x001a};
10135 uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10136 0xe82c, 0x4887};
10137 const struct rte_ipv4_hdr *ipv4 =
10138 (const struct rte_ipv4_hdr *)td[0].output_text.data;
10139 int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10140 struct crypto_testsuite_params *ts_params = &testsuite_params;
10141 struct crypto_unittest_params *ut_params = &unittest_params;
10142 struct rte_security_capability_idx sec_cap_idx;
10143 const struct rte_security_capability *sec_cap;
10144 struct rte_security_ipsec_xform ipsec_xform;
10145 uint8_t dev_id = ts_params->valid_devs[0];
10146 enum rte_security_ipsec_sa_direction dir;
10147 struct ipsec_test_data *res_d_tmp = NULL;
10148 uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10149 int salt_len, i, ret = TEST_SUCCESS;
10150 void *ctx;
10151 uint32_t src, dst;
10152 uint32_t verify;
10153
10154 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10155 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10156
10157 /* Use first test data to create session */
10158
10159 /* Copy IPsec xform */
10160 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10161
10162 dir = ipsec_xform.direction;
10163 verify = flags->tunnel_hdr_verify;
10164
10165 memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10166 memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10167
10168 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10169 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10170 src += 1;
10171 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10172 dst += 1;
10173 }
10174
10175 if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10176 if (td->ipsec_xform.tunnel.type ==
10177 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10178 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10179 sizeof(src));
10180 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10181 sizeof(dst));
10182
10183 if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)

Tested by

no test coverage detected