4 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * Security Associations
37 #include <sys/types.h>
38 #include <netinet/in.h>
39 #include <netinet/ip.h>
40 #include <netinet/ip6.h>
42 #include <rte_memzone.h>
43 #include <rte_crypto.h>
44 #include <rte_cryptodev.h>
45 #include <rte_byteorder.h>
46 #include <rte_errno.h>
48 #include <rte_random.h>
54 struct supported_cipher_algo {
56 enum rte_crypto_cipher_algorithm algo;
62 struct supported_auth_algo {
64 enum rte_crypto_auth_algorithm algo;
71 struct supported_aead_algo {
73 enum rte_crypto_aead_algorithm algo;
82 const struct supported_cipher_algo cipher_algos[] = {
85 .algo = RTE_CRYPTO_CIPHER_NULL,
91 .keyword = "aes-128-cbc",
92 .algo = RTE_CRYPTO_CIPHER_AES_CBC,
98 .keyword = "aes-128-gcm",
99 .algo = RTE_CRYPTO_CIPHER_AES_GCM,
105 .keyword = "aes-128-ctr",
106 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
108 .block_size = 16, /* XXX AESNI MB limition, should be 4 */
113 const struct supported_auth_algo auth_algos[] = {
116 .algo = RTE_CRYPTO_AUTH_NULL,
122 .keyword = "sha1-hmac",
123 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
128 .keyword = "sha256-hmac",
129 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
134 .keyword = "aes-128-gcm",
135 .algo = RTE_CRYPTO_AUTH_AES_GCM,
142 const struct supported_aead_algo aead_algos[] = { { } };
144 struct ipsec_sa sa_out[IPSEC_SA_MAX_ENTRIES];
147 struct ipsec_sa sa_in[IPSEC_SA_MAX_ENTRIES];
150 static const struct supported_cipher_algo *
151 find_match_cipher_algo(const char *cipher_keyword)
155 for (i = 0; i < RTE_DIM(cipher_algos); i++) {
156 const struct supported_cipher_algo *algo =
159 if (strcmp(cipher_keyword, algo->keyword) == 0)
166 static const struct supported_auth_algo *
167 find_match_auth_algo(const char *auth_keyword)
171 for (i = 0; i < RTE_DIM(auth_algos); i++) {
172 const struct supported_auth_algo *algo =
175 if (strcmp(auth_keyword, algo->keyword) == 0)
182 static const struct supported_aead_algo *
183 find_match_aead_algo(const char *aead_keyword)
187 for (i = 0; i < RTE_DIM(aead_algos); i++) {
188 const struct supported_aead_algo *algo =
191 if (strcmp(aead_keyword, algo->keyword) == 0)
199 * parse x:x:x:x.... hex number key string into uint8_t *key
201 * > 0: number of bytes parsed
205 parse_key_string(const char *key_str, uint8_t *key)
207 const char *pt_start = key_str, *pt_end = key_str;
208 uint32_t nb_bytes = 0;
210 while (pt_end != NULL) {
211 char sub_str[3] = {0};
213 pt_end = strchr(pt_start, ':');
215 if (pt_end == NULL) {
216 if (strlen(pt_start) > 2)
218 strncpy(sub_str, pt_start, 2);
220 if (pt_end - pt_start > 2)
223 strncpy(sub_str, pt_start, pt_end - pt_start);
224 pt_start = pt_end + 1;
227 key[nb_bytes++] = strtol(sub_str, NULL, 16);
234 parse_sa_tokens(char **tokens, uint32_t n_tokens,
235 struct parse_status *status)
237 struct ipsec_sa *rule = NULL;
238 uint32_t ti; /*token index*/
239 uint32_t *ri /*rule index*/;
240 uint32_t cipher_algo_p = 0;
241 uint32_t auth_algo_p = 0;
242 uint32_t aead_algo_p = 0;
247 if (strcmp(tokens[0], "in") == 0) {
250 APP_CHECK(*ri <= IPSEC_SA_MAX_ENTRIES - 1, status,
251 "too many sa rules, abort insertion\n");
252 if (status->status < 0)
259 APP_CHECK(*ri <= IPSEC_SA_MAX_ENTRIES - 1, status,
260 "too many sa rules, abort insertion\n");
261 if (status->status < 0)
268 APP_CHECK_TOKEN_IS_NUM(tokens, 1, status);
269 if (status->status < 0)
271 rule->spi = atoi(tokens[1]);
273 for (ti = 2; ti < n_tokens; ti++) {
274 if (strcmp(tokens[ti], "mode") == 0) {
275 APP_CHECK_PRESENCE(mode_p, tokens[ti], status);
276 if (status->status < 0)
279 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
280 if (status->status < 0)
283 if (strcmp(tokens[ti], "ipv4-tunnel") == 0)
284 rule->flags = IP4_TUNNEL;
285 else if (strcmp(tokens[ti], "ipv6-tunnel") == 0)
286 rule->flags = IP6_TUNNEL;
287 else if (strcmp(tokens[ti], "transport") == 0)
288 rule->flags = TRANSPORT;
290 APP_CHECK(0, status, "unrecognized "
291 "input \"%s\"", tokens[ti]);
299 if (strcmp(tokens[ti], "cipher_algo") == 0) {
300 const struct supported_cipher_algo *algo;
303 APP_CHECK_PRESENCE(cipher_algo_p, tokens[ti],
305 if (status->status < 0)
308 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
309 if (status->status < 0)
312 algo = find_match_cipher_algo(tokens[ti]);
314 APP_CHECK(algo != NULL, status, "unrecognized "
315 "input \"%s\"", tokens[ti]);
317 rule->cipher_algo = algo->algo;
318 rule->block_size = algo->block_size;
319 rule->iv_len = algo->iv_len;
320 rule->cipher_key_len = algo->key_len;
322 /* for NULL algorithm, no cipher key required */
323 if (rule->cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
328 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
329 if (status->status < 0)
332 APP_CHECK(strcmp(tokens[ti], "cipher_key") == 0,
333 status, "unrecognized input \"%s\", "
334 "expect \"cipher_key\"", tokens[ti]);
335 if (status->status < 0)
338 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
339 if (status->status < 0)
342 key_len = parse_key_string(tokens[ti],
344 APP_CHECK(key_len == rule->cipher_key_len, status,
345 "unrecognized input \"%s\"", tokens[ti]);
346 if (status->status < 0)
349 if (algo->algo == RTE_CRYPTO_CIPHER_AES_CBC)
350 rule->salt = (uint32_t)rte_rand();
352 if ((algo->algo == RTE_CRYPTO_CIPHER_AES_CTR) ||
353 (algo->algo == RTE_CRYPTO_CIPHER_AES_GCM)) {
355 rule->cipher_key_len = key_len;
357 &rule->cipher_key[key_len], 4);
364 if (strcmp(tokens[ti], "auth_algo") == 0) {
365 const struct supported_auth_algo *algo;
368 APP_CHECK_PRESENCE(auth_algo_p, tokens[ti],
370 if (status->status < 0)
373 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
374 if (status->status < 0)
377 algo = find_match_auth_algo(tokens[ti]);
378 APP_CHECK(algo != NULL, status, "unrecognized "
379 "input \"%s\"", tokens[ti]);
381 rule->auth_algo = algo->algo;
382 rule->auth_key_len = algo->key_len;
383 rule->digest_len = algo->digest_len;
384 rule->aad_len = algo->key_len;
386 /* NULL algorithm and combined algos do not
389 if (algo->key_not_req) {
394 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
395 if (status->status < 0)
398 APP_CHECK(strcmp(tokens[ti], "auth_key") == 0,
399 status, "unrecognized input \"%s\", "
400 "expect \"auth_key\"", tokens[ti]);
401 if (status->status < 0)
404 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
405 if (status->status < 0)
408 key_len = parse_key_string(tokens[ti],
410 APP_CHECK(key_len == rule->auth_key_len, status,
411 "unrecognized input \"%s\"", tokens[ti]);
412 if (status->status < 0)
419 if (strcmp(tokens[ti], "aead_algo") == 0) {
420 const struct supported_aead_algo *algo;
423 APP_CHECK_PRESENCE(aead_algo_p, tokens[ti],
425 if (status->status < 0)
428 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
429 if (status->status < 0)
432 algo = find_match_aead_algo(tokens[ti]);
434 APP_CHECK(algo != NULL, status, "unrecognized "
435 "input \"%s\"", tokens[ti]);
437 rule->aead_algo = algo->algo;
438 rule->cipher_key_len = algo->key_len;
439 rule->digest_len = algo->digest_len;
440 rule->aad_len = algo->key_len;
441 rule->block_size = algo->block_size;
442 rule->iv_len = algo->iv_len;
444 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
445 if (status->status < 0)
448 APP_CHECK(strcmp(tokens[ti], "aead_key") == 0,
449 status, "unrecognized input \"%s\", "
450 "expect \"aead_key\"", tokens[ti]);
451 if (status->status < 0)
454 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
455 if (status->status < 0)
458 key_len = parse_key_string(tokens[ti],
460 APP_CHECK(key_len == rule->cipher_key_len, status,
461 "unrecognized input \"%s\"", tokens[ti]);
462 if (status->status < 0)
466 rule->cipher_key_len = key_len;
468 &rule->cipher_key[key_len], 4);
474 if (strcmp(tokens[ti], "src") == 0) {
475 APP_CHECK_PRESENCE(src_p, tokens[ti], status);
476 if (status->status < 0)
479 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
480 if (status->status < 0)
483 if (rule->flags == IP4_TUNNEL) {
486 APP_CHECK(parse_ipv4_addr(tokens[ti],
487 &ip, NULL) == 0, status,
488 "unrecognized input \"%s\", "
489 "expect valid ipv4 addr",
491 if (status->status < 0)
493 rule->src.ip.ip4 = rte_bswap32(
494 (uint32_t)ip.s_addr);
495 } else if (rule->flags == IP6_TUNNEL) {
498 APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
500 "unrecognized input \"%s\", "
501 "expect valid ipv6 addr",
503 if (status->status < 0)
505 memcpy(rule->src.ip.ip6.ip6_b,
507 } else if (rule->flags == TRANSPORT) {
508 APP_CHECK(0, status, "unrecognized input "
509 "\"%s\"", tokens[ti]);
517 if (strcmp(tokens[ti], "dst") == 0) {
518 APP_CHECK_PRESENCE(dst_p, tokens[ti], status);
519 if (status->status < 0)
522 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
523 if (status->status < 0)
526 if (rule->flags == IP4_TUNNEL) {
529 APP_CHECK(parse_ipv4_addr(tokens[ti],
530 &ip, NULL) == 0, status,
531 "unrecognized input \"%s\", "
532 "expect valid ipv4 addr",
534 if (status->status < 0)
536 rule->dst.ip.ip4 = rte_bswap32(
537 (uint32_t)ip.s_addr);
538 } else if (rule->flags == IP6_TUNNEL) {
541 APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
543 "unrecognized input \"%s\", "
544 "expect valid ipv6 addr",
546 if (status->status < 0)
548 memcpy(rule->dst.ip.ip6.ip6_b, ip.s6_addr, 16);
549 } else if (rule->flags == TRANSPORT) {
550 APP_CHECK(0, status, "unrecognized "
551 "input \"%s\"", tokens[ti]);
559 /* unrecognizeable input */
560 APP_CHECK(0, status, "unrecognized input \"%s\"",
566 APP_CHECK(cipher_algo_p == 0, status,
567 "AEAD used, no need for cipher options");
568 if (status->status < 0)
571 APP_CHECK(auth_algo_p == 0, status,
572 "AEAD used, no need for auth options");
573 if (status->status < 0)
576 APP_CHECK(cipher_algo_p == 1, status, "missing cipher or AEAD options");
577 if (status->status < 0)
580 APP_CHECK(auth_algo_p == 1, status, "missing auth or AEAD options");
581 if (status->status < 0)
585 APP_CHECK(mode_p == 1, status, "missing mode option");
586 if (status->status < 0)
593 print_one_sa_rule(const struct ipsec_sa *sa, int inbound)
598 printf("\tspi_%s(%3u):", inbound?"in":"out", sa->spi);
600 for (i = 0; i < RTE_DIM(cipher_algos); i++) {
601 if (cipher_algos[i].algo == sa->cipher_algo) {
602 printf("%s ", cipher_algos[i].keyword);
607 for (i = 0; i < RTE_DIM(auth_algos); i++) {
608 if (auth_algos[i].algo == sa->auth_algo) {
609 printf("%s ", auth_algos[i].keyword);
614 for (i = 0; i < RTE_DIM(aead_algos); i++) {
615 if (aead_algos[i].algo == sa->aead_algo) {
616 printf("%s ", aead_algos[i].keyword);
625 printf("IP4Tunnel ");
626 uint32_t_to_char(sa->src.ip.ip4, &a, &b, &c, &d);
627 printf("%hhu.%hhu.%hhu.%hhu ", d, c, b, a);
628 uint32_t_to_char(sa->dst.ip.ip4, &a, &b, &c, &d);
629 printf("%hhu.%hhu.%hhu.%hhu", d, c, b, a);
632 printf("IP6Tunnel ");
633 for (i = 0; i < 16; i++) {
634 if (i % 2 && i != 15)
635 printf("%.2x:", sa->src.ip.ip6.ip6_b[i]);
637 printf("%.2x", sa->src.ip.ip6.ip6_b[i]);
640 for (i = 0; i < 16; i++) {
641 if (i % 2 && i != 15)
642 printf("%.2x:", sa->dst.ip.ip6.ip6_b[i]);
644 printf("%.2x", sa->dst.ip.ip6.ip6_b[i]);
655 struct ipsec_sa sa[IPSEC_SA_MAX_ENTRIES];
657 struct rte_crypto_sym_xform a;
658 struct rte_crypto_sym_xform b;
659 } xf[IPSEC_SA_MAX_ENTRIES];
662 static struct sa_ctx *
663 sa_create(const char *name, int32_t socket_id)
666 struct sa_ctx *sa_ctx;
668 const struct rte_memzone *mz;
670 snprintf(s, sizeof(s), "%s_%u", name, socket_id);
672 /* Create SA array table */
673 printf("Creating SA context with %u maximum entries\n",
674 IPSEC_SA_MAX_ENTRIES);
676 mz_size = sizeof(struct sa_ctx);
677 mz = rte_memzone_reserve(s, mz_size, socket_id,
678 RTE_MEMZONE_1GB | RTE_MEMZONE_SIZE_HINT_ONLY);
680 printf("Failed to allocate SA DB memory\n");
685 sa_ctx = (struct sa_ctx *)mz->addr;
691 sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],
692 uint32_t nb_entries, uint32_t inbound)
698 for (i = 0; i < nb_entries; i++) {
699 idx = SPI2IDX(entries[i].spi);
700 sa = &sa_ctx->sa[idx];
702 printf("Index %u already in use by SPI %u\n",
711 sa->src.ip.ip4 = rte_cpu_to_be_32(sa->src.ip.ip4);
712 sa->dst.ip.ip4 = rte_cpu_to_be_32(sa->dst.ip.ip4);
715 switch (sa->cipher_algo) {
716 case RTE_CRYPTO_CIPHER_NULL:
717 case RTE_CRYPTO_CIPHER_AES_CBC:
718 iv_length = sa->iv_len;
720 case RTE_CRYPTO_CIPHER_AES_CTR:
721 case RTE_CRYPTO_CIPHER_AES_GCM:
725 RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
731 sa_ctx->xf[idx].b.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
732 sa_ctx->xf[idx].b.cipher.algo = sa->cipher_algo;
733 sa_ctx->xf[idx].b.cipher.key.data = sa->cipher_key;
734 sa_ctx->xf[idx].b.cipher.key.length =
736 sa_ctx->xf[idx].b.cipher.op =
737 RTE_CRYPTO_CIPHER_OP_DECRYPT;
738 sa_ctx->xf[idx].b.cipher.iv.offset = IV_OFFSET;
739 sa_ctx->xf[idx].b.cipher.iv.length = iv_length;
740 sa_ctx->xf[idx].b.next = NULL;
742 sa_ctx->xf[idx].a.type = RTE_CRYPTO_SYM_XFORM_AUTH;
743 sa_ctx->xf[idx].a.auth.algo = sa->auth_algo;
744 sa_ctx->xf[idx].a.auth.add_auth_data_length =
746 sa_ctx->xf[idx].a.auth.key.data = sa->auth_key;
747 sa_ctx->xf[idx].a.auth.key.length =
749 sa_ctx->xf[idx].a.auth.digest_length =
751 sa_ctx->xf[idx].a.auth.op =
752 RTE_CRYPTO_AUTH_OP_VERIFY;
754 } else { /* outbound */
755 sa_ctx->xf[idx].a.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
756 sa_ctx->xf[idx].a.cipher.algo = sa->cipher_algo;
757 sa_ctx->xf[idx].a.cipher.key.data = sa->cipher_key;
758 sa_ctx->xf[idx].a.cipher.key.length =
760 sa_ctx->xf[idx].a.cipher.op =
761 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
762 sa_ctx->xf[idx].a.cipher.iv.offset = IV_OFFSET;
763 sa_ctx->xf[idx].a.cipher.iv.length = iv_length;
764 sa_ctx->xf[idx].a.next = NULL;
766 sa_ctx->xf[idx].b.type = RTE_CRYPTO_SYM_XFORM_AUTH;
767 sa_ctx->xf[idx].b.auth.algo = sa->auth_algo;
768 sa_ctx->xf[idx].b.auth.add_auth_data_length =
770 sa_ctx->xf[idx].b.auth.key.data = sa->auth_key;
771 sa_ctx->xf[idx].b.auth.key.length =
773 sa_ctx->xf[idx].b.auth.digest_length =
775 sa_ctx->xf[idx].b.auth.op =
776 RTE_CRYPTO_AUTH_OP_GENERATE;
779 sa_ctx->xf[idx].a.next = &sa_ctx->xf[idx].b;
780 sa_ctx->xf[idx].b.next = NULL;
781 sa->xforms = &sa_ctx->xf[idx].a;
783 print_one_sa_rule(sa, inbound);
790 sa_out_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],
793 return sa_add_rules(sa_ctx, entries, nb_entries, 0);
797 sa_in_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],
800 return sa_add_rules(sa_ctx, entries, nb_entries, 1);
804 sa_init(struct socket_ctx *ctx, int32_t socket_id)
809 rte_exit(EXIT_FAILURE, "NULL context.\n");
811 if (ctx->sa_in != NULL)
812 rte_exit(EXIT_FAILURE, "Inbound SA DB for socket %u already "
813 "initialized\n", socket_id);
815 if (ctx->sa_out != NULL)
816 rte_exit(EXIT_FAILURE, "Outbound SA DB for socket %u already "
817 "initialized\n", socket_id);
821 ctx->sa_in = sa_create(name, socket_id);
822 if (ctx->sa_in == NULL)
823 rte_exit(EXIT_FAILURE, "Error [%d] creating SA "
824 "context %s in socket %d\n", rte_errno,
827 sa_in_add_rules(ctx->sa_in, sa_in, nb_sa_in);
829 RTE_LOG(WARNING, IPSEC, "No SA Inbound rule specified\n");
833 ctx->sa_out = sa_create(name, socket_id);
834 if (ctx->sa_out == NULL)
835 rte_exit(EXIT_FAILURE, "Error [%d] creating SA "
836 "context %s in socket %d\n", rte_errno,
839 sa_out_add_rules(ctx->sa_out, sa_out, nb_sa_out);
841 RTE_LOG(WARNING, IPSEC, "No SA Outbound rule "
846 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx)
848 struct ipsec_mbuf_metadata *priv;
850 priv = RTE_PTR_ADD(m, sizeof(struct rte_mbuf));
852 return (sa_ctx->sa[sa_idx].spi == priv->sa->spi);
856 single_inbound_lookup(struct ipsec_sa *sadb, struct rte_mbuf *pkt,
857 struct ipsec_sa **sa_ret)
867 ip = rte_pktmbuf_mtod(pkt, struct ip *);
868 if (ip->ip_v == IPVERSION)
869 esp = (struct esp_hdr *)(ip + 1);
871 esp = (struct esp_hdr *)(((struct ip6_hdr *)ip) + 1);
873 if (esp->spi == INVALID_SPI)
876 sa = &sadb[SPI2IDX(rte_be_to_cpu_32(esp->spi))];
877 if (rte_be_to_cpu_32(esp->spi) != sa->spi)
882 src4_addr = RTE_PTR_ADD(ip, offsetof(struct ip, ip_src));
883 if ((ip->ip_v == IPVERSION) &&
884 (sa->src.ip.ip4 == *src4_addr) &&
885 (sa->dst.ip.ip4 == *(src4_addr + 1)))
889 src6_addr = RTE_PTR_ADD(ip, offsetof(struct ip6_hdr, ip6_src));
890 if ((ip->ip_v == IP6_VERSION) &&
891 !memcmp(&sa->src.ip.ip6.ip6, src6_addr, 16) &&
892 !memcmp(&sa->dst.ip.ip6.ip6, src6_addr + 16, 16))
901 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
902 struct ipsec_sa *sa[], uint16_t nb_pkts)
906 for (i = 0; i < nb_pkts; i++)
907 single_inbound_lookup(sa_ctx->sa, pkts[i], &sa[i]);
911 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
912 struct ipsec_sa *sa[], uint16_t nb_pkts)
916 for (i = 0; i < nb_pkts; i++)
917 sa[i] = &sa_ctx->sa[sa_idx[i]];