git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
app/crypto-perf: check lcore job failure
[dpdk.git]
/
examples
/
ipsec-secgw
/
sa.c
diff --git
a/examples/ipsec-secgw/sa.c
b/examples/ipsec-secgw/sa.c
index
a7298a3
..
7262cce
100644
(file)
--- a/
examples/ipsec-secgw/sa.c
+++ b/
examples/ipsec-secgw/sa.c
@@
-126,11
+126,11
@@
const struct supported_aead_algo aead_algos[] = {
}
};
}
};
-struct ipsec_sa sa_out[IPSEC_SA_MAX_ENTRIES];
-uint32_t nb_sa_out;
+st
atic st
ruct ipsec_sa sa_out[IPSEC_SA_MAX_ENTRIES];
+
static
uint32_t nb_sa_out;
-struct ipsec_sa sa_in[IPSEC_SA_MAX_ENTRIES];
-uint32_t nb_sa_in;
+st
atic st
ruct ipsec_sa sa_in[IPSEC_SA_MAX_ENTRIES];
+
static
uint32_t nb_sa_in;
static const struct supported_cipher_algo *
find_match_cipher_algo(const char *cipher_keyword)
static const struct supported_cipher_algo *
find_match_cipher_algo(const char *cipher_keyword)
@@
-631,7
+631,7
@@
parse_sa_tokens(char **tokens, uint32_t n_tokens,
*ri = *ri + 1;
}
*ri = *ri + 1;
}
-static
inline
void
+static void
print_one_sa_rule(const struct ipsec_sa *sa, int inbound)
{
uint32_t i;
print_one_sa_rule(const struct ipsec_sa *sa, int inbound)
{
uint32_t i;
@@
-951,7
+951,7
@@
get_spi_proto(uint32_t spi, enum rte_security_ipsec_sa_direction dir)
if (rc6 >= 0) {
RTE_LOG(ERR, IPSEC,
"%s: SPI %u used simultaeously by "
if (rc6 >= 0) {
RTE_LOG(ERR, IPSEC,
"%s: SPI %u used simultaeously by "
- "
IPv
4(%d) and IPv6 (%d) SP rules\n",
+ "
RTE_IPV
4(%d) and IPv6 (%d) SP rules\n",
__func__, spi, rc4, rc6);
return -EINVAL;
} else
__func__, spi, rc4, rc6);
return -EINVAL;
} else
@@
-967,7
+967,7
@@
get_spi_proto(uint32_t spi, enum rte_security_ipsec_sa_direction dir)
static int
fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss,
static int
fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss,
- const struct
ipv4_hdr *v4, struct
ipv6_hdr *v6)
+ const struct
rte_ipv4_hdr *v4, struct rte_
ipv6_hdr *v6)
{
int32_t rc;
{
int32_t rc;
@@
-1038,15
+1038,15
@@
ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)
{
int rc;
struct rte_ipsec_sa_prm prm;
{
int rc;
struct rte_ipsec_sa_prm prm;
- struct ipv4_hdr v4 = {
+ struct
rte_
ipv4_hdr v4 = {
.version_ihl = IPVERSION << 4 |
.version_ihl = IPVERSION << 4 |
- sizeof(v4) / IPV4_IHL_MULTIPLIER,
+ sizeof(v4) /
RTE_
IPV4_IHL_MULTIPLIER,
.time_to_live = IPDEFTTL,
.next_proto_id = IPPROTO_ESP,
.src_addr = lsa->src.ip.ip4,
.dst_addr = lsa->dst.ip.ip4,
};
.time_to_live = IPDEFTTL,
.next_proto_id = IPPROTO_ESP,
.src_addr = lsa->src.ip.ip4,
.dst_addr = lsa->dst.ip.ip4,
};
- struct ipv6_hdr v6 = {
+ struct
rte_
ipv6_hdr v6 = {
.vtc_flow = htonl(IP6_VERSION << 28),
.proto = IPPROTO_ESP,
};
.vtc_flow = htonl(IP6_VERSION << 28),
.proto = IPPROTO_ESP,
};
@@
-1116,6
+1116,31
@@
ipsec_satbl_init(struct sa_ctx *ctx, const struct ipsec_sa *ent,
return rc;
}
return rc;
}
+/*
+ * Walk through all SA rules to find an SA with given SPI
+ */
+int
+sa_spi_present(uint32_t spi, int inbound)
+{
+ uint32_t i, num;
+ const struct ipsec_sa *sar;
+
+ if (inbound != 0) {
+ sar = sa_in;
+ num = nb_sa_in;
+ } else {
+ sar = sa_out;
+ num = nb_sa_out;
+ }
+
+ for (i = 0; i != num; i++) {
+ if (sar[i].spi == spi)
+ return i;
+ }
+
+ return -ENOENT;
+}
+
void
sa_init(struct socket_ctx *ctx, int32_t socket_id)
{
void
sa_init(struct socket_ctx *ctx, int32_t socket_id)
{
@@
-1194,7
+1219,7
@@
static inline void
single_inbound_lookup(struct ipsec_sa *sadb, struct rte_mbuf *pkt,
struct ipsec_sa **sa_ret)
{
single_inbound_lookup(struct ipsec_sa *sadb, struct rte_mbuf *pkt,
struct ipsec_sa **sa_ret)
{
- struct esp_hdr *esp;
+ struct
rte_
esp_hdr *esp;
struct ip *ip;
uint32_t *src4_addr;
uint8_t *src6_addr;
struct ip *ip;
uint32_t *src4_addr;
uint8_t *src6_addr;
@@
-1203,10
+1228,7
@@
single_inbound_lookup(struct ipsec_sa *sadb, struct rte_mbuf *pkt,
*sa_ret = NULL;
ip = rte_pktmbuf_mtod(pkt, struct ip *);
*sa_ret = NULL;
ip = rte_pktmbuf_mtod(pkt, struct ip *);
- if (ip->ip_v == IPVERSION)
- esp = (struct esp_hdr *)(ip + 1);
- else
- esp = (struct esp_hdr *)(((struct ip6_hdr *)ip) + 1);
+ esp = rte_pktmbuf_mtod_offset(pkt, struct rte_esp_hdr *, pkt->l3_len);
if (esp->spi == INVALID_SPI)
return;
if (esp->spi == INVALID_SPI)
return;