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

Function sa_init

dpdk/examples/ipsec-secgw/sa.c:1693–1762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1691}
1692
1693void
1694sa_init(struct socket_ctx *ctx, int32_t socket_id,
1695 struct lcore_conf *lcore_conf,
1696 const struct eventmode_conf *em_conf)
1697{
1698 int32_t rc;
1699 const char *name;
1700 uint32_t lcore_id;
1701 struct ipsec_ctx *ipsec_ctx[RTE_MAX_LCORE];
1702
1703 if (ctx == NULL)
1704 rte_exit(EXIT_FAILURE, "NULL context.\n");
1705
1706 if (ctx->sa_in != NULL)
1707 rte_exit(EXIT_FAILURE, "Inbound SA DB for socket %u already "
1708 "initialized\n", socket_id);
1709
1710 if (ctx->sa_out != NULL)
1711 rte_exit(EXIT_FAILURE, "Outbound SA DB for socket %u already "
1712 "initialized\n", socket_id);
1713
1714 if (nb_sa_in > 0) {
1715 name = "sa_in";
1716 ctx->sa_in = sa_create(name, socket_id, nb_sa_in);
1717 if (ctx->sa_in == NULL)
1718 rte_exit(EXIT_FAILURE, "Error [%d] creating SA "
1719 "context %s in socket %d\n", rte_errno,
1720 name, socket_id);
1721
1722 rc = ipsec_sad_create(name, &ctx->sa_in->sad, socket_id,
1723 &sa_in_cnt);
1724 if (rc != 0)
1725 rte_exit(EXIT_FAILURE, "failed to init SAD\n");
1726 RTE_LCORE_FOREACH(lcore_id)
1727 ipsec_ctx[lcore_id] = &lcore_conf[lcore_id].inbound;
1728 sa_in_add_rules(ctx->sa_in, sa_in, nb_sa_in, ctx, ipsec_ctx, em_conf);
1729
1730 if (app_sa_prm.enable != 0) {
1731 rc = ipsec_satbl_init(ctx->sa_in, nb_sa_in,
1732 socket_id, ctx, ipsec_ctx, em_conf);
1733 if (rc != 0)
1734 rte_exit(EXIT_FAILURE,
1735 "failed to init inbound SAs\n");
1736 }
1737 } else
1738 RTE_LOG(WARNING, IPSEC, "No SA Inbound rule specified\n");
1739
1740 if (nb_sa_out > 0) {
1741 name = "sa_out";
1742 ctx->sa_out = sa_create(name, socket_id, nb_sa_out);
1743 if (ctx->sa_out == NULL)
1744 rte_exit(EXIT_FAILURE, "Error [%d] creating SA "
1745 "context %s in socket %d\n", rte_errno,
1746 name, socket_id);
1747
1748 RTE_LCORE_FOREACH(lcore_id)
1749 ipsec_ctx[lcore_id] = &lcore_conf[lcore_id].outbound;
1750 sa_out_add_rules(ctx->sa_out, sa_out, nb_sa_out, ctx, ipsec_ctx, em_conf);

Callers 1

mainFunction · 0.85

Calls 6

rte_exitFunction · 0.85
sa_createFunction · 0.85
ipsec_sad_createFunction · 0.85
sa_in_add_rulesFunction · 0.85
ipsec_satbl_initFunction · 0.85
sa_out_add_rulesFunction · 0.85

Tested by

no test coverage detected