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

Function rte_ipsec_sad_create

dpdk/lib/ipsec/ipsec_sad.c:254–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254struct rte_ipsec_sad *
255rte_ipsec_sad_create(const char *name, const struct rte_ipsec_sad_conf *conf)
256{
257 char hash_name[RTE_HASH_NAMESIZE];
258 char sad_name[RTE_IPSEC_SAD_NAMESIZE];
259 struct rte_tailq_entry *te;
260 struct rte_ipsec_sad_list *sad_list;
261 struct rte_ipsec_sad *sad, *tmp_sad = NULL;
262 struct rte_hash_parameters hash_params = {0};
263 int ret;
264 uint32_t sa_sum;
265
266 RTE_BUILD_BUG_ON(RTE_IPSEC_SAD_KEY_TYPE_MASK != 3);
267
268 if ((name == NULL) || (conf == NULL) ||
269 ((conf->max_sa[RTE_IPSEC_SAD_SPI_ONLY] == 0) &&
270 (conf->max_sa[RTE_IPSEC_SAD_SPI_DIP] == 0) &&
271 (conf->max_sa[RTE_IPSEC_SAD_SPI_DIP_SIP] == 0))) {
272 rte_errno = EINVAL;
273 return NULL;
274 }
275
276 ret = snprintf(sad_name, RTE_IPSEC_SAD_NAMESIZE, SAD_FORMAT, name);
277 if (ret < 0 || ret >= RTE_IPSEC_SAD_NAMESIZE) {
278 rte_errno = ENAMETOOLONG;
279 return NULL;
280 }
281
282 /** Init SAD*/
283 sa_sum = RTE_MAX(MIN_HASH_ENTRIES,
284 conf->max_sa[RTE_IPSEC_SAD_SPI_ONLY]) +
285 RTE_MAX(MIN_HASH_ENTRIES,
286 conf->max_sa[RTE_IPSEC_SAD_SPI_DIP]) +
287 RTE_MAX(MIN_HASH_ENTRIES,
288 conf->max_sa[RTE_IPSEC_SAD_SPI_DIP_SIP]);
289 sad = rte_zmalloc_socket(NULL, sizeof(*sad) +
290 (sizeof(struct hash_cnt) * sa_sum),
291 RTE_CACHE_LINE_SIZE, conf->socket_id);
292 if (sad == NULL) {
293 rte_errno = ENOMEM;
294 return NULL;
295 }
296 memcpy(sad->name, sad_name, sizeof(sad_name));
297
298 hash_params.hash_func = DEFAULT_HASH_FUNC;
299 hash_params.hash_func_init_val = rte_rand();
300 sad->init_val = hash_params.hash_func_init_val;
301 hash_params.socket_id = conf->socket_id;
302 hash_params.name = hash_name;
303 if (conf->flags & RTE_IPSEC_SAD_FLAG_RW_CONCURRENCY)
304 hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY;
305
306 /** Init hash[RTE_IPSEC_SAD_SPI_ONLY] for SPI only */
307 snprintf(hash_name, sizeof(hash_name), "sad_1_%p", sad);
308 hash_params.key_len = sizeof(((struct rte_ipsec_sadv4_key *)0)->spi);
309 sad->keysize[RTE_IPSEC_SAD_SPI_ONLY] = hash_params.key_len;
310 hash_params.entries = sa_sum;
311 sad->hash[RTE_IPSEC_SAD_SPI_ONLY] = rte_hash_create(&hash_params);

Callers 11

mainFunction · 0.85
test_create_invalidFunction · 0.85
test_find_existingFunction · 0.85
test_multiple_createFunction · 0.85
__test_add_invalidFunction · 0.85
__test_delete_invalidFunction · 0.85
__test_lookup_invalidFunction · 0.85
__test_lookup_basicFunction · 0.85
__test_lookup_advFunction · 0.85
__test_lookup_orderFunction · 0.85
ipsec_sad_createFunction · 0.85

Calls 10

snprintfFunction · 0.85
rte_zmalloc_socketFunction · 0.85
rte_randFunction · 0.85
rte_hash_createFunction · 0.85
rte_ipsec_sad_destroyFunction · 0.85
strncmpFunction · 0.85
rte_zmallocFunction · 0.85
memcpyFunction · 0.50

Tested by 9

test_create_invalidFunction · 0.68
test_find_existingFunction · 0.68
test_multiple_createFunction · 0.68
__test_add_invalidFunction · 0.68
__test_delete_invalidFunction · 0.68
__test_lookup_invalidFunction · 0.68
__test_lookup_basicFunction · 0.68
__test_lookup_advFunction · 0.68
__test_lookup_orderFunction · 0.68