IPsec Sec GW new features
cover IPsec Sec GW new features
Update the IPsec sample app with new features and updates:
- NAT-T and TSO support
- telemetry support
- ol_flags support
- reset callback, enable stats by default, initial SQN
Depends on series 18279 ('new features for ipsec and security libraries')
Radu Nicolau (7):
examples/ipsec-secgw: add ol_flags support examples/ipsec-secgw: add support for NAT-T examples/ipsec-secgw: add support for TSO examples/ipsec-secgw: enable stats by default examples/ipsec-secgw: add support for telemetry examples/ipsec-secgw: add support for defining initial sequence number
value
examples/ipsec-secgw: add ethdev reset callback
examples/ipsec-secgw/esp.c | 7 +- examples/ipsec-secgw/ipsec-secgw.c | 404 +++++++++++++++++++++++++--- examples/ipsec-secgw/ipsec-secgw.h | 33 ++- examples/ipsec-secgw/ipsec.c | 380 ++++++++++++--------------- examples/ipsec-secgw/ipsec.h | 26 +- examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 407 ++++++++++++++++++++++++----- examples/ipsec-secgw/sad.c | 10 +- examples/ipsec-secgw/sad.h | 20 +- 9 files changed, 941 insertions(+), 348 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/7 examples/ipsec-secgw: add ol_flags support
Add support for ol_flags to the IPsec GW sample app.
--- examples/ipsec-secgw/ipsec-secgw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +5 -8
@@ -515,7 +515,7 @@ prepare_traffic(struct rte_mbuf **pkts, struct ipsec_traffic *t,static inline void prepare_tx_pkt (struct rte_mbuf *pkt,uint16_t port, -const struct lcore_conf *qconf) + const struct lcore_conf *qconf __rte_unused) {struct ip *ip;struct rte_ether_hdr *ethhdr;
@@ -526,20 +526,17 @@ prepare_tx_pkt(struct rte_mbuf *pkt, uint16_t port,rte_pktmbuf_prepend (pkt,RTE_ETHER_HDR_LEN );if (ip->ip_v ==IPVERSION ) { - pkt->ol_flags |= qconf->outbound.ipv4_offloads; - pkt->l3_len =sizeof (struct ip ); pkt->l2_len =RTE_ETHER_HDR_LEN ; - ip->ip_sum =0 ; -/* calculate IPv4 cksum in SW */ -if ((pkt->ol_flags &PKT_TX_IP_CKSUM ) ==0 ) +if ((pkt->ol_flags & + (PKT_TX_IP_CKSUM |PKT_TX_OUTER_IP_CKSUM )) ==0 ) ip->ip_sum =rte_ipv4_cksum ((struct rte_ipv4_hdr *)ip); +else + ip->ip_sum =0 ; ethhdr->ether_type =rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV4 ); }else { - pkt->ol_flags |= qconf->outbound.ipv6_offloads; - pkt->l3_len =sizeof (struct ip6_hdr ); pkt->l2_len =RTE_ETHER_HDR_LEN ; ethhdr->ether_type =rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV6 );
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 1/7] examples/ipsec-secgw: add ol_flags support
Quoted 1 line
Add support for
ol_flagsto the IPsec GW sample app.
Description is not appropriate. ol_flags are supported to do what? How the existing code was not good and what benefit do we get from this patch?
Quoted 54 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec-secgw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)examples/ipsec- renamed from examples/ipsec-secgw/ipsec-secgw.c +0
-0
secgw/ipsec-secgw.c
indexf252d34985..6d516e2221100644examples/ipsec-secgw/ipsec-secgw.c +1
-1@@ -515,7 +515,7 @@ prepare_traffic(struct rte_mbuf **pkts, structipsec_traffic *t, static inline void prepare_tx_pkt(struct rte_mbuf *pkt, uint16_t port, - const struct lcore_conf *qconf) + const struct lcore_conf *qconf __rte_unused) { struct ip *ip;examples/ipsec-secgw/ipsec-secgw.c +4
-7struct rte_ether_hdr *ethhdr;@@ -526,20 +526,17 @@ prepare_tx_pkt(struct rte_mbuf *pkt, uint16_t port,rte_pktmbuf_prepend (pkt,RTE_ETHER_HDR_LEN );if (ip->ip_v ==IPVERSION ) { - pkt->ol_flags |= qconf->outbound.ipv4_offloads; - pkt->l3_len =sizeof (struct ip ); pkt->l2_len =RTE_ETHER_HDR_LEN ; - ip->ip_sum =0 ; -/* calculate IPv4 cksum in SW */ -if ((pkt->ol_flags &PKT_TX_IP_CKSUM ) ==0 ) +if ((pkt->ol_flags & + (PKT_TX_IP_CKSUM |PKT_TX_OUTER_IP_CKSUM )) ==0 ) ip->ip_sum =rte_ipv4_cksum ((struct rte_ipv4_hdr *)ip); +else + ip->ip_sum =0 ; ethhdr->ether_type =rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV4 ); }else { - pkt->ol_flags |= qconf->outbound.ipv6_offloads; - pkt->l3_len =sizeof (struct ip6_hdr ); pkt->l2_len =RTE_ETHER_HDR_LEN ; ethhdr->ether_type =
rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
--
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 1/7] examples/ipsec-secgw: add ol_flags support
Hi Akhil,
Quoted 6 lines · Akhil Goyal
Quoted 1 line
Add support for
ol_flagsto the IPsec GW sample app.Description is not appropriate.
ol_flagsare supported to do what? How the existing code was not good and what benefit do we get from this patch?
Thanks for reviewing the series! I will address your feedback for all the patches in the v2.
PATCH 2/7 examples/ipsec-secgw: add support for NAT-T
In reply to Radu NicolauAdd support to the sample application to support IPsec NAT-T for both transport and tunnel modes, for both IPv4 and IPv6.
--- examples/ipsec-secgw/esp.c | 7 +- examples/ipsec-secgw/ipsec-secgw.c | 3 - examples/ipsec-secgw/ipsec.c | 375 ++++++++++++----------------- examples/ipsec-secgw/ipsec.h | 19 +- examples/ipsec-secgw/sa.c | 240 +++++++++++++----- examples/ipsec-secgw/sad.c | 10 +- examples/ipsec-secgw/sad.h | 20 +- 7 files changed, 365 insertions(+), 309 deletions(-)
examples/ipsec-secgw/esp.c +4 -3
@@ -265,9 +265,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,RTE_ASSERT (IS_TUNNEL (sa->flags) ||IS_TRANSPORT (sa->flags)); -if (likely (IS_IP4_TUNNEL (sa->flags))) +if (likely ((IS_TUNNEL (sa->flags) &&IS_IP4 (sa->flags)))) ip_hdr_len =sizeof (struct ip ); -else if (IS_IP6_TUNNEL (sa->flags)) +else if ((IS_TUNNEL (sa->flags) &&IS_IP6 (sa->flags))) ip_hdr_len =sizeof (struct ip6_hdr );else if (!IS_TRANSPORT (sa->flags)) { RTE_LOG(ERR, IPSEC_ESP, "Unsupported SA flags: 0x%x\n",
@@ -308,7 +308,8 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa, &sa->src, &sa->dst); esp = (struct rte_esp_hdr *)(ip6 +1 );break ; -case TRANSPORT : +case IP4_TRANSPORT : +case IP6_TRANSPORT : new_ip = (uint8_t *)rte_pktmbuf_prepend (m,sizeof (struct rte_esp_hdr ) + sa->iv_len);memmove (new_ip, ip4, ip_hdr_len);
examples/ipsec-secgw/ipsec-secgw.c +0 -3
@@ -2299,9 +2299,6 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads)/* Pre-populate pkt offloads based on capabilities */ qconf->outbound.ipv4_offloads =PKT_TX_IPV4 ; qconf->outbound.ipv6_offloads =PKT_TX_IPV6 ; -if (local_port_conf.txmode.offloads &DEV_TX_OFFLOAD_IPV4_CKSUM ) - qconf->outbound.ipv4_offloads |=PKT_TX_IP_CKSUM ; - tx_queueid++;/* init RX queues */
examples/ipsec-secgw/ipsec.c +157 -218
456 lines not on this page · raw message
examples/ipsec-secgw/ipsec.h +11 -8
@@ -122,11 +122,15 @@ struct ipsec_sa {uint16_t flags;#define IP4_TUNNEL (1 << 0)#define IP6_TUNNEL (1 << 1) -#define TRANSPORT (1 << 2) +#define NATT_UDP_TUNNEL (1 << 2)#define IP4_TRANSPORT (1 << 3)#define IP6_TRANSPORT (1 << 4)struct ip_addr src;struct ip_addr dst; +struct { +uint16_t sport; +uint16_t dport; + } udp;uint8_t cipher_key[MAX_KEY_SIZE ];uint16_t cipher_key_len;uint8_t auth_key[MAX_KEY_SIZE ];
@@ -142,7 +146,7 @@ struct ipsec_sa {uint8_t fdir_qid;uint8_t fdir_flag; -#define MAX_RTE_FLOW_PATTERN (4) +#define MAX_RTE_FLOW_PATTERN (5)#define MAX_RTE_FLOW_ACTIONS (3)struct rte_flow_item pattern[MAX_RTE_FLOW_PATTERN ];struct rte_flow_action action[MAX_RTE_FLOW_ACTIONS ];
@@ -151,6 +155,7 @@ struct ipsec_sa {struct rte_flow_item_ipv4 ipv4_spec;struct rte_flow_item_ipv6 ipv6_spec; }; +struct rte_flow_item_udp udp_spec;struct rte_flow_item_esp esp_spec;struct rte_flow *flow;struct rte_security_session_conf sess_conf;
@@ -181,18 +186,16 @@ struct ipsec_mbuf_metadata {uint8_t buf[32 ]; } __rte_cache_aligned; -#define IS_TRANSPORT (flags) ((flags) & TRANSPORT) +#define IS_TRANSPORT (flags) ((flags) & (IP4_TRANSPORT | IP6_TRANSPORT))#define IS_TUNNEL (flags) ((flags) & (IP4_TUNNEL | IP6_TUNNEL)) +#define IS_NATT_UDP_TUNNEL (flags) ((flags) & NATT_UDP_TUNNEL) +#define IS_IP4 (flags) ((flags) & (IP4_TUNNEL | IP4_TRANSPORT))#define IS_IP6 (flags) ((flags) & (IP6_TUNNEL | IP6_TRANSPORT)) -#define IS_IP4_TUNNEL (flags) ((flags) & IP4_TUNNEL) - -#define IS_IP6_TUNNEL (flags) ((flags) & IP6_TUNNEL) -/* * Macro for getting ipsec_sa flags statuses without version of protocol * used for transport (IP4_TRANSPORT and IP6_TRANSPORT flags).
@@ -200,7 +203,7 @@ struct ipsec_mbuf_metadata {#define WITHOUT_TRANSPORT_VERSION (flags) \ ((flags) & (IP4_TUNNEL | \ IP6_TUNNEL | \ - TRANSPORT)) + (IP4_TRANSPORT | IP6_TRANSPORT)))struct cdev_qp {uint16_t id;
examples/ipsec-secgw/sa.c +179 -61
375 lines not on this page · raw message
examples/ipsec-secgw/sad.c +4 -6
@@ -25,8 +25,8 @@ ipsec_sad_add(struct ipsec_sad *sad, struct ipsec_sa *sa)/* spi field is common for ipv4 and ipv6 key types */ key.v4.spi =rte_cpu_to_be_32 (sa->spi); lookup_key[0 ] = &key; -switch (WITHOUT_TRANSPORT_VERSION (sa->flags)) { -case IP4_TUNNEL : + +if (IS_IP4 (sa->flags) &&IS_TUNNEL (sa->flags)) {rte_ipsec_sad_lookup (sad->sad_v4, lookup_key, &tmp,1 );if (tmp !=NULL )return -EEXIST ;
@@ -35,8 +35,7 @@ ipsec_sad_add(struct ipsec_sad *sad, struct ipsec_sa *sa) RTE_IPSEC_SAD_SPI_ONLY, sa);if (ret !=0 )return ret; -break ; -case IP6_TUNNEL : + }else if (IS_IP6 (sa->flags) &&IS_TUNNEL (sa->flags)) {rte_ipsec_sad_lookup (sad->sad_v6, lookup_key, &tmp,1 );if (tmp !=NULL )return -EEXIST ;
@@ -45,8 +44,7 @@ ipsec_sad_add(struct ipsec_sad *sad, struct ipsec_sa *sa) RTE_IPSEC_SAD_SPI_ONLY, sa);if (ret !=0 )return ret; -break ; -case TRANSPORT : + }else if (IS_TRANSPORT (sa->flags)) {if (sp4_spi_present (sa->spi,1 ,NULL ,NULL ) >=0 ) {rte_ipsec_sad_lookup (sad->sad_v4, lookup_key, &tmp,1 );if (tmp !=NULL )
examples/ipsec-secgw/sad.h +10 -10
@@ -29,16 +29,16 @@ static inline int cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4, struct rte_ipv6_hdr *ipv6) { - int sa_type = WITHOUT_TRANSPORT_VERSION(sa->flags); -if ((sa_type ==TRANSPORT ) || -/* IPv4 check */ - (is_v4 && (sa_type ==IP4_TUNNEL ) && - (sa->src.ip.ip4 == ipv4->src_addr) && - (sa->dst.ip.ip4 == ipv4->dst_addr)) || -/* IPv6 check */ - (!is_v4 && (sa_type ==IP6_TUNNEL ) && - (!memcmp (sa->src.ip.ip6.ip6, ipv6->src_addr,16 )) && - (!memcmp (sa->dst.ip.ip6.ip6, ipv6->dst_addr,16 )))) + + if (IS_TRANSPORT(sa->flags) || + /* IPv4 check */ + (is_v4 && IS_IP4(sa->flags) && + (sa->src.ip.ip4 == ipv4->src_addr) && + (sa->dst.ip.ip4 == ipv4->dst_addr)) || + /* IPv6 check */ + (!is_v4 && IS_IP6(sa->flags) && + (!memcmp(sa->src.ip.ip6.ip6, ipv6->src_addr, 16)) && + (!memcmp(sa->dst.ip.ip6.ip6, ipv6->dst_addr, 16)))) return 1; return 0;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 2/7] examples/ipsec-secgw: add support for NAT-T
Hi Radu,
Quoted 6 lines
Add support to the sample application to support IPsec NAT-T for both transport and tunnel modes, for both IPv4 and IPv6.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>---
Udp-encapsulation is already supported in the app with the option --udp-encap in sa configuration and it is enabled for INLINE PROTO and LOOKASIDE PROTO for IPv4/IPv6. I believe the same can be used for inline crypto case As well.
Did you try using it? Is there some specific reason for not using it? I believe We can enhance that option if something is missing in that.
Regards,
Akhil
PATCH 3/7 examples/ipsec-secgw: add support for TSO
In reply to Radu NicolauAdd support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
--- examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
examples/ipsec-secgw/ipsec.h +1 -0
@@ -143,6 +143,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +15 -0
@@ -695,6 +695,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
@@ -1366,6 +1376,11 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.options.ecn =1 ; prm->ipsec_xform.options.copy_dscp =1 ; +if (ss->mss >0 ) { + prm->ipsec_xform.options.tso =1 ; + prm->ipsec_xform.mss = ss->mss; + } +if (IS_TRANSPORT (ss->flags)) {/* transport mode */ prm->trs.proto = rc;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 3/7] examples/ipsec-secgw: add support for TSO
Quoted 2 lines
Add support to allow user to specific MSS for TSO offload on a per SA
Spell check 'specify'
Quoted 8 lines
basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 15 +++++++++++++++
No update for the new mss option in the documentation of the app
Please also update description to explain the new option.
Quoted 50 lines
2 files changed, 16 insertions(+)examples/ipsec-secgw/ipsec.h +1
-0@@ -143,6 +143,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;examples/ipsec-secgw/sa.c +15
-0@@ -695,6 +695,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;@@ -1366,6 +1376,11 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm,const struct ipsec_sa *ss, prm->ipsec_xform.options.ecn = 1; prm->ipsec_xform.options.copy_dscp =1 ; +if (ss->mss >0 ) { + prm->ipsec_xform.options.tso =1 ; + prm->ipsec_xform.mss = ss->mss; + } +if (IS_TRANSPORT (ss->flags)) {/* transport mode */
prm->trs.proto= rc;
--
2.25.1
PATCH 4/7 examples/ipsec-secgw: enable stats by default
In reply to Radu NicolauEnable stats screen by default
--- examples/ipsec-secgw/ipsec-secgw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ipsec-secgw/ipsec-secgw.h +1 -1
@@ -7,7 +7,7 @@#include <stdbool.h> #ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 +#define STATS_INTERVAL 10ULL#endif #define NB_SOCKETS 4
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH 4/7] examples/ipsec-secgw: enable stats by default
Quoted 34 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Radu Nicolau
Sent: Friday, September 3, 2021 12:23 PM
To: Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>
Subject: [dpdk-dev] [PATCH 4/7] examples/ipsec-secgw: enable stats by defaultEnable stats screen by default
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec-secgw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/ipsec- renamed from examples/ipsec-secgw/ipsec-secgw.h +0
-0
secgw/ipsec-secgw.h
index96e22de45e..ede610bcde100644examples/ipsec-secgw/ipsec-secgw.h +1
-2@@ -7,7 +7,7 @@#include <stdbool.h> #ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 +#define STATS_INTERVAL 10ULL#endif #define NB_SOCKETS 4 --
Quoted 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 4/7] examples/ipsec-secgw: enable stats by default
In reply to Radu NicolauQuoted 6 lines
Enable stats screen by default
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>---
I believe timeout should be configurable like we have in l3fwd/l2fwd. And without recompiling, there should be a way out to disable it. If we are not doing an effort to do that, then by default it should be Disabled in my opinion. Others can comment on it.
Re: [dpdk-dev] [EXT] [PATCH 4/7] examples/ipsec-secgw: enable stats by default
Quoted 9 lines · Akhil Goyal
Quoted 5 lines
Enable stats screen by default
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>---
I believe timeout should be configurable like we have in l3fwd/l2fwd. And without recompiling, there should be a way out to disable it. If we are not doing an effort to do that, then by default it should be Disabled in my opinion. Others can comment on it.
+1 we shall make it optional and disabled by default.
PATCH 5/7 examples/ipsec-secgw: add support for telemetry
In reply to Radu NicolauAdd telemetry support to the IPsec GW sample app
--- examples/ipsec-secgw/ipsec-secgw.c | 370 +++++++++++++++++++++++++++-- examples/ipsec-secgw/ipsec-secgw.h | 31 +++ examples/ipsec-secgw/ipsec.h | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 21 +- 5 files changed, 401 insertions(+), 25 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +352 -18
@@ -48,6 +48,7 @@#include <rte_ip.h> #include <rte_ip_frag.h> #include <rte_alarm.h> +#include <rte_telemetry.h> #include "event_helper.h" #include "flow.h"
@@ -668,7 +669,7 @@ send_single_packet(struct rte_mbuf *m, uint16_t port, uint8_t proto)static inline void inbound_sp_sa (struct sp_ctx *sp,struct sa_ctx *sa,struct traffic_type *ip, -uint16_t lim) +uint16_t lim,struct ipsec_spd_stats *stats) {struct rte_mbuf *m;uint32_t i, j, res, sa_idx;
@@ -685,25 +686,30 @@ inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip, res = ip->res[i];if (res ==BYPASS ) { ip->pkts[j++] = m; + stats->bypass++;continue ; }if (res ==DISCARD ) {free_pkts (&m,1 ); + stats->discard++;continue ; }/* Only check SPI match for processed IPSec packets */ if (i < lim && ((m->ol_flags &PKT_RX_SEC_OFFLOAD ) ==0 )) { + stats->discard++;free_pkts (&m,1 );continue ; } sa_idx = res -1 ;if (!inbound_sa_check (sa, m, sa_idx)) { + stats->discard++;free_pkts (&m,1 );continue ; } ip->pkts[j++] = m; + stats->protect++; } ip->num = j; }
@@ -747,6 +753,7 @@ static inline void process_pkts_inbound(struct ipsec_ctx *ipsec_ctx, struct ipsec_traffic *traffic) { + unsigned int lcoreid = rte_lcore_id();uint16_t nb_pkts_in, n_ip4, n_ip6; n_ip4 = traffic->ip4.num;
@@ -762,16 +769,20 @@ process_pkts_inbound(struct ipsec_ctx *ipsec_ctx,ipsec_process (ipsec_ctx, traffic); } -inbound_sp_sa (ipsec_ctx->sp4_ctx, ipsec_ctx->sa_ctx, &traffic->ip4, - n_ip4); +inbound_sp_sa (ipsec_ctx->sp4_ctx, + ipsec_ctx->sa_ctx, &traffic->ip4, n_ip4, + &core_statistics[lcoreid].inbound.spd4); -inbound_sp_sa (ipsec_ctx->sp6_ctx, ipsec_ctx->sa_ctx, &traffic->ip6, - n_ip6); +inbound_sp_sa (ipsec_ctx->sp6_ctx, + ipsec_ctx->sa_ctx, &traffic->ip6, n_ip6, + &core_statistics[lcoreid].inbound.spd6); }static inline void -outbound_sp (struct sp_ctx *sp,struct traffic_type *ip, -struct traffic_type *ipsec) +outbound_spd_lookup (struct sp_ctx *sp, +struct traffic_type *ip, +struct traffic_type *ipsec, +struct ipsec_spd_stats *stats) {struct rte_mbuf *m;uint32_t i, j, sa_idx;
@@ -779,20 +790,27 @@ outbound_sp(struct sp_ctx *sp, struct traffic_type *ip,if (ip->num ==0 || sp ==NULL )return ; -rte_acl_classify ((struct rte_acl_ctx *)sp, ip->data, ip->res, - ip->num,DEFAULT_MAX_CATEGORIES ); +rte_acl_classify ((struct rte_acl_ctx *)sp, + ip->data, ip->res, ip->num, +DEFAULT_MAX_CATEGORIES ); - j =0 ; -for (i =0 ; i < ip->num; i++) { +for (i =0 , j =0 ; i < ip->num; i++) { m = ip->pkts[i]; sa_idx = ip->res[i] -1 ; -if (ip->res[i] ==DISCARD ) + +if (unlikely (ip->res[i] ==DISCARD )) {free_pkts (&m,1 ); -else if (ip->res[i] ==BYPASS ) + + stats->discard++; + }else if (unlikely (ip->res[i] ==BYPASS )) { ip->pkts[j++] = m; -else { + + stats->bypass++; + }else { ipsec->res[ipsec->num] = sa_idx; ipsec->pkts[ipsec->num++] = m; + + stats->protect++; } } ip->num = j;
@@ -804,15 +822,20 @@ process_pkts_outbound(struct ipsec_ctx *ipsec_ctx, {struct rte_mbuf *m;uint16_t idx, nb_pkts_out, i; +unsigned int lcoreid =rte_lcore_id ();/* Drop any IPsec traffic from protected ports */ free_pkts (traffic->ipsec.pkts, traffic->ipsec.num); traffic->ipsec.num =0 ; -outbound_sp (ipsec_ctx->sp4_ctx, &traffic->ip4, &traffic->ipsec); +outbound_spd_lookup (ipsec_ctx->sp4_ctx, + &traffic->ip4, &traffic->ipsec, + &core_statistics[lcoreid].outbound.spd4); -outbound_sp (ipsec_ctx->sp6_ctx, &traffic->ip6, &traffic->ipsec); +outbound_spd_lookup (ipsec_ctx->sp6_ctx, + &traffic->ip6, &traffic->ipsec, + &core_statistics[lcoreid].outbound.spd4);if (app_sa_prm.enable ==0 ) {
@@ -966,6 +989,7 @@ route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint8_t nb_pkts)int32_t pkt_hop =0 ;uint16_t i, offset;uint16_t lpm_pkts =0 ; +unsigned int lcoreid =rte_lcore_id ();if (nb_pkts ==0 )return ;
@@ -1001,6 +1025,7 @@ route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint8_t nb_pkts) }if ((pkt_hop &RTE_LPM_LOOKUP_SUCCESS ) ==0 ) { + core_statistics[lcoreid].lpm4.miss++;free_pkts (&pkts[i],1 );continue ; }
@@ -1017,6 +1042,7 @@ route6_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint8_t nb_pkts)int32_t pkt_hop =0 ;uint16_t i, offset;uint16_t lpm_pkts =0 ; +unsigned int lcoreid =rte_lcore_id ();if (nb_pkts ==0 )return ;
@@ -1053,6 +1079,7 @@ route6_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint8_t nb_pkts) }if (pkt_hop ==-1 ) { + core_statistics[lcoreid].lpm6.miss++;free_pkts (&pkts[i],1 );continue ; }
@@ -1126,6 +1153,7 @@ drain_inbound_crypto_queues(const struct lcore_conf *qconf, {uint32_t n;struct ipsec_traffic trf; +unsigned int lcoreid =rte_lcore_id ();if (app_sa_prm.enable ==0 ) {
@@ -1143,13 +1171,15 @@ drain_inbound_crypto_queues(const struct lcore_conf *qconf,/* process ipv4 packets */ if (trf.ip4.num !=0 ) { -inbound_sp_sa (ctx->sp4_ctx, ctx->sa_ctx, &trf.ip4,0 ); +inbound_sp_sa (ctx->sp4_ctx, ctx->sa_ctx, &trf.ip4,0 , + &core_statistics[lcoreid].inbound.spd4);route4_pkts (qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num); }/* process ipv6 packets */ if (trf.ip6.num !=0 ) { -inbound_sp_sa (ctx->sp6_ctx, ctx->sa_ctx, &trf.ip6,0 ); +inbound_sp_sa (ctx->sp6_ctx, ctx->sa_ctx, &trf.ip6,0 , + &core_statistics[lcoreid].inbound.spd6);route6_pkts (qconf->rt6_ctx, trf.ip6.pkts, trf.ip6.num); } }
@@ -2826,6 +2856,308 @@ calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, 8192U); } + +static int +handle_telemetry_cmd_ipsec_secgw_stats(const char *cmd __rte_unused, +const char *params,struct rte_tel_data *data) +{ +uint64_t total_pkts_dropped =0 , total_pkts_tx =0 , total_pkts_rx =0 ; +unsigned int coreid; + +rte_tel_data_start_dict (data); + +if (params) { + coreid = (uint32_t )atoi (params); +if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + + total_pkts_dropped = core_statistics[coreid].dropped; + total_pkts_tx = core_statistics[coreid].tx; + total_pkts_rx = core_statistics[coreid].rx; + + }else { +for (coreid =0 ; coreid <RTE_MAX_LCORE ; coreid++) { + +/* skip disabled cores */ +if (rte_lcore_is_enabled (coreid) ==0 ) +continue ; + + total_pkts_dropped += core_statistics[coreid].dropped; + total_pkts_tx += core_statistics[coreid].tx; + total_pkts_rx += core_statistics[coreid].rx; + } + } + +/* add telemetry key/values pairs */ +rte_tel_data_add_dict_u64 (data,"packets received" , + total_pkts_rx); + +rte_tel_data_add_dict_u64 (data,"packets transmitted" , + total_pkts_tx); + +rte_tel_data_add_dict_u64 (data,"packets dopped" , + total_pkts_dropped); + + +return 0 ; +} + +static void +update_lcore_statistics (struct ipsec_core_statistics *total,uint32_t coreid) +{ +struct ipsec_core_statistics *lcore_stats; + +/* skip disabled cores */ +if (rte_lcore_is_enabled (coreid) ==0 ) +return ; + + lcore_stats = &core_statistics[coreid]; + + total->rx = lcore_stats->rx; + total->dropped = lcore_stats->dropped; + total->tx = lcore_stats->tx; + +/* outbound stats */ + total->outbound.spd6.protect += lcore_stats->outbound.spd6.protect; + total->outbound.spd6.bypass += lcore_stats->outbound.spd6.bypass; + total->outbound.spd6.discard += lcore_stats->outbound.spd6.discard; + + total->outbound.spd4.protect += lcore_stats->outbound.spd4.protect; + total->outbound.spd4.bypass += lcore_stats->outbound.spd4.bypass; + total->outbound.spd4.discard += lcore_stats->outbound.spd4.discard; + + total->outbound.sad.miss += lcore_stats->outbound.sad.miss; + +/* inbound stats */ + total->inbound.spd6.protect += lcore_stats->inbound.spd6.protect; + total->inbound.spd6.bypass += lcore_stats->inbound.spd6.bypass; + total->inbound.spd6.discard += lcore_stats->inbound.spd6.discard; + + total->inbound.spd4.protect += lcore_stats->inbound.spd4.protect; + total->inbound.spd4.bypass += lcore_stats->inbound.spd4.bypass; + total->inbound.spd4.discard += lcore_stats->inbound.spd4.discard; + + total->inbound.sad.miss += lcore_stats->inbound.sad.miss; + + +/* routing stats */ + total->lpm4.miss += lcore_stats->lpm4.miss; + total->lpm6.miss += lcore_stats->lpm6.miss; +} + +static void +update_statistics (struct ipsec_core_statistics *total,uint32_t coreid) +{ +memset (total,0 ,sizeof (*total)); + +if (coreid !=UINT32_MAX ) { +update_lcore_statistics (total, coreid); + }else { +for (coreid =0 ; coreid <RTE_MAX_LCORE ; coreid++) +update_lcore_statistics (total, coreid); + } +} + +static int +handle_telemetry_cmd_ipsec_secgw_stats_outbound(const char *cmd __rte_unused, +const char *params,struct rte_tel_data *data) +{ +struct ipsec_core_statistics total_stats; + +struct rte_tel_data *spd4_data =rte_tel_data_alloc (); +struct rte_tel_data *spd6_data =rte_tel_data_alloc (); +struct rte_tel_data *sad_data =rte_tel_data_alloc (); + +unsigned int coreid =UINT32_MAX ; + +/* verify allocated telemetry data structures */ +if (!spd4_data || !spd6_data || !sad_data) +return -ENOMEM ; + +/* initialize telemetry data structs as dicts */ +rte_tel_data_start_dict (data); + +rte_tel_data_start_dict (spd4_data); +rte_tel_data_start_dict (spd6_data); +rte_tel_data_start_dict (sad_data); + +if (params) { + coreid = (uint32_t )atoi (params); +if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + } + +update_statistics (&total_stats, coreid); + +/* add spd 4 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd4_data,"protect" , + total_stats.outbound.spd4.protect); +rte_tel_data_add_dict_u64 (spd4_data,"bypass" , + total_stats.outbound.spd4.bypass); +rte_tel_data_add_dict_u64 (spd4_data,"discard" , + total_stats.outbound.spd4.discard); + +rte_tel_data_add_dict_container (data,"spd4" , spd4_data,0 ); + +/* add spd 6 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd6_data,"protect" , + total_stats.outbound.spd6.protect); +rte_tel_data_add_dict_u64 (spd6_data,"bypass" , + total_stats.outbound.spd6.bypass); +rte_tel_data_add_dict_u64 (spd6_data,"discard" , + total_stats.outbound.spd6.discard); + +rte_tel_data_add_dict_container (data,"spd6" , spd6_data,0 ); + +/* add sad telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (sad_data,"miss" , + total_stats.outbound.sad.miss); + +rte_tel_data_add_dict_container (data,"sad" , sad_data,0 ); + +return 0 ; +} + +static int +handle_telemetry_cmd_ipsec_secgw_stats_inbound(const char *cmd __rte_unused, +const char *params,struct rte_tel_data *data) +{ +struct ipsec_core_statistics total_stats; + +struct rte_tel_data *spd4_data =rte_tel_data_alloc (); +struct rte_tel_data *spd6_data =rte_tel_data_alloc (); +struct rte_tel_data *sad_data =rte_tel_data_alloc (); + +unsigned int coreid =UINT32_MAX ; + +/* verify allocated telemetry data structures */ +if (!spd4_data || !spd6_data || !sad_data) +return -ENOMEM ; + +/* initialize telemetry data structs as dicts */ +rte_tel_data_start_dict (data); +rte_tel_data_start_dict (spd4_data); +rte_tel_data_start_dict (spd6_data); +rte_tel_data_start_dict (sad_data); + +/* add children dicts to parent dict */ + +if (params) { + coreid = (uint32_t )atoi (params); +if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + } + +update_statistics (&total_stats, coreid); + +/* add sad telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (sad_data,"miss" , + total_stats.outbound.sad.miss); + +rte_tel_data_add_dict_container (data,"sad" , sad_data,0 ); + +/* add spd 4 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd4_data,"protect" , + total_stats.inbound.spd4.protect); +rte_tel_data_add_dict_u64 (spd4_data,"bypass" , + total_stats.inbound.spd4.bypass); +rte_tel_data_add_dict_u64 (spd4_data,"discard" , + total_stats.inbound.spd4.discard); + +rte_tel_data_add_dict_container (data,"spd4" , spd4_data,0 ); + +/* add spd 6 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd6_data,"protect" , + total_stats.inbound.spd6.protect); +rte_tel_data_add_dict_u64 (spd6_data,"bypass" , + total_stats.inbound.spd6.bypass); +rte_tel_data_add_dict_u64 (spd6_data,"discard" , + total_stats.inbound.spd6.discard); + +rte_tel_data_add_dict_container (data,"spd6" , spd6_data,0 ); + +return 0 ; +} + +static int +handle_telemetry_cmd_ipsec_secgw_stats_routing(const char *cmd __rte_unused, +const char *params,struct rte_tel_data *data) +{ +struct ipsec_core_statistics total_stats; + +struct rte_tel_data *lpm4_data =rte_tel_data_alloc (); +struct rte_tel_data *lpm6_data =rte_tel_data_alloc (); + +unsigned int coreid =UINT32_MAX ; + +/* initialize telemetry data structs as dicts */ +rte_tel_data_start_dict (data); +rte_tel_data_start_dict (lpm4_data); +rte_tel_data_start_dict (lpm6_data); + + +if (params) { + coreid = (uint32_t )atoi (params); +if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + } + +update_statistics (&total_stats, coreid); + +/* add lpm 4 telemetry key/values pairs */ +rte_tel_data_add_dict_u64 (lpm4_data,"miss" , + total_stats.outbound.spd4.protect); + +rte_tel_data_add_dict_container (data,"IPv4 LPM" , lpm4_data,0 ); + +/* add lpm 6 telemetry key/values pairs */ +rte_tel_data_add_dict_u64 (lpm6_data,"miss" , + total_stats.outbound.spd6.protect); + +rte_tel_data_add_dict_container (data,"IPv6 LPM" , lpm6_data,0 ); + +return 0 ; +} + +static void +ipsec_secgw_telemetry_init (void ) +{ +rte_telemetry_register_cmd ("/examples/ipsec-secgw/stats" , + handle_telemetry_cmd_ipsec_secgw_stats, +"Returns outbound global stats. " +"Optional Parameters: int <logical core id>" ); + +rte_telemetry_register_cmd ("/examples/ipsec-secgw/stats/outbound" , + handle_telemetry_cmd_ipsec_secgw_stats_outbound, +"Returns outbound global stats. " +"Optional Parameters: int <logical core id>" ); + +rte_telemetry_register_cmd ("/examples/ipsec-secgw/stats/inbound" , + handle_telemetry_cmd_ipsec_secgw_stats_inbound, +"Returns outbound global stats. " +"Optional Parameters: int <logical core id>" ); + +rte_telemetry_register_cmd ("/examples/ipsec-secgw/stats/routing" , + handle_telemetry_cmd_ipsec_secgw_stats_routing, +"Returns outbound global stats. " +"Optional Parameters: int <logical core id>" ); +} + +static void +telemetry_init (void ) +{ +rte_ipsec_telemetry_init (); + +ipsec_secgw_telemetry_init (); + +} +int32_t main (int32_t argc,char **argv) {
@@ -2863,6 +3195,8 @@ main(int32_t argc, char **argv)if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid parameters\n" ); +telemetry_init (); +/* parse configuration file */ if (parse_cfg_file (cfgfile) <0 ) { printf("parsing file \"%s\" failed\n",
examples/ipsec-secgw/ipsec-secgw.h +31 -0
@@ -83,6 +83,17 @@ struct ethaddr_info {uint64_t src, dst; }; +struct ipsec_spd_stats { +uint64_t protect; +uint64_t bypass; +uint64_t discard; +}; + +struct ipsec_sa_stats { +uint64_t hit; +uint64_t miss; +}; + #if (STATS_INTERVAL > 0) struct ipsec_core_statistics { uint64_t tx;
@@ -91,6 +102,26 @@ struct ipsec_core_statistics {uint64_t tx_call;uint64_t dropped;uint64_t burst_rx; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } outbound; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } inbound; + +struct { +uint64_t miss; + } lpm4; + +struct { +uint64_t miss; + } lpm6; } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ];
examples/ipsec-secgw/ipsec.h +2 -0
@@ -125,6 +125,8 @@ struct ipsec_sa {#define NATT_UDP_TUNNEL (1 << 2)#define IP4_TRANSPORT (1 << 3)#define IP6_TRANSPORT (1 << 4) +#define SA_TELEMETRY_ENABLE (1 << 5) +struct ip_addr src;struct ip_addr dst;struct {
examples/ipsec-secgw/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev'] +deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev', 'telemetry'] allow_experimental_apis = true sources = files( 'esp.c',
examples/ipsec-secgw/sa.c +15 -6
@@ -323,6 +323,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,return ;if (atoi (tokens[1 ]) ==INVALID_SPI )return ; + rule->flags =0 ; rule->spi =atoi (tokens[1 ]); rule->portid =UINT16_MAX ; ips =ipsec_get_primary_session (rule);
@@ -339,26 +340,26 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (strcmp (tokens[ti],"ipv4-tunnel" ) ==0 ) { sa_cnt->nb_v4++; - rule->flags =IP4_TUNNEL ; + rule->flags |=IP4_TUNNEL ; }else if (strcmp (tokens[ti],"ipv4-udp-tunnel" ) ==0 ) { sa_cnt->nb_v4++; - rule->flags =IP4_TUNNEL |NATT_UDP_TUNNEL ; + rule->flags |=IP4_TUNNEL |NATT_UDP_TUNNEL ; rule->udp.sport =0 ; rule->udp.dport =4500 ; }else if (strcmp (tokens[ti],"ipv6-tunnel" ) ==0 ) { sa_cnt->nb_v6++; - rule->flags =IP6_TUNNEL ; + rule->flags |=IP6_TUNNEL ; }else if (strcmp (tokens[ti],"ipv6-udp-tunnel" ) ==0 ) { sa_cnt->nb_v6++; - rule->flags =IP6_TUNNEL |NATT_UDP_TUNNEL ; + rule->flags |=IP6_TUNNEL |NATT_UDP_TUNNEL ; }else if (strcmp (tokens[ti],"transport" ) ==0 ) { sa_cnt->nb_v4++; sa_cnt->nb_v6++; - rule->flags =IP4_TRANSPORT |IP6_TRANSPORT ; + rule->flags |=IP4_TRANSPORT |IP6_TRANSPORT ; }else if (strcmp (tokens[ti],"udp-transport" ) ==0 ) { sa_cnt->nb_v4++; sa_cnt->nb_v6++; - rule->flags =IP4_TRANSPORT |IP6_TRANSPORT | + rule->flags |=IP4_TRANSPORT |IP6_TRANSPORT |NATT_UDP_TUNNEL ; rule->udp.sport =0 ; rule->udp.dport =4500 ;
@@ -372,6 +373,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"telemetry" ) ==0 ) { + rule->flags |=SA_TELEMETRY_ENABLE ; +continue ; + } +if (strcmp (tokens[ti],"cipher_algo" ) ==0 ) {const struct supported_cipher_algo *algo;uint32_t key_len;
@@ -1519,6 +1525,9 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)if (rc <0 )return rc; +if (lsa->flags &SA_TELEMETRY_ENABLE ) +rte_ipsec_telemetry_sa_add (sa); +/* init primary processing session */ ips =ipsec_get_primary_session (lsa); rc =fill_ipsec_session (ips, sa);
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 5/7] examples/ipsec-secgw: add support for telemetry
Quoted 2 lines
Add telemetry support to the IPsec GW sample app
Add description about how user can use this feature.
Quoted 5 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>
examples/ipsec-secgw/ipsec-secgw.c outbound_sp(struct sp_ctx *sp, struct traffic_type · line 796
Quoted 9 lines
examples/ipsec-secgw/ipsec-secgw.c +3
-2@@ -779,20 +790,27 @@ outbound_sp(struct sp_ctx *sp, struct traffic_type *ip, if (ip->num == 0 || sp == NULL) return; -rte_acl_classify ((struct rte_acl_ctx *)sp, ip->data, ip->res, - ip->num,DEFAULT_MAX_CATEGORIES ); +rte_acl_classify ((struct rte_acl_ctx *)sp, + ip->data, ip->res, ip->num, +DEFAULT_MAX_CATEGORIES );
Unnecessary change.
Quoted 11 lines
examples/ipsec-secgw/ipsec-secgw.c +1
-0@@ -804,15 +822,20 @@ process_pkts_outbound(struct ipsec_ctx *ipsec_ctx, {struct rte_mbuf *m;uint16_t idx, nb_pkts_out, i; +unsigned int lcoreid =rte_lcore_id ();/* Drop any IPsec traffic from protected ports */ free_pkts (traffic->ipsec.pkts, traffic->ipsec.num); traffic->ipsec.num =0 ;
examples/ipsec-secgw/ipsec-secgw.c process_pkts_outbound(struct ipsec_ctx · line 839
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.c +6
-2-outbound_sp (ipsec_ctx->sp4_ctx, &traffic->ip4, &traffic->ipsec); +outbound_spd_lookup (ipsec_ctx->sp4_ctx, + &traffic->ip4, &traffic->ipsec, + &core_statistics[lcoreid].outbound.spd4); -outbound_sp (ipsec_ctx->sp6_ctx, &traffic->ip6, &traffic->ipsec); +outbound_spd_lookup (ipsec_ctx->sp6_ctx, + &traffic->ip6, &traffic->ipsec, + &core_statistics[lcoreid].outbound.spd4);
It should be core_statistics[lcoreid].outbound.spd6
examples/ipsec-secgw/ipsec-secgw.c calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, · line 2901
Quoted 4 lines
examples/ipsec-secgw/ipsec-secgw.c +4
-0+rte_tel_data_add_dict_u64 (data,"packets dopped" , + total_pkts_dropped); + +
Extra line
examples/ipsec-secgw/sa.c parse_sa_tokens(char **tokens, uint32_t n_tokens, · line 379
Quoted 8 lines
examples/ipsec-secgw/sa.c +7
-0+return 0 ; +} + +if (strcmp (tokens[ti],"telemetry" ) ==0 ) { + rule->flags |=SA_TELEMETRY_ENABLE ; +continue ; + }
Documentation update missing for this new option
Please do not add new features without documentation.
PATCH 6/7 examples/ipsec-secgw: add support for defining initial sequence number value
In reply to Radu NicolauAdd esn field to SA definition block to allow initial ESN value
--- examples/ipsec-secgw/ipsec.c | 5 +++++ examples/ipsec-secgw/ipsec.h | 2 ++ examples/ipsec-secgw/sa.c | 15 +++++++++++++++ 3 files changed, 22 insertions(+)
examples/ipsec-secgw/ipsec.c +5 -0
@@ -234,6 +234,11 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sess_conf.ipsec.udp.dport =htons (sa->udp.dport); } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } +struct rte_flow_action_security action_security;struct rte_flow_error err;
examples/ipsec-secgw/ipsec.h +2 -0
@@ -146,6 +146,8 @@ struct ipsec_sa {uint8_t udp_encap;uint16_t portid;uint16_t mss; +uint16_t esn; +uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +15 -0
@@ -711,6 +711,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
@@ -1387,6 +1397,11 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.mss = ss->mss; } +if (ss->esn >0 ) { + prm->ipsec_xform.options.esn =1 ; + prm->ipsec_xform.esn.value = ss->esn; + } +if (IS_TRANSPORT (ss->flags)) {/* transport mode */ prm->trs.proto = rc;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 6/7] examples/ipsec-secgw: add support for defining initial sequence number value
Quoted 2 lines
Add esn field to SA definition block to allow initial ESN value
Add description about the new option added and how to use it.
Quoted 6 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec.c | 5 +++++ examples/ipsec-secgw/ipsec.h | 2 ++ examples/ipsec-secgw/sa.c | 15 +++++++++++++++
Documentation missing again.
Quoted 68 lines
3 files changed, 22 insertions(+)examples/ipsec-secgw/ipsec.c +5
-0@@ -234,6 +234,11 @@ create_inline_session(struct socket_ctx *skt_ctx,struct ipsec_sa *sa, sess_conf.ipsec.udp.dport = htons(sa->udp.dport); } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } +struct rte_flow_action_security action_security;struct rte_flow_error err;examples/ipsec-secgw/ipsec.h +2
-0@@ -146,6 +146,8 @@ struct ipsec_sa {uint8_t udp_encap;uint16_t portid;uint16_t mss; +uint16_t esn; +uint8_t fdir_qid;uint8_t fdir_flag;examples/ipsec-secgw/sa.c +15
-0@@ -711,6 +711,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;@@ -1387,6 +1397,11 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm,const struct ipsec_sa *ss, prm->ipsec_xform.mss = ss->mss; } +if (ss->esn >0 ) { + prm->ipsec_xform.options.esn =1 ; + prm->ipsec_xform.esn.value = ss->esn; + } +if (IS_TRANSPORT (ss->flags)) {/* transport mode */
prm->trs.proto= rc;
--
2.25.1
PATCH 7/7 examples/ipsec-secgw: add ethdev reset callback
In reply to Radu NicolauAdd event handler for ethdev reset callback
--- examples/ipsec-secgw/ipsec-secgw.c | 18 +++- examples/ipsec-secgw/ipsec.h | 4 +- examples/ipsec-secgw/sa.c | 130 +++++++++++++++++++++++++++-- 3 files changed, 139 insertions(+), 13 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +16 -2
@@ -2254,7 +2254,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) local_port_conf.rxmode.offloads)rte_exit (EXIT_FAILURE ,"Error: port %u required RX offloads: 0x%" PRIx64 -", avaialbe RX offloads: 0x%" PRIx64"\n" , +", available RX offloads: 0x%" PRIx64"\n" , portid, local_port_conf.rxmode.offloads, dev_info.rx_offload_capa);
@@ -2262,7 +2262,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) local_port_conf.txmode.offloads)rte_exit (EXIT_FAILURE ,"Error: port %u required TX offloads: 0x%" PRIx64 -", avaialbe TX offloads: 0x%" PRIx64"\n" , +", available TX offloads: 0x%" PRIx64"\n" , portid, local_port_conf.txmode.offloads, dev_info.tx_offload_capa);
@@ -2543,6 +2543,17 @@ inline_ipsec_event_callback(uint16_t port_id, enum rte_eth_event_type type,return -1 ; } +static int +ethdev_reset_event_callback (uint16_t port_id, + enum rte_eth_event_type type __rte_unused, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d\n" , port_id); +printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue, struct rte_mbuf *pkt[], uint16_t nb_pkts,
@@ -3317,6 +3328,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_IPSEC , inline_ipsec_event_callback,NULL ); }
examples/ipsec-secgw/ipsec.h +2 -2
@@ -65,7 +65,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 +#define MAX_KEY_SIZE 132/* * application wide SA parameters
@@ -146,7 +146,7 @@ struct ipsec_sa {uint8_t udp_encap;uint16_t portid;uint16_t mss; -uint16_t esn; +uint32_t esn;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +121 -9
200 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH 7/7] examples/ipsec-secgw: add ethdev reset callback
Quoted 1 line
Add event handler for ethdev reset callback
I believe the below patch need to be split in 4-5 patches. It has a lot of irrelevant stuff.
Quoted 25 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec-secgw.c | 18 +++- examples/ipsec-secgw/ipsec.h | 4 +- examples/ipsec-secgw/sa.c | 130 +++++++++++++++++++++++++++-- 3 files changed, 139 insertions(+), 13 deletions(-)examples/ipsec- renamed from examples/ipsec-secgw/ipsec-secgw.c +0
-0
secgw/ipsec-secgw.c
indexe725d84e7c..9ba9568978100644examples/ipsec-secgw/ipsec-secgw.c +1
-1@@ -2254,7 +2254,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) local_port_conf.rxmode.offloads)rte_exit (EXIT_FAILURE ,"Error: port %u required RX offloads: 0x%" PRIx64 -", avaialbe RX offloads: 0x%" PRIx64"\n" , +", available RX offloads: 0x%" PRIx64"\n" , portid, local_port_conf.rxmode.offloads, dev_info.rx_offload_capa);
examples/ipsec-secgw/ipsec-secgw.c port_init(uint16_t portid, uint64_t · line 2268
Quoted 8 lines
examples/ipsec-secgw/ipsec-secgw.c +1
-1@@ -2262,7 +2262,7 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads) local_port_conf.txmode.offloads)rte_exit (EXIT_FAILURE ,"Error: port %u required TX offloads: 0x%" PRIx64 -", avaialbe TX offloads: 0x%" PRIx64"\n" , +", available TX offloads: 0x%" PRIx64"\n" , portid, local_port_conf.txmode.offloads, dev_info.tx_offload_capa);
Submit a separate patch for above so that it can be back ported.
Quoted 37 lines
examples/ipsec-secgw/ipsec-secgw.c +11
-0@@ -2543,6 +2543,17 @@ inline_ipsec_event_callback(uint16_t port_id,enum rte_eth_event_type type, return -1; } +static int +ethdev_reset_event_callback (uint16_t port_id, + enum rte_eth_event_type type __rte_unused, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d\n" , port_id); +printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue,examples/ipsec-secgw/ipsec-secgw.c +3
-0struct rte_mbuf *pkt[], uint16_t nb_pkts,@@ -3317,6 +3328,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); + rte_eth_dev_callback_register(portid, RTE_ETH_EVENT_IPSEC, inline_ipsec_event_callback,NULL);
examples/ipsec-secgw/ipsec-secgw.c +0
-0}examples/ipsec-secgw/ipsec.h +0
-0
examples/ipsec-secgw/ipsec.h struct ip_addr { · line 68
Quoted 5 lines
examples/ipsec-secgw/ipsec.h +1
-1@@ -65,7 +65,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 +#define MAX_KEY_SIZE 132
Reason?? This change do not match with the patch description.
Quoted 32 lines
examples/ipsec-secgw/ipsec.h +1
-1/* * application wide SA parameters @@ -146,7 +146,7 @@ struct ipsec_sa {uint8_t udp_encap;uint16_t portid;uint16_t mss; -uint16_t esn; +uint32_t esn;uint8_t fdir_qid;uint8_t fdir_flag;examples/ipsec-secgw/sa.c +5
-0@@ -46,6 +46,7 @@ struct supported_cipher_algo {struct supported_auth_algo {const char *keyword;enum rte_crypto_auth_algorithm algo; +uint16_t iv_len;uint16_t digest_len;uint16_t key_len;uint8_t key_not_req;@@ -98,6 +99,20 @@ const struct supported_cipher_algo cipher_algos[] = { .block_size = 4, .key_len =20 }, + { + .keyword = "aes-192-ctr", + .algo = RTE_CRYPTO_CIPHER_AES_CTR, + .iv_len = 16,
examples/ipsec-secgw/sa.c const struct supported_cipher_algo cipher_algos[] = { · line 115
Quoted 10 lines
examples/ipsec-secgw/sa.c +10
-0+ .block_size = 16, + .key_len =28 + }, + { + .keyword = "aes-256-ctr", + .algo = RTE_CRYPTO_CIPHER_AES_CTR, + .iv_len = 16, + .block_size = 16, + .key_len =36 + },
I think the above change need a separate patch to add support for new algos.
Quoted 65 lines
examples/ipsec-secgw/sa.c +51
-0{ .keyword = "3des-cbc", .algo = RTE_CRYPTO_CIPHER_3DES_CBC,@@ -126,6 +141,31 @@ const struct supported_auth_algo auth_algos[] = { .algo = RTE_CRYPTO_AUTH_SHA256_HMAC, .digest_len = 16, .key_len =32 + }, + { + .keyword = "sha384-hmac", + .algo = RTE_CRYPTO_AUTH_SHA384_HMAC, + .digest_len = 24, + .key_len =48 + }, + { + .keyword = "sha512-hmac", + .algo = RTE_CRYPTO_AUTH_SHA512_HMAC, + .digest_len = 32, + .key_len =64 + }, + { + .keyword = "aes-gmac", + .algo = RTE_CRYPTO_AUTH_AES_GMAC, + .iv_len = 8, + .digest_len = 16, + .key_len =20 + }, + { + .keyword = "aes-xcbc-mac-96", + .algo = RTE_CRYPTO_AUTH_AES_XCBC_MAC, + .digest_len = 12, + .key_len = 16 } };@@ -156,6 +196,42 @@ const struct supported_aead_algo aead_algos[] = { .key_len = 36, .digest_len = 16, .aad_len = 8, + }, + { + .keyword = "aes-128-ccm", + .algo = RTE_CRYPTO_AEAD_AES_CCM, + .iv_len = 8, + .block_size = 4, + .key_len = 20, + .digest_len = 16, + .aad_len = 8, + }, + { + .keyword = "aes-192-ccm", + .algo = RTE_CRYPTO_AEAD_AES_CCM, + .iv_len = 8, + .block_size = 4, + .key_len = 28, + .digest_len = 16, + .aad_len = 8, + }, + { + .keyword = "aes-256-ccm", + .algo = RTE_CRYPTO_AEAD_AES_CCM, + .iv_len = 8, + .block_size = 4, + .key_len = 36, + .digest_len = 16,
examples/ipsec-secgw/sa.c const struct supported_aead_algo aead_algos[] = { · line 234
Quoted 10 lines
examples/ipsec-secgw/sa.c +10
-0+ .aad_len = 8, + }, + { + .keyword = "chacha20-poly1305", + .algo = RTE_CRYPTO_AEAD_CHACHA20_POLY1305, + .iv_len = 12, + .block_size = 64, + .key_len = 36, + .digest_len = 16, + .aad_len = 8,
Above changes are also not relevant to this patch.
And MAX_KEY_SIZE is updated as 132, but max size that I see here is 64.
examples/ipsec-secgw/sa.c parse_sa_tokens(char **tokens, uint32_t n_tokens, · line 433
Quoted 10 lines
examples/ipsec-secgw/sa.c +2
-0} };@@ -352,6 +428,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, }else if (strcmp (tokens[ti],"ipv6-udp-tunnel" ) ==0 ) { sa_cnt->nb_v6++; rule->flags |=IP6_TUNNEL |NATT_UDP_TUNNEL ; + rule->udp.sport =0 ; + rule->udp.dport =4500 ;
Again irrelevant change as per the description.
Quoted 6 lines
examples/ipsec-secgw/sa.c +0
-0}else if (strcmp (tokens[ti],"transport" ) ==0 ) { sa_cnt->nb_v4++;examples/ipsec-secgw/sa.c +0
-0sa_cnt->nb_v6++;@@ -499,6 +577,15 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (status->status <0 )return ;
examples/ipsec-secgw/sa.c parse_sa_tokens(char **tokens, uint32_t n_tokens, · line 588
Quoted 10 lines
examples/ipsec-secgw/sa.c +9
-0+if (algo->algo ==RTE_CRYPTO_AUTH_AES_GMAC ) { + key_len -=4 ; + rule->auth_key_len = key_len; + rule->iv_len = algo->iv_len; +memcpy (&rule->salt, + &rule->auth_key[key_len],4 ); + } + +
Extra line and irrelevant change.
Quoted 105 lines
examples/ipsec-secgw/sa.c +4
-3auth_algo_p =1 ;continue ; }@@ -1209,10 +1296,15 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], sa->aead_algo == RTE_CRYPTO_AEAD_AES_CCM || sa->aead_algo == RTE_CRYPTO_AEAD_CHACHA20_POLY1305) { - if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) + if (ips->type == + RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) { iv_length =8 ; - else - iv_length =12 ; + } else { + if (sa->aead_algo ==
RTE_CRYPTO_AEAD_AES_CCM)examples/ipsec-secgw/sa.c +4
-0+ iv_length =11 ; + else + iv_length =12 ; + } sa_ctx->xf[idx].a.type =
RTE_CRYPTO_SYM_XFORM_AEAD;examples/ipsec-secgw/sa.c +1
-3sa_ctx->xf[idx].a.aead.algo = sa->aead_algo;@@ -1236,10 +1328,8 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[], case RTE_CRYPTO_CIPHER_NULL:case RTE_CRYPTO_CIPHER_3DES_CBC :case RTE_CRYPTO_CIPHER_AES_CBC : - iv_length = sa->iv_len; -break ;case RTE_CRYPTO_CIPHER_AES_CTR : - iv_length =16 ; + iv_length = sa->iv_len;break ;default :examples/ipsec-secgw/sa.c +9
-0RTE_LOG(ERR, IPSEC_ESP,@@ -1248,6 +1338,15 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], return -EINVAL; } +if (sa->auth_algo ==RTE_CRYPTO_AUTH_AES_GMAC ) { +if (ips->type == +RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) { + iv_length =8 ; + }else { + iv_length =12 ; + } + } +examples/ipsec-secgw/sa.c +0
-0if (inbound) { sa_ctx->xf[idx].b.type =
RTE_CRYPTO_SYM_XFORM_CIPHER;
sa_ctx->xf[idx].b.cipher.algo = sa-Quoted 1 line
cipher_algo;examples/ipsec-secgw/sa.c +3
-0@@ -1269,6 +1368,9 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], sa->digest_len; sa_ctx->xf[idx].a.auth.op =RTE_CRYPTO_AUTH_OP_VERIFY ; + sa_ctx->xf[idx].a.auth.iv.offset =IV_OFFSET ; + sa_ctx->xf[idx].a.auth.iv.length = iv_length; + }else {/* outbound */ sa_ctx->xf[idx].a.type =
RTE_CRYPTO_SYM_XFORM_CIPHER;
sa_ctx->xf[idx].a.cipher.algo = sa-Quoted 1 line
cipher_algo;examples/ipsec-secgw/sa.c +13
-3@@ -1290,11 +1392,21 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], sa->digest_len; sa_ctx->xf[idx].b.auth.op =RTE_CRYPTO_AUTH_OP_GENERATE ; + sa_ctx->xf[idx].b.auth.iv.offset =IV_OFFSET ; + sa_ctx->xf[idx].b.auth.iv.length = iv_length; + } - sa_ctx->xf[idx].a.next = &sa_ctx->xf[idx].b; - sa_ctx->xf[idx].b.next =NULL ; - sa->xforms = &sa_ctx->xf[idx].a; +if (sa->auth_algo ==RTE_CRYPTO_AUTH_AES_GMAC ) { + sa->xforms = inbound ? + &sa_ctx->xf[idx].a : &sa_ctx- >xf[idx].b; + sa->xforms->next =NULL ; + + }else { + sa_ctx->xf[idx].a.next = &sa_ctx->xf[idx].b; + sa_ctx->xf[idx].b.next =NULL ; + sa->xforms = &sa_ctx->xf[idx].a; + }examples/ipsec-secgw/sa.c +0
-1} if (ips->type == --2.25.1
v2 cover IPsec Sec GW new features
In reply to Radu NicolauUpdate the IPsec sample app with new features and updates:
- egress TSO support
- telemetry support
- add reset callback
- stats screen configurable as a command line parameter
- UDP encapsulation support for inline crypto
- ESN with configurable start value
Depends on series 18837 ('new features for ipsec and security libraries')
Radu Nicolau (9):
examples/ipsec-secgw: update create inline session examples/ipsec-secgw: update SA parameters with L3 options examples/ipsec-secgw: add support for telemetry examples/ipsec-secgw: add stats interval argument examples/ipsec-secgw: add support for TSO examples/ipsec-secgw: add support for defining initial sequence number
value
examples/ipsec-secgw: add ethdev reset callback examples/ipsec-secgw: add support for additional algorithms examples/ipsec-secgw: add support for inline crypto UDP encapsulation
doc/guides/sample_app_ug/ipsec_secgw.rst | 36 ++ examples/ipsec-secgw/ipsec-secgw.c | 408 +++++++++++++++++++++-- examples/ipsec-secgw/ipsec-secgw.h | 48 ++- examples/ipsec-secgw/ipsec.c | 95 +++++- examples/ipsec-secgw/ipsec.h | 14 +- examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 305 +++++++++++++++-- 7 files changed, 816 insertions(+), 92 deletions(-)
Signature · 3 lines
v2: reworked the patchset to improve quality and address feedback 2.25.1
PATCH v2 1/9 examples/ipsec-secgw: update create inline session
Rework create inline session function as to update the session configuration parameters before create session is called. Also updated the rss key array size to prevent buffers overflows with PMDs that copy more than 40 bytes.
--- examples/ipsec-secgw/ipsec.c | 56 ++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec.c +48 -8
@@ -167,21 +167,61 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, .action_type = ips->type, .protocol =RTE_SECURITY_PROTOCOL_IPSEC , {.ipsec = { - .spi = sa->spi, + .spi =rte_cpu_to_be_32 (sa->spi), .salt = sa->salt, .options = { 0 }, .replay_win_sz = 0, .direction = sa->direction, - .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, - .mode = (sa->flags == IP4_TUNNEL || - sa->flags ==IP6_TUNNEL ) ? -RTE_SECURITY_IPSEC_SA_MODE_TUNNEL : - RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP } }, .crypto_xform = sa->xforms, .userdata = NULL, }; +if (IS_TRANSPORT (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT ; +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + } + }else if (IS_TUNNEL (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + }else { +RTE_LOG (ERR ,IPSEC ,"invalid tunnel type\n" ); +return -1 ; + } + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -267,10 +307,10 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->attr.ingress = (sa->direction ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS );if (sa->attr.ingress) { -uint8_t rss_key[40 ]; +uint8_t rss_key[64 ];struct rte_eth_rss_conf rss_conf = { .rss_key = rss_key, - .rss_key_len =40 , + .rss_key_len =sizeof (rss_key), };struct rte_eth_dev_info dev_info;uint16_t queue[RTE_MAX_QUEUES_PER_PORT ];
Signature · 1 line
2.25.1
PATCH v2 2/9 examples/ipsec-secgw: update SA parameters with L3 options
In reply to Radu NicolauSet the L3 offset and L3 length in the SA parameters
--- examples/ipsec-secgw/sa.c | 4 ++++ 1 file changed, 4 insertions(+)
examples/ipsec-secgw/sa.c +4 -0
@@ -1316,11 +1316,15 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss,if (IS_IP4_TUNNEL (ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + prm->tun.hdr_l3_len =sizeof (*v4); + prm->tun.hdr_l3_off =0 ; prm->tun.hdr_len =sizeof (*v4); prm->tun.next_proto = rc; prm->tun.hdr = v4; }else if (IS_IP6_TUNNEL (ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + prm->tun.hdr_l3_len =sizeof (*v6); + prm->tun.hdr_l3_off =0 ; prm->tun.hdr_len =sizeof (*v6); prm->tun.next_proto = rc; prm->tun.hdr = v6;
Signature · 1 line
2.25.1
PATCH v2 3/9 examples/ipsec-secgw: add support for telemetry
In reply to Radu NicolauAdd telemetry support to the IPsec GW sample app
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 11 + examples/ipsec-secgw/ipsec-secgw.c | 365 ++++++++++++++++++++++- examples/ipsec-secgw/ipsec-secgw.h | 33 +- examples/ipsec-secgw/ipsec.h | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 15 +- 6 files changed, 406 insertions(+), 22 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +11 -0
@@ -720,6 +720,17 @@ where each options means: * *udp-encap* + ``<telemetry>`` + + * Option to enable per SA telemetry. + Currently only supported with IPsec library path. + + * Optional: Yes, it is disabled by default + + * Syntax: + + * *telemetry* + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +349 -16
496 lines not on this page · raw message
examples/ipsec-secgw/ipsec-secgw.h +31 -2
@@ -83,7 +83,17 @@ struct ethaddr_info {uint64_t src, dst; }; -#if (STATS_INTERVAL > 0) +struct ipsec_spd_stats { +uint64_t protect; +uint64_t bypass; +uint64_t discard; +}; + +struct ipsec_sa_stats { +uint64_t hit; +uint64_t miss; +}; +struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -91,10 +101,29 @@ struct ipsec_core_statistics {uint64_t tx_call;uint64_t dropped;uint64_t burst_rx; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } outbound; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } inbound; + +struct { +uint64_t miss; + } lpm4; + +struct { +uint64_t miss; + } lpm6; } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */ extern struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS ];
examples/ipsec-secgw/ipsec.h +2 -0
@@ -125,6 +125,8 @@ struct ipsec_sa {#define TRANSPORT (1 << 2)#define IP4_TRANSPORT (1 << 3)#define IP6_TRANSPORT (1 << 4) +#define SA_TELEMETRY_ENABLE (1 << 5) +struct ip_addr src;struct ip_addr dst;uint8_t cipher_key[MAX_KEY_SIZE ];
examples/ipsec-secgw/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev'] +deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev', 'telemetry'] allow_experimental_apis = true sources = files( 'esp.c',
examples/ipsec-secgw/sa.c +12 -3
@@ -322,6 +322,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,return ;if (atoi (tokens[1 ]) ==INVALID_SPI )return ; + rule->flags =0 ; rule->spi =atoi (tokens[1 ]); rule->portid =UINT16_MAX ; ips =ipsec_get_primary_session (rule);
@@ -338,14 +339,14 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (strcmp (tokens[ti],"ipv4-tunnel" ) ==0 ) { sa_cnt->nb_v4++; - rule->flags =IP4_TUNNEL ; + rule->flags |=IP4_TUNNEL ; }else if (strcmp (tokens[ti],"ipv6-tunnel" ) ==0 ) { sa_cnt->nb_v6++; - rule->flags =IP6_TUNNEL ; + rule->flags |=IP6_TUNNEL ; }else if (strcmp (tokens[ti],"transport" ) ==0 ) { sa_cnt->nb_v4++; sa_cnt->nb_v6++; - rule->flags =TRANSPORT ; + rule->flags |=TRANSPORT ; }else {APP_CHECK (0 , status,"unrecognized " "input \"%s\"" , tokens[ti]);
@@ -356,6 +357,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"telemetry" ) ==0 ) { + rule->flags |=SA_TELEMETRY_ENABLE ; +continue ; + } +if (strcmp (tokens[ti],"cipher_algo" ) ==0 ) {const struct supported_cipher_algo *algo;uint32_t key_len;
@@ -1390,6 +1396,9 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)if (rc <0 )return rc; +if (lsa->flags &SA_TELEMETRY_ENABLE ) +rte_ipsec_telemetry_sa_add (sa); +/* init primary processing session */ ips =ipsec_get_primary_session (lsa); rc =fill_ipsec_session (ips, sa);
Signature · 1 line
2.25.1
PATCH v2 4/9 examples/ipsec-secgw: add stats interval argument
In reply to Radu NicolauAdd -t for stats screen update interval, disabled by default.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 15 ------------ 3 files changed, 25 insertions(+), 24 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
@@ -127,6 +127,7 @@ The application has a number of command line options:: -p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -w REPLAY_WINDOW_SIZE -e -a -c SAD_CACHE_SIZE + -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]
@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval. If set to zero or + omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs will be calculated based on number of cores, eth ports and crypto queues.
examples/ipsec-secgw/ipsec-secgw.c +20 -9
@@ -181,6 +181,7 @@ static uint32_t frag_tbl_sz;static uint32_t frame_buf_size =RTE_MBUF_DEFAULT_BUF_SIZE ;static uint32_t mtu_size =RTE_ETHER_MTU ;static uint64_t frag_ttl_ns =MAX_FRAG_TTL_NS ; +static uint32_t stats_interval;/* application wide librte_ipsec/SA parameters */ struct app_sa_prm app_sa_prm = {
@@ -292,7 +293,6 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph, } } -#if (STATS_INTERVAL >0 )/* Print out statistics on packet distribution */ static void
@@ -352,9 +352,8 @@ print_stats_cb(__rte_unused void *param) total_packets_dropped);printf ("\n====================================================\n" ); - rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb, NULL); +rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet (struct rte_mbuf *pkt,struct ipsec_traffic *t)
@@ -1435,6 +1434,7 @@ print_usage(const char *prgname)" [-e]" " [-a]" " [-c]" +" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]"
@@ -1459,6 +1459,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specified number\n" " of mbufs will be calculated based on number of cores,\n" " ports and crypto queues\n"
@@ -1666,7 +1668,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {switch (opt) {
@@ -1747,6 +1749,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);if (ret) {
@@ -3350,11 +3361,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb,NULL ); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch (ipsec_launch_one_lcore, eh_conf,CALL_MAIN );
examples/ipsec-secgw/ipsec-secgw.h +0 -15
@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4
@@ -144,38 +141,26 @@ is_unprotected_port(uint16_t port_id)static inline void core_stats_update_rx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argument
Quoted 165 lines · Radu Nicolau
Add -t for stats screen update interval, disabled by default.
Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 15 ------------ 3 files changed, 25 insertions(+), 24 deletions(-)doc/guides/sample_app_ug/ipsec_secgw.rst +5
-0@@ -127,6 +127,7 @@ The application has a number of command line options:: -p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -w REPLAY_WINDOW_SIZE -e -a -c SAD_CACHE_SIZE + -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval. If set to zero or + omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs will be calculated based on number of cores, eth ports and crypto queues.examples/ipsec-secgw/ipsec-secgw.c +20
-9@@ -181,6 +181,7 @@ static uint32_t frag_tbl_sz;static uint32_t frame_buf_size =RTE_MBUF_DEFAULT_BUF_SIZE ;static uint32_t mtu_size =RTE_ETHER_MTU ;static uint64_t frag_ttl_ns =MAX_FRAG_TTL_NS ; +static uint32_t stats_interval;/* application wide librte_ipsec/SA parameters */ struct app_sa_prm app_sa_prm = {@@ -292,7 +293,6 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph, } } -#if (STATS_INTERVAL >0 )/* Print out statistics on packet distribution */ static void@@ -352,9 +352,8 @@ print_stats_cb(__rte_unused void *param) total_packets_dropped);printf ("\n====================================================\n" ); - rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb, NULL); +rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet (struct rte_mbuf *pkt,struct ipsec_traffic *t)@@ -1435,6 +1434,7 @@ print_usage(const char *prgname)" [-e]" " [-a]" " [-c]" +" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]" @@ -1459,6 +1459,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specified number\n" " of mbufs will be calculated based on number of cores,\n" " ports and crypto queues\n" @@ -1666,7 +1668,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {switch (opt) {@@ -1747,6 +1749,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);if (ret) {@@ -3350,11 +3361,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb,NULL ); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch (ipsec_launch_one_lcore, eh_conf,CALL_MAIN );examples/ipsec-secgw/ipsec-secgw.h +0
-11@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4@@ -144,38 +141,26 @@ is_unprotected_port(uint16_t port_id)static inline void core_stats_update_rx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n)
examples/ipsec-secgw/ipsec-secgw.h is_unprotected_port(uint16_t port_id) · line 166
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.h +0
-4{ -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */
Re: [dpdk-dev] [EXT] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argument
In reply to Radu NicolauHi Radu,
Making stats dynamic would have a perf cost. That was the reason it was introduced as a compile time option. Why do we need it changed?
Also, it looks like this patch is only disabling stats printing when timeout is 0. I don't see stats collection being conditional. Stats collection would also have perf impact, right?
Thanks,
Anoob
Quoted 195 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Radu Nicolau
Sent: Wednesday, September 15, 2021 7:15 PM
To: Radu Nicolau <[email protected]>; Akhil Goyal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: [EXT] [dpdk-dev] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argumentExternal Email
----------------------------------------------------------------------
Add -t for stats screen update interval, disabled by default.Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 15 ------------ 3 files changed, 25 insertions(+), 24 deletions(-)doc/guides/sample_app_ug/ipsec_secgw.rst +0
-0@@ -127,6 +127,7 @@ The application has a number of command lineoptions::
-p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -wREPLAY_WINDOW_SIZE-e -a -cSAD_CACHE_SIZEdoc/guides/sample_app_ug/ipsec_secgw.rst +5
-0+ -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval. If set to zero or + omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number ofmbufs
will be calculated based on number of cores, eth ports and crypto queues.examples/ipsec- renamed from examples/ipsec-secgw/ipsec-secgw.c +0
-0
secgw/ipsec-secgw.c
index265fff4bef..60b25be872100644examples/ipsec-secgw/ipsec-secgw.c +0
-0@@ -181,6 +181,7 @@ static uint32_t frag_tbl_sz; static uint32_t
frame_buf_size=RTE_MBUF_DEFAULT_BUF_SIZE; staticuint32_tmtu_size=RTE_ETHER_MTU; staticuint64_tfrag_ttl_ns=MAX_FRAG_TTL_NS; +staticuint32_tstats_interval;/* application wide librte_ipsec/SA parameters */ struct
app_sa_prmapp_sa_prm= { @@ -292,7 +293,6 @@ adjust_ipv6_pktlen(structrte_mbuf*m, const structrte_ipv6_hdr*iph,examples/ipsec-secgw/ipsec-secgw.c +0
-1} } -#if (STATS_INTERVAL >0 ) /* Print out statistics on packet distribution */ static void @@ -352,9 +352,8@@
print_stats_cb(__rte_unused void *param)
total_packets_dropped);printf("\n====================================================\n");
examples/ipsec-secgw/ipsec-secgw.c +0
-1- rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb,NULL);
examples/ipsec-secgw/ipsec-secgw.c +1
-1+rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) @@ -1435,6 +1434,7 @@
print_usage(const char *prgname)examples/ipsec-secgw/ipsec-secgw.c +3
-0" [-e]" " [-a]" " [-c]" +" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]" @@ -1459,6 +1459,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specifiednumber\n"
examples/ipsec-secgw/ipsec-secgw.c +1
-1" of mbufs will be calculated based on number of cores,\n" " ports and crypto queues\n" @@ -1666,7 +1668,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {examples/ipsec-secgw/ipsec-secgw.c +9
-0switch (opt) {@@ -1747,6 +1749,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);examples/ipsec-secgw/ipsec-secgw.c +5
-5if (ret) {@@ -3350,11 +3361,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb, NULL); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch(ipsec_launch_one_lcore,
eh_conf,CALL_MAIN); diff --gita/examples/ipsec-secgw/ipsec-secgw.hb/examples/ipsec-secgw/ipsec-secgw.h
indexf3082a1037..de9f382742100644examples/ipsec-secgw/ipsec-secgw.h +0
-13@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4@@ -144,38 +141,26 @@ is_unprotected_port(uint16_t port_id) static inline void core_stats_update_rx(int n) { -#if (STATS_INTERVAL > 0)int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */ --2.25.1
Re: [dpdk-dev] [EXT] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argument
Hi Anoob,
Quoted 3 lines · Anoob Joseph
Hi Radu,
Making stats dynamic would have a perf cost. That was the reason it was introduced as a compile time option. Why do we need it changed?
We changed it for two reasons, for a better UX and for the telemetry feature that is introduced with patch 3.
Quoted 2 lines
Also, it looks like this patch is only disabling stats printing when timeout is 0. I don't see stats collection being conditional. Stats collection would also have perf impact, right?
I don't think there is a measurable performance impact because these are per burst calls.
Regards,
Radu
Quoted 199 lines
Thanks,
AnoobQuoted 195 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Radu Nicolau
Sent: Wednesday, September 15, 2021 7:15 PM
To: Radu Nicolau <[email protected]>; Akhil Goyal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: [EXT] [dpdk-dev] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argumentExternal Email
----------------------------------------------------------------------
Add -t for stats screen update interval, disabled by default.Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 15 ------------ 3 files changed, 25 insertions(+), 24 deletions(-)doc/guides/sample_app_ug/ipsec_secgw.rst +0
-0@@ -127,6 +127,7 @@ The application has a number of command lineoptions::
-p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -wREPLAY_WINDOW_SIZE-e -a -cSAD_CACHE_SIZEdoc/guides/sample_app_ug/ipsec_secgw.rst +5
-0+ -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval. If set to zero or + omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number ofmbufs
will be calculated based on number of cores, eth ports and crypto queues.examples/ipsec- renamed from examples/ipsec-secgw/ipsec-secgw.c +0
-0
secgw/ipsec-secgw.c
index265fff4bef..60b25be872100644examples/ipsec-secgw/ipsec-secgw.c +0
-0@@ -181,6 +181,7 @@ static uint32_t frag_tbl_sz; static uint32_t
frame_buf_size=RTE_MBUF_DEFAULT_BUF_SIZE; staticuint32_tmtu_size=RTE_ETHER_MTU; staticuint64_tfrag_ttl_ns=MAX_FRAG_TTL_NS; +staticuint32_tstats_interval;/* application wide librte_ipsec/SA parameters */ struct
app_sa_prmapp_sa_prm= { @@ -292,7 +293,6 @@ adjust_ipv6_pktlen(structrte_mbuf*m, const structrte_ipv6_hdr*iph,
}
}-#if (
STATS_INTERVAL> 0)/* Print out statistics on packet distribution */ static void @@ -352,9 +352,8
@@print_stats_cb(__rte_unused void *param)
total_packets_dropped);printf("\n====================================================\n");
examples/ipsec-secgw/ipsec-secgw.c +0
-1- rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb,NULL);
examples/ipsec-secgw/ipsec-secgw.c +1
-1+rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) @@ -1435,6 +1434,7 @@
print_usage(const char *prgname)
" [-e]"
" [-a]"
" [-c]"examples/ipsec-secgw/ipsec-secgw.c +3
-0+" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]" @@ -1459,6 +1459,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specifiednumber\n"
" of mbufs will be calculated based on number of cores,\n"
" ports and crypto queues\n"examples/ipsec-secgw/ipsec-secgw.c +1
-1@@ -1666,7 +1668,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {switch (opt) {examples/ipsec-secgw/ipsec-secgw.c +9
-0@@ -1747,6 +1749,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);if (ret) {examples/ipsec-secgw/ipsec-secgw.c +5
-5@@ -3350,11 +3361,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb, NULL); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch(ipsec_launch_one_lcore,
eh_conf,CALL_MAIN); diff --gita/examples/ipsec-secgw/ipsec-secgw.hb/examples/ipsec-secgw/ipsec-secgw.h
indexf3082a1037..de9f382742100644examples/ipsec-secgw/ipsec-secgw.h +0
-13@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4@@ -144,38 +141,26 @@ is_unprotected_port(uint16_t port_id) static inline void core_stats_update_rx(int n) { -#if (STATS_INTERVAL > 0)int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */ --2.25.1
Anoob Joseph
Acked-byRe: [dpdk-dev] [EXT] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argument
Hi Radu,
Please see inline.
Thanks,
Anoob
Quoted 13 lines
Subject: Re: [EXT] [dpdk-dev] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argument
Hi Anoob,
Quoted 3 lines · Anoob Joseph
Hi Radu,
Making stats dynamic would have a perf cost. That was the reason it was
introduced as a compile time option. Why do we need it changed? We changed it for two reasons, for a better UX and for the telemetry feature that is introduced with patch 3.
Quoted 1 line
Quoted 5 lines
Quoted 1 line
Also, it looks like this patch is only disabling stats printing when timeout is 0.
I don't see stats collection being conditional. Stats collection would also have perf impact, right?
I don't think there is a measurable performance impact because these are per burst calls.
[Anoob] Agreed. If it was done intentionally, then I don’t see any problem.
[snip]
PATCH v2 5/9 examples/ipsec-secgw: add support for TSO
In reply to Radu NicolauAdd support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+)
doc/guides/sample_app_ug/ipsec_secgw.rst +10 -0
@@ -736,6 +736,16 @@ where each options means: * *telemetry* + ``<mss>`` + + * Maximum segment size for TSO offload, available for egress SAs only. + + * Optional: Yes, TSO offload not set by default + + * Syntax: + + * *mss N* N is the segment size + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec.h +1 -0
@@ -141,6 +141,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +15 -0
@@ -683,6 +683,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
@@ -1320,6 +1330,11 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.options.ecn =1 ; prm->ipsec_xform.options.copy_dscp =1 ; +if (ss->mss >0 ) { + prm->ipsec_xform.options.tso =1 ; + prm->ipsec_xform.mss = ss->mss; + } +if (IS_IP4_TUNNEL (ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; prm->tun.hdr_l3_len =sizeof (*v4);
Signature · 1 line
2.25.1
PATCH v2 6/9 examples/ipsec-secgw: add support for defining initial sequence number value
In reply to Radu NicolauAdd esn field to SA definition block to allow initial ESN value
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec.c | 5 +++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 15 +++++++++++++++ 4 files changed, 31 insertions(+)
doc/guides/sample_app_ug/ipsec_secgw.rst +10 -0
@@ -746,6 +746,16 @@ where each options means: * *mss N* N is the segment size + ``<esn>`` + + * Enable ESN and set the initial ESN value. + + * Optional: Yes, ESN not enabled by default + + * Syntax: + + * *esn N* N is the initial ESN value + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec.c +5 -0
@@ -222,6 +222,11 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, } } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
examples/ipsec-secgw/ipsec.h +1 -0
@@ -142,6 +142,7 @@ struct ipsec_sa {uint8_t udp_encap;uint16_t portid;uint16_t mss; +uint64_t esn;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +15 -0
@@ -693,6 +693,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
@@ -1335,6 +1345,11 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.mss = ss->mss; } +if (ss->esn >0 ) { + prm->ipsec_xform.options.esn =1 ; + prm->ipsec_xform.esn.value = ss->esn; + } +if (IS_IP4_TUNNEL (ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; prm->tun.hdr_l3_len =sizeof (*v4);
Signature · 1 line
2.25.1
PATCH v2 7/9 examples/ipsec-secgw: add ethdev reset callback
In reply to Radu NicolauAdd event handler for ethdev reset callback
--- examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
examples/ipsec-secgw/ipsec-secgw.c +14 -0
@@ -2559,6 +2559,17 @@ inline_ipsec_event_callback(uint16_t port_id, enum rte_eth_event_type type,return -1 ; } +static int +ethdev_reset_event_callback (uint16_t port_id, + enum rte_eth_event_type type __rte_unused, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d\n" , port_id); +printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue, struct rte_mbuf *pkt[], uint16_t nb_pkts,
@@ -3333,6 +3344,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_IPSEC , inline_ipsec_event_callback,NULL ); }
Signature · 1 line
2.25.1
PATCH v2 8/9 examples/ipsec-secgw: add support for additional algorithms
In reply to Radu NicolauAdd support for AES-GMAC, AES_CTR, AES_XCBC_MAC,AES_CCM, CHACHA20_POLY1305
--- examples/ipsec-secgw/ipsec.h | 3 +- examples/ipsec-secgw/sa.c | 133 ++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 10 deletions(-)
examples/ipsec-secgw/ipsec.h +1 -2
@@ -65,8 +65,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 - +#define MAX_KEY_SIZE 96/* * application wide SA parameters */
examples/ipsec-secgw/sa.c +125 -8
196 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 9/9 examples/ipsec-secgw: add support for inline crypto UDP encapsulation
In reply to Radu NicolauEnable UDP encapsulation for both transport and tunnel modes for the inline crypto offload path.
--- examples/ipsec-secgw/ipsec.c | 34 ++++++++-- examples/ipsec-secgw/ipsec.h | 7 +- examples/ipsec-secgw/sa.c | 123 ++++++++++++++++++++++++++++------- 3 files changed, 136 insertions(+), 28 deletions(-)
examples/ipsec-secgw/ipsec.c +30 -4
@@ -222,6 +222,13 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, } } +if (sa->udp_encap) { + sess_conf.ipsec.options.udp_encap =1 ; + + sess_conf.ipsec.udp.sport =htons (sa->udp.sport); + sess_conf.ipsec.udp.dport =htons (sa->udp.dport); + } +if (sa->esn >0 ) { sess_conf.ipsec.options.esn =1 ; sess_conf.ipsec.esn.value = sa->esn;
@@ -295,12 +302,31 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->ipv4_spec.hdr.src_addr = sa->src.ip.ip4; } - sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; - sa->pattern[2 ].spec = &sa->esp_spec; - sa->pattern[2 ].mask = &rte_flow_item_esp_mask; sa->esp_spec.hdr.spi =rte_cpu_to_be_32 (sa->spi); - sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; +if (sa->udp_encap) { + + sa->udp_spec.hdr.dst_port = +rte_cpu_to_be_16 (sa->udp.dport); + sa->udp_spec.hdr.src_port = +rte_cpu_to_be_16 (sa->udp.sport); + + sa->pattern[2 ].mask = &rte_flow_item_udp_mask; + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_UDP ; + sa->pattern[2 ].spec = &sa->udp_spec; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[3 ].spec = &sa->esp_spec; + sa->pattern[3 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[4 ].type =RTE_FLOW_ITEM_TYPE_END ; + }else { + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[2 ].spec = &sa->esp_spec; + sa->pattern[2 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; + } sa->action[0 ].type =RTE_FLOW_ACTION_TYPE_SECURITY ; sa->action[0 ].conf = ips->security.ses;
examples/ipsec-secgw/ipsec.h +6 -1
@@ -128,6 +128,10 @@ struct ipsec_sa {struct ip_addr src;struct ip_addr dst; +struct { +uint16_t sport; +uint16_t dport; + } udp;uint8_t cipher_key[MAX_KEY_SIZE ];uint16_t cipher_key_len;uint8_t auth_key[MAX_KEY_SIZE ];
@@ -145,7 +149,7 @@ struct ipsec_sa {uint8_t fdir_qid;uint8_t fdir_flag; -#define MAX_RTE_FLOW_PATTERN (4) +#define MAX_RTE_FLOW_PATTERN (5)#define MAX_RTE_FLOW_ACTIONS (3)struct rte_flow_item pattern[MAX_RTE_FLOW_PATTERN ];struct rte_flow_action action[MAX_RTE_FLOW_ACTIONS ];
@@ -154,6 +158,7 @@ struct ipsec_sa {struct rte_flow_item_ipv4 ipv4_spec;struct rte_flow_item_ipv6 ipv6_spec; }; +struct rte_flow_item_udp udp_spec;struct rte_flow_item_esp esp_spec;struct rte_flow *flow;struct rte_security_session_conf sess_conf;
examples/ipsec-secgw/sa.c +100 -23
181 lines not on this page · raw message
Signature · 1 line
2.25.1
v3 cover IPsec Sec GW new features
In reply to Radu NicolauUpdate the IPsec sample app with new features and updates:
- egress TSO support
- telemetry support
- add reset callback
- stats screen configurable as a command line parameter
- UDP encapsulation support for inline crypto
- ESN with configurable start value
Depends on series 18837 ('new features for ipsec and security libraries')
Radu Nicolau (8):
examples/ipsec-secgw: add stats interval argument examples/ipsec-secgw: update create inline session examples/ipsec-secgw: add support for inline crypto UDP encapsulation examples/ipsec-secgw: add support for TSO examples/ipsec-secgw: add support for telemetry examples/ipsec-secgw: add support for defining initial sequence number
value
examples/ipsec-secgw: add ethdev reset callback examples/ipsec-secgw: add support for additional algorithms
doc/guides/sample_app_ug/ipsec_secgw.rst | 36 ++ examples/ipsec-secgw/ipsec-secgw.c | 404 +++++++++++++++++++++-- examples/ipsec-secgw/ipsec-secgw.h | 48 ++- examples/ipsec-secgw/ipsec.c | 93 +++++- examples/ipsec-secgw/ipsec.h | 14 +- examples/ipsec-secgw/ipsec_process.c | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 179 +++++++++- 8 files changed, 710 insertions(+), 68 deletions(-)
Signature · 4 lines
v2: reworked the patchset to improve quality and address feedback v3: reworked the patchset to accomodate changes in the ipsec libray 2.25.1
PATCH v3 1/8 examples/ipsec-secgw: add stats interval argument
Add -t for stats screen update interval, disabled by default.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 17 -------------- 3 files changed, 25 insertions(+), 26 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
@@ -127,6 +127,7 @@ The application has a number of command line options:: -p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -w REPLAY_WINDOW_SIZE -e -a -c SAD_CACHE_SIZE + -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]
@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval. If set to zero or + omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs will be calculated based on number of cores, eth ports and crypto queues.
examples/ipsec-secgw/ipsec-secgw.c +20 -9
@@ -180,6 +180,7 @@ static uint32_t frag_tbl_sz;static uint32_t frame_buf_size =RTE_MBUF_DEFAULT_BUF_SIZE ;static uint32_t mtu_size =RTE_ETHER_MTU ;static uint64_t frag_ttl_ns =MAX_FRAG_TTL_NS ; +static uint32_t stats_interval;/* application wide librte_ipsec/SA parameters */ struct app_sa_prm app_sa_prm = {
@@ -291,7 +292,6 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph, } } -#if (STATS_INTERVAL >0 )/* Print out statistics on packet distribution */ static void
@@ -351,9 +351,8 @@ print_stats_cb(__rte_unused void *param) total_packets_dropped);printf ("\n====================================================\n" ); - rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb, NULL); +rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet (struct rte_mbuf *pkt,struct ipsec_traffic *t)
@@ -1406,6 +1405,7 @@ print_usage(const char *prgname)" [-e]" " [-a]" " [-c]" +" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]"
@@ -1430,6 +1430,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specified number\n" " of mbufs will be calculated based on number of cores,\n" " ports and crypto queues\n"
@@ -1637,7 +1639,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {switch (opt) {
@@ -1718,6 +1720,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);if (ret) {
@@ -3017,11 +3028,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb,NULL ); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch (ipsec_launch_one_lcore, eh_conf,CALL_MAIN );
examples/ipsec-secgw/ipsec-secgw.h +0 -17
@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4
@@ -83,7 +80,6 @@ struct ethaddr_info {uint64_t src, dst; }; -#if (STATS_INTERVAL > 0)struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -94,7 +90,6 @@ struct ipsec_core_statistics { } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */ extern struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS ];
@@ -115,38 +110,26 @@ is_unprotected_port(uint16_t port_id)static inline void core_stats_update_rx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 1/8] examples/ipsec-secgw: add stats interval argument
Quoted 15 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +0
-0@@ -127,6 +127,7 @@ The application has a number of command lineoptions::
-p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -wREPLAY_WINDOW_SIZE-e -a -cSAD_CACHE_SIZEdoc/guides/sample_app_ug/ipsec_secgw.rst +1
-0+ -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]
doc/guides/sample_app_ug/ipsec_secgw.rst Where: · line 182
Quoted 6 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +3
-0@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval. If set to zero or + omitted statistics screen is disabled. + Default value: 0.
Please also mention the unit of interval.
PATCH v3 2/8 examples/ipsec-secgw: update create inline session
In reply to Radu NicolauRework create inline session function as to update the session configuration parameters before create session is called. Also updated the rss key array size to prevent buffers overflows with PMDs that copy more than 40 bytes.
--- examples/ipsec-secgw/ipsec.c | 54 +++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-)
examples/ipsec-secgw/ipsec.c +47 -7
@@ -172,16 +172,56 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, .options = { 0 }, .replay_win_sz = 0, .direction = sa->direction, - .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, - .mode = (sa->flags ==IP4_TUNNEL || - sa->flags ==IP6_TUNNEL ) ? -RTE_SECURITY_IPSEC_SA_MODE_TUNNEL : - RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP } }, .crypto_xform = sa->xforms, .userdata = NULL, }; +if (IS_TRANSPORT (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT ; +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + } + }else if (IS_TUNNEL (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + }else { +RTE_LOG (ERR ,IPSEC ,"invalid tunnel type\n" ); +return -1 ; + } + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -267,10 +307,10 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->attr.ingress = (sa->direction ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS );if (sa->attr.ingress) { -uint8_t rss_key[40 ]; +uint8_t rss_key[64 ];struct rte_eth_rss_conf rss_conf = { .rss_key = rss_key, - .rss_key_len =40 , + .rss_key_len =sizeof (rss_key), };struct rte_eth_dev_info dev_info;uint16_t queue[RTE_MAX_QUEUES_PER_PORT ];
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 2/8] examples/ipsec-secgw: update create inline session
Quoted 7 lines
Rework create inline session function as to update the session configuration parameters before create session is called. Also updated the rss key array size to prevent buffers overflows with PMDs that copy more than 40 bytes.
Signed-off-by Radu Nicolau <[email protected]>---
PATCH v3 3/8 examples/ipsec-secgw: add support for inline crypto UDP encapsulation
In reply to Radu NicolauEnable UDP encapsulation for both transport and tunnel modes for the inline crypto offload path.
--- examples/ipsec-secgw/ipsec.c | 33 +++++++++++++++++++++++++++++---- examples/ipsec-secgw/ipsec.h | 7 ++++++- examples/ipsec-secgw/sa.c | 9 +++++++++ 3 files changed, 44 insertions(+), 5 deletions(-)
examples/ipsec-secgw/ipsec.c +29 -4
@@ -222,6 +222,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, } } +if (sa->udp_encap) { + sess_conf.ipsec.options.udp_encap =1 ; + sess_conf.ipsec.udp.sport =htons (sa->udp.sport); + sess_conf.ipsec.udp.dport =htons (sa->udp.dport); + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -290,12 +296,31 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->ipv4_spec.hdr.src_addr = sa->src.ip.ip4; } - sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; - sa->pattern[2 ].spec = &sa->esp_spec; - sa->pattern[2 ].mask = &rte_flow_item_esp_mask; sa->esp_spec.hdr.spi =rte_cpu_to_be_32 (sa->spi); - sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; +if (sa->udp_encap) { + + sa->udp_spec.hdr.dst_port = +rte_cpu_to_be_16 (sa->udp.dport); + sa->udp_spec.hdr.src_port = +rte_cpu_to_be_16 (sa->udp.sport); + + sa->pattern[2 ].mask = &rte_flow_item_udp_mask; + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_UDP ; + sa->pattern[2 ].spec = &sa->udp_spec; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[3 ].spec = &sa->esp_spec; + sa->pattern[3 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[4 ].type =RTE_FLOW_ITEM_TYPE_END ; + }else { + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[2 ].spec = &sa->esp_spec; + sa->pattern[2 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; + } sa->action[0 ].type =RTE_FLOW_ACTION_TYPE_SECURITY ; sa->action[0 ].conf = ips->security.ses;
examples/ipsec-secgw/ipsec.h +6 -1
@@ -127,6 +127,10 @@ struct ipsec_sa {#define IP6_TRANSPORT (1 << 4)struct ip_addr src;struct ip_addr dst; +struct { +uint16_t sport; +uint16_t dport; + } udp;uint8_t cipher_key[MAX_KEY_SIZE ];uint16_t cipher_key_len;uint8_t auth_key[MAX_KEY_SIZE ];
@@ -142,7 +146,7 @@ struct ipsec_sa {uint8_t fdir_qid;uint8_t fdir_flag; -#define MAX_RTE_FLOW_PATTERN (4) +#define MAX_RTE_FLOW_PATTERN (5)#define MAX_RTE_FLOW_ACTIONS (3)struct rte_flow_item pattern[MAX_RTE_FLOW_PATTERN ];struct rte_flow_action action[MAX_RTE_FLOW_ACTIONS ];
@@ -151,6 +155,7 @@ struct ipsec_sa {struct rte_flow_item_ipv4 ipv4_spec;struct rte_flow_item_ipv6 ipv6_spec; }; +struct rte_flow_item_udp udp_spec;struct rte_flow_item_esp esp_spec;struct rte_flow *flow;struct rte_security_session_conf sess_conf;
examples/ipsec-secgw/sa.c +9 -0
@@ -17,6 +17,7 @@#include <rte_byteorder.h> #include <rte_errno.h> #include <rte_ip.h> +#include <rte_udp.h> #include <rte_random.h> #include <rte_ethdev.h> #include <rte_malloc.h>
@@ -771,6 +772,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, app_sa_prm.udp_encap =1 ; udp_encap_p =1 ;break ; +case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO : + rule->udp_encap =1 ; + rule->udp.sport =0 ; + rule->udp.dport =4500 ; +break ;default :APP_CHECK (0 , status, "UDP encapsulation not supported for "
@@ -858,6 +864,8 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound) }printf ("mode:" ); +if (sa->udp_encap) +printf ("UDP encapsulated " );switch (WITHOUT_TRANSPORT_VERSION (sa->flags)) {case IP4_TUNNEL :
@@ -1311,6 +1319,7 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.mode = (IS_TRANSPORT (ss->flags)) ?RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT :RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + prm->ipsec_xform.options.udp_encap = ss->udp_encap; prm->ipsec_xform.options.ecn =1 ; prm->ipsec_xform.options.copy_dscp =1 ;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 3/8] examples/ipsec-secgw: add support for inline crypto UDP encapsulation
Quoted 11 lines
Enable UDP encapsulation for both transport and tunnel modes for the inline crypto offload path.
Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec.c | 33 +++++++++++++++++++++++++++++---- examples/ipsec-secgw/ipsec.h | 7 ++++++- examples/ipsec-secgw/sa.c | 9 +++++++++ 3 files changed, 44 insertions(+), 5 deletions(-)
Please update "doc/guides/sample_app_ug/ipsec_secgw.rst".
It has a limitation added that it is supported only on lookaside proto mode.
PATCH v3 4/8 examples/ipsec-secgw: add support for TSO
In reply to Radu NicolauAdd support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec-secgw.c | 4 ++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/ipsec_process.c | 2 ++ examples/ipsec-secgw/sa.c | 12 ++++++++++++ 5 files changed, 29 insertions(+)
doc/guides/sample_app_ug/ipsec_secgw.rst +10 -0
@@ -725,6 +725,16 @@ where each options means: * *udp-encap* + ``<mss>`` + + * Maximum segment size for TSO offload, available for egress SAs only. + + * Optional: Yes, TSO offload not set by default + + * Syntax: + + * *mss N* N is the segment size + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +4 -0
@@ -399,6 +399,10 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) pkt->l2_len =0 ; pkt->l3_len =sizeof (*iph4); pkt->packet_type |=RTE_PTYPE_L3_IPV4 ; +if (pkt->packet_type &RTE_PTYPE_L4_TCP ) + pkt->l4_len =sizeof (struct rte_tcp_hdr ); +else + pkt->l4_len =sizeof (struct rte_udp_hdr ); }else if (eth->ether_type ==rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV6 )) {int next_proto;size_t l3len, ext_len;
examples/ipsec-secgw/ipsec.h +1 -0
@@ -143,6 +143,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/ipsec_process.c +2 -0
@@ -222,6 +222,8 @@ prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt)for (j =0 ; j != cnt; j++) { priv =get_priv (mb[j]); priv->sa = sa; +if (priv->sa->mss) + mb[j]->tso_segsz = priv->sa->mss; } }
examples/ipsec-secgw/sa.c +12 -0
@@ -678,6 +678,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
@@ -1326,11 +1336,13 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss,if (IS_IP4_TUNNEL (ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; prm->tun.hdr_len =sizeof (*v4); + prm->tun.hdr_l3_off =0 ; prm->tun.next_proto = rc; prm->tun.hdr = v4; }else if (IS_IP6_TUNNEL (ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; prm->tun.hdr_len =sizeof (*v6); + prm->tun.hdr_l3_off =0 ; prm->tun.next_proto = rc; prm->tun.hdr = v6; }else {
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 4/8] examples/ipsec-secgw: add support for TSO
Quoted 6 lines
Add support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>
Quoted 7 lines
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec-secgw.c | 4 ++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/ipsec_process.c | 2 ++ examples/ipsec-secgw/sa.c | 12 ++++++++++++ 5 files changed, 29 insertions(+)
I think it is worth mentioning in release notes for this feature.
Quoted 9 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +0
-0@@ -725,6 +725,16 @@ where each options means: * *udp-encap*
doc/guides/sample_app_ug/ipsec_secgw.rst where each options means: · line 736
Quoted 10 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +9
-0+ ``<mss>`` + + * Maximum segment size for TSO offload, available for egress SAs only. + + * Optional: Yes, TSO offload not set by default + + * Syntax: + + * *mss N* N is the segment size
Specify units as well.
N is the segment size in bytes
Quoted 10 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +1
-0+ Example SA rules: .. code-block:: consoleexamples/ipsec- renamed from examples/ipsec-secgw/ipsec-secgw.c +0
-0
secgw/ipsec-secgw.c
index1d30f39450..3da520ec6e100644
examples/ipsec-secgw/ipsec-secgw.c prepare_one_packet(struct rte_mbuf *pkt, struct · line 406
Quoted 8 lines
examples/ipsec-secgw/ipsec-secgw.c +4
-0@@ -399,6 +399,10 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) pkt->l2_len = 0; pkt->l3_len =sizeof (*iph4); pkt->packet_type |=RTE_PTYPE_L3_IPV4 ; +if (pkt->packet_type &RTE_PTYPE_L4_TCP ) + pkt->l4_len =sizeof (struct rte_tcp_hdr ); +else + pkt->l4_len =sizeof (struct rte_udp_hdr );
If the packet is neither TCP nor UDP then?
Quoted 66 lines
examples/ipsec-secgw/ipsec-secgw.c +0
-0}else if (eth->ether_type ==rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV6 )) {examples/ipsec-secgw/ipsec-secgw.c +0
-0int next_proto;size_t l3len, ext_len;examples/ipsec-secgw/ipsec.h +1
-0@@ -143,6 +143,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;examples/ipsec- renamed from examples/ipsec-secgw/ipsec_process.c +0
-0
secgw/ipsec_process.c
index5012e1a6a4..fc2a3cbcd1100644examples/ipsec-secgw/ipsec_process.c +2
-0@@ -222,6 +222,8 @@ prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt)for (j =0 ; j != cnt; j++) { priv =get_priv (mb[j]); priv->sa = sa; +if (priv->sa->mss) + mb[j]->tso_segsz = priv->sa->mss; } }examples/ipsec-secgw/sa.c +12
-0@@ -678,6 +678,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;@@ -1326,11 +1336,13 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, if (IS_IP4_TUNNEL(ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; prm->tun.hdr_len =sizeof (*v4); + prm->tun.hdr_l3_off =0 ; prm->tun.next_proto = rc; prm->tun.hdr = v4; } else if (IS_IP6_TUNNEL(ss->flags)) { prm->ipsec_xform.tunnel.type =RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; prm->tun.hdr_len =sizeof (*v6); + prm->tun.hdr_l3_off =0 ;
examples/ipsec-secgw/sa.c fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, · line 1348
Quoted 3 lines
examples/ipsec-secgw/sa.c +0
-0prm->tun.next_proto = rc; prm->tun.hdr = v6; }else {
Also update print_usage() function with the new options added. Check in other patches also.
PATCH v3 5/8 examples/ipsec-secgw: add support for telemetry
In reply to Radu NicolauAdd telemetry support to the IPsec GW sample app
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 11 + examples/ipsec-secgw/ipsec-secgw.c | 357 ++++++++++++++++++++++- examples/ipsec-secgw/ipsec-secgw.h | 31 ++ examples/ipsec-secgw/ipsec.h | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 15 +- 6 files changed, 398 insertions(+), 20 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +11 -0
@@ -735,6 +735,17 @@ where each options means: * *mss N* N is the segment size +``<telemetry>`` + + * Option to enable per SA telemetry. + Currently only supported with IPsec library path. + + * Optional: Yes, it is disabled by default + + * Syntax: + + * *telemetry* + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +341 -16
488 lines not on this page · raw message
examples/ipsec-secgw/ipsec-secgw.h +31 -0
@@ -80,6 +80,17 @@ struct ethaddr_info {uint64_t src, dst; }; +struct ipsec_spd_stats { +uint64_t protect; +uint64_t bypass; +uint64_t discard; +}; + +struct ipsec_sa_stats { +uint64_t hit; +uint64_t miss; +}; +struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -87,6 +98,26 @@ struct ipsec_core_statistics {uint64_t tx_call;uint64_t dropped;uint64_t burst_rx; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } outbound; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } inbound; + +struct { +uint64_t miss; + } lpm4; + +struct { +uint64_t miss; + } lpm6; } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ];
examples/ipsec-secgw/ipsec.h +2 -0
@@ -125,6 +125,8 @@ struct ipsec_sa {#define TRANSPORT (1 << 2)#define IP4_TRANSPORT (1 << 3)#define IP6_TRANSPORT (1 << 4) +#define SA_TELEMETRY_ENABLE (1 << 5) +struct ip_addr src;struct ip_addr dst;struct {
examples/ipsec-secgw/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev'] +deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev', 'telemetry'] allow_experimental_apis = true sources = files( 'esp.c',
examples/ipsec-secgw/sa.c +12 -3
@@ -323,6 +323,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,return ;if (atoi (tokens[1 ]) ==INVALID_SPI )return ; + rule->flags =0 ; rule->spi =atoi (tokens[1 ]); rule->portid =UINT16_MAX ; ips =ipsec_get_primary_session (rule);
@@ -339,14 +340,14 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (strcmp (tokens[ti],"ipv4-tunnel" ) ==0 ) { sa_cnt->nb_v4++; - rule->flags =IP4_TUNNEL ; + rule->flags |=IP4_TUNNEL ; }else if (strcmp (tokens[ti],"ipv6-tunnel" ) ==0 ) { sa_cnt->nb_v6++; - rule->flags =IP6_TUNNEL ; + rule->flags |=IP6_TUNNEL ; }else if (strcmp (tokens[ti],"transport" ) ==0 ) { sa_cnt->nb_v4++; sa_cnt->nb_v6++; - rule->flags =TRANSPORT ; + rule->flags |=TRANSPORT ; }else {APP_CHECK (0 , status,"unrecognized " "input \"%s\"" , tokens[ti]);
@@ -357,6 +358,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"telemetry" ) ==0 ) { + rule->flags |=SA_TELEMETRY_ENABLE ; +continue ; + } +if (strcmp (tokens[ti],"cipher_algo" ) ==0 ) {const struct supported_cipher_algo *algo;uint32_t key_len;
@@ -1407,6 +1413,9 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)if (rc <0 )return rc; +if (lsa->flags &SA_TELEMETRY_ENABLE ) +rte_ipsec_telemetry_sa_add (sa); +/* init primary processing session */ ips =ipsec_get_primary_session (lsa); rc =fill_ipsec_session (ips, sa);
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 5/8] examples/ipsec-secgw: add support for telemetry
Subject can be
Examples/ipsec-secgw: support telemetry
Quoted 2 lines
Add telemetry support to the IPsec GW sample app
Elaborate patch description to show how it can be used. Probably it is worth mentioning how the output will look like.
Quoted 11 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/sample_app_ug/ipsec_secgw.rst | 11 + examples/ipsec-secgw/ipsec-secgw.c | 357 ++++++++++++++++++++++- examples/ipsec-secgw/ipsec-secgw.h | 31 ++ examples/ipsec-secgw/ipsec.h | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 15 +- 6 files changed, 398 insertions(+), 20 deletions(-)
Release notes.
Add a sub-bullet for each of the new features added.
Quoted 12 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +3
-0@@ -735,6 +735,17 @@ where each options means: * *mss N* N is the segment size +``<telemetry>`` + + * Option to enable per SA telemetry.
doc/guides/sample_app_ug/ipsec_secgw.rst where each options means: · line 750
Quoted 10 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +8
-0+ Currently only supported with IPsec library path. + + * Optional: Yes, it is disabled by default + + * Syntax: + + * *telemetry* + Example SA rules:
print_usage() is not updated.
PATCH v3 6/8 examples/ipsec-secgw: add support for defining initial sequence number value
In reply to Radu NicolauAdd esn field to SA definition block to allow initial ESN value
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec.c | 6 ++++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 10 ++++++++++ 4 files changed, 27 insertions(+)
doc/guides/sample_app_ug/ipsec_secgw.rst +10 -0
@@ -746,6 +746,16 @@ where each options means: * *telemetry* + ``<esn>`` + + * Enable ESN and set the initial ESN value. + + * Optional: Yes, ESN not enabled by default + + * Syntax: + + * *esn N* N is the initial ESN value + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec.c +6 -0
@@ -228,6 +228,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sess_conf.ipsec.udp.dport =htons (sa->udp.dport); } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } + +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
examples/ipsec-secgw/ipsec.h +1 -0
@@ -146,6 +146,7 @@ struct ipsec_sa {uint8_t udp_encap;uint16_t portid;uint16_t mss; +uint64_t esn;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +10 -0
@@ -694,6 +694,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 6/8] examples/ipsec-secgw: add support for defining initial sequence number value
Quoted 4 lines
Subject: [EXT] [PATCH v3 6/8] examples/ipsec-secgw: add support for defining initial sequence number value
Subject too long.
examples/ipsec-secgw: define initial ESN value
Quoted 1 line
Add esn field to SA definition block to allow initial ESN value
The commit description should describe the new option added in the app. Only a one liner comment is not sufficient. Please check other patches as well.
Quoted 19 lines
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec.c | 6 ++++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 10 ++++++++++ 4 files changed, 27 insertions(+)doc/guides/sample_app_ug/ipsec_secgw.rst +0
-0@@ -746,6 +746,16 @@ where each options means: * *telemetry*
doc/guides/sample_app_ug/ipsec_secgw.rst where each options means: · line 758
Quoted 10 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +10
-0+ ``<esn>`` + + * Enable ESN and set the initial ESN value. + + * Optional: Yes, ESN not enabled by default + + * Syntax: + + * *esn N* N is the initial ESN value +
Print_usage() update missing.
Quoted 8 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +0
-0Example SA rules: .. code-block:: consoleexamples/ipsec-secgw/ipsec.c +0
-0
examples/ipsec-secgw/ipsec.c create_inline_session(struct socket_ctx *skt_ctx, · line 237
Quoted 10 lines
examples/ipsec-secgw/ipsec.c +6
-0@@ -228,6 +228,12 @@ create_inline_session(struct socket_ctx *skt_ctx,struct ipsec_sa *sa, sess_conf.ipsec.udp.dport = htons(sa->udp.dport); } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } + +
Extra line
Quoted 39 lines
examples/ipsec-secgw/ipsec.c +0
-0RTE_LOG_DP(DEBUG, IPSEC, "Create session for SA spi %u on port %u\n",examples/ipsec-secgw/ipsec.c +0
-0sa->spi, sa->portid);examples/ipsec-secgw/ipsec.h +1
-0@@ -146,6 +146,7 @@ struct ipsec_sa {uint8_t udp_encap;uint16_t portid;uint16_t mss; +uint64_t esn;uint8_t fdir_qid;uint8_t fdir_flag;examples/ipsec-secgw/sa.c +10
-1@@ -694,6 +694,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb; --2.25.1
PATCH v3 7/8 examples/ipsec-secgw: add ethdev reset callback
In reply to Radu NicolauAdd event handler for ethdev reset callback
--- examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
examples/ipsec-secgw/ipsec-secgw.c +14 -0
@@ -2563,6 +2563,17 @@ inline_ipsec_event_callback(uint16_t port_id, enum rte_eth_event_type type,return -1 ; } +static int +ethdev_reset_event_callback (uint16_t port_id, + enum rte_eth_event_type type __rte_unused, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d\n" , port_id); +printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue, struct rte_mbuf *pkt[], uint16_t nb_pkts,
@@ -3329,6 +3340,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_IPSEC , inline_ipsec_event_callback,NULL ); }
Signature · 1 line
2.25.1
PATCH v3 8/8 examples/ipsec-secgw: add support for additional algorithms
In reply to Radu NicolauAdd support for AES-GMAC, AES_CTR, AES_XCBC_MAC,AES_CCM, CHACHA20_POLY1305
--- examples/ipsec-secgw/ipsec.h | 3 +- examples/ipsec-secgw/sa.c | 133 ++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 10 deletions(-)
examples/ipsec-secgw/ipsec.h +1 -2
@@ -65,8 +65,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 - +#define MAX_KEY_SIZE 96/* * application wide SA parameters */
examples/ipsec-secgw/sa.c +125 -8
196 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 8/8] examples/ipsec-secgw: add support for additional algorithms
Quoted 10 lines
Add support for AES-GMAC,
AES_CTR,AES_XCBC_MAC,AES_CCM,CHACHA20_POLY1305Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec.h | 3 +- examples/ipsec-secgw/sa.c | 133 ++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 10 deletions(-)
Documentation?
Release notes?
examples/ipsec-secgw/ipsec.h struct ip_addr { · line 68
Quoted 11 lines
examples/ipsec-secgw/ipsec.h +1
-2@@ -65,8 +65,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 - +#define MAX_KEY_SIZE 96
Max key length defined below is 64, then why 96?
Quoted 114 lines
examples/ipsec-secgw/ipsec.h +0
-0/* * application wide SA parameters */ examples/ipsec-secgw/sa.c +76
-0@@ -46,6 +46,7 @@ struct supported_cipher_algo {struct supported_auth_algo {const char *keyword;enum rte_crypto_auth_algorithm algo; +uint16_t iv_len;uint16_t digest_len;uint16_t key_len;uint8_t key_not_req;@@ -98,6 +99,20 @@ const struct supported_cipher_algo cipher_algos[] = { .block_size = 4, .key_len =20 }, + { + .keyword = "aes-192-ctr", + .algo = RTE_CRYPTO_CIPHER_AES_CTR, + .iv_len = 16, + .block_size = 16, + .key_len =28 + }, + { + .keyword = "aes-256-ctr", + .algo = RTE_CRYPTO_CIPHER_AES_CTR, + .iv_len = 16, + .block_size = 16, + .key_len =36 + }, { .keyword = "3des-cbc", .algo = RTE_CRYPTO_CIPHER_3DES_CBC,@@ -126,6 +141,31 @@ const struct supported_auth_algo auth_algos[] = { .algo = RTE_CRYPTO_AUTH_SHA256_HMAC, .digest_len = 16, .key_len =32 + }, + { + .keyword = "sha384-hmac", + .algo = RTE_CRYPTO_AUTH_SHA384_HMAC, + .digest_len = 24, + .key_len =48 + }, + { + .keyword = "sha512-hmac", + .algo = RTE_CRYPTO_AUTH_SHA512_HMAC, + .digest_len = 32, + .key_len =64 + }, + { + .keyword = "aes-gmac", + .algo = RTE_CRYPTO_AUTH_AES_GMAC, + .iv_len = 8, + .digest_len = 16, + .key_len =20 + }, + { + .keyword = "aes-xcbc-mac-96", + .algo = RTE_CRYPTO_AUTH_AES_XCBC_MAC, + .digest_len = 12, + .key_len = 16 } };@@ -156,6 +196,42 @@ const struct supported_aead_algo aead_algos[] = { .key_len = 36, .digest_len = 16, .aad_len = 8, + }, + { + .keyword = "aes-128-ccm", + .algo = RTE_CRYPTO_AEAD_AES_CCM, + .iv_len = 8, + .block_size = 4, + .key_len = 20, + .digest_len = 16, + .aad_len = 8, + }, + { + .keyword = "aes-192-ccm", + .algo = RTE_CRYPTO_AEAD_AES_CCM, + .iv_len = 8, + .block_size = 4, + .key_len = 28, + .digest_len = 16, + .aad_len = 8, + }, + { + .keyword = "aes-256-ccm", + .algo = RTE_CRYPTO_AEAD_AES_CCM, + .iv_len = 8, + .block_size = 4, + .key_len = 36, + .digest_len = 16, + .aad_len = 8, + }, + { + .keyword = "chacha20-poly1305", + .algo = RTE_CRYPTO_AEAD_CHACHA20_POLY1305, + .iv_len = 12, + .block_size = 64, + .key_len = 36, + .digest_len = 16, + .aad_len = 8, } };@@ -484,6 +560,15 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (status->status <0 )return ;
examples/ipsec-secgw/sa.c parse_sa_tokens(char **tokens, uint32_t n_tokens, · line 571
Quoted 10 lines
examples/ipsec-secgw/sa.c +9
-0+if (algo->algo ==RTE_CRYPTO_AUTH_AES_GMAC ) { + key_len -=4 ; + rule->auth_key_len = key_len; + rule->iv_len = algo->iv_len; +memcpy (&rule->salt, + &rule->auth_key[key_len],4 ); + } + +
Extra line
Quoted 10 lines
examples/ipsec-secgw/sa.c +0
-2auth_algo_p =1 ;continue ; }@@ -1181,8 +1266,20 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], break; } -if (sa->aead_algo ==RTE_CRYPTO_AEAD_AES_GCM ) { - iv_length =12 ;
examples/ipsec-secgw/sa.c sa_add_rules(struct sa_ctx *sa_ctx, const struct · line 1279
Quoted 10 lines
examples/ipsec-secgw/sa.c +8
-0+ +if (sa->aead_algo ==RTE_CRYPTO_AEAD_AES_GCM || + sa->aead_algo ==RTE_CRYPTO_AEAD_AES_CCM || + sa->aead_algo ==RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ) { + +if (ips->type == +RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) { + iv_length =8 ;
How is IV length dependent on the action type?
It should be same for all modes for a particular algorithm. Right?
Quoted 25 lines
examples/ipsec-secgw/sa.c +2
-0+ }else { + if (sa->aead_algo ==
RTE_CRYPTO_AEAD_AES_CCM)examples/ipsec-secgw/sa.c +4
-0+ iv_length =11 ; + else + iv_length =12 ; + } sa_ctx->xf[idx].a.type =
RTE_CRYPTO_SYM_XFORM_AEAD;examples/ipsec-secgw/sa.c +1
-3sa_ctx->xf[idx].a.aead.algo = sa->aead_algo;@@ -1206,10 +1303,8 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[], case RTE_CRYPTO_CIPHER_NULL:case RTE_CRYPTO_CIPHER_3DES_CBC :case RTE_CRYPTO_CIPHER_AES_CBC : - iv_length = sa->iv_len; -break ;case RTE_CRYPTO_CIPHER_AES_CTR : - iv_length =16 ; + iv_length = sa->iv_len;break ;default :examples/ipsec-secgw/sa.c +0
-0RTE_LOG(ERR, IPSEC_ESP,
examples/ipsec-secgw/sa.c sa_add_rules(struct sa_ctx *sa_ctx, const struct · line 1322
Quoted 10 lines
examples/ipsec-secgw/sa.c +4
-0@@ -1218,6 +1313,15 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], return -EINVAL; } +if (sa->auth_algo ==RTE_CRYPTO_AUTH_AES_GMAC ) { +if (ips->type == +RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) { + iv_length =8 ;
Same comment here.
Quoted 53 lines
examples/ipsec-secgw/sa.c +5
-0+ }else { + iv_length =12 ; + } + } +examples/ipsec-secgw/sa.c +0
-0if (inbound) { sa_ctx->xf[idx].b.type =
RTE_CRYPTO_SYM_XFORM_CIPHER;
sa_ctx->xf[idx].b.cipher.algo = sa-Quoted 1 line
cipher_algo;examples/ipsec-secgw/sa.c +3
-0@@ -1239,6 +1343,9 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], sa->digest_len; sa_ctx->xf[idx].a.auth.op =RTE_CRYPTO_AUTH_OP_VERIFY ; + sa_ctx->xf[idx].a.auth.iv.offset =IV_OFFSET ; + sa_ctx->xf[idx].a.auth.iv.length = iv_length; + }else {/* outbound */ sa_ctx->xf[idx].a.type =
RTE_CRYPTO_SYM_XFORM_CIPHER;
sa_ctx->xf[idx].a.cipher.algo = sa-Quoted 1 line
cipher_algo;examples/ipsec-secgw/sa.c +13
-3@@ -1260,11 +1367,21 @@ sa_add_rules(struct sa_ctx *sa_ctx, const structipsec_sa entries[], sa->digest_len; sa_ctx->xf[idx].b.auth.op =RTE_CRYPTO_AUTH_OP_GENERATE ; + sa_ctx->xf[idx].b.auth.iv.offset =IV_OFFSET ; + sa_ctx->xf[idx].b.auth.iv.length = iv_length; + } - sa_ctx->xf[idx].a.next = &sa_ctx->xf[idx].b; - sa_ctx->xf[idx].b.next =NULL ; - sa->xforms = &sa_ctx->xf[idx].a; +if (sa->auth_algo ==RTE_CRYPTO_AUTH_AES_GMAC ) { + sa->xforms = inbound ? + &sa_ctx->xf[idx].a : &sa_ctx- >xf[idx].b; + sa->xforms->next =NULL ; + + }else { + sa_ctx->xf[idx].a.next = &sa_ctx->xf[idx].b; + sa_ctx->xf[idx].b.next =NULL ; + sa->xforms = &sa_ctx->xf[idx].a; + }examples/ipsec-secgw/sa.c +0
-1} if (ips->type == --2.25.1
Re: [dpdk-dev] [EXT] [PATCH v3 8/8] examples/ipsec-secgw: add support for additional algorithms
Hi Akhil, thanks for the feedback, some comments below.
Quoted 10 lines · Akhil Goyal
Quoted 10 lines
Add support for AES-GMAC,
AES_CTR,AES_XCBC_MAC,AES_CCM,CHACHA20_POLY1305Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec.h | 3 +- examples/ipsec-secgw/sa.c | 133 ++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 10 deletions(-)
Quoted 2 lines
Documentation?
Release notes?
I will follow up with an updated patchset.
Quoted 3 lines
examples/ipsec-secgw/ipsec.h struct ip_addr { · line 68
Quoted 2 lines
examples/ipsec-secgw/ipsec.h +1
-1- +#define MAX_KEY_SIZE 96Max key length defined below is 64, then why 96?
I guess just to have some room, I will set it back to 64.
Quoted 4 lines
Quoted 4 lines
/* }
Quoted 14 lines
Review
Quoted 12 lines
examples/ipsec-secgw/sa.c +4
-2-if (sa->aead_algo ==RTE_CRYPTO_AEAD_AES_GCM ) { - iv_length =12 ; + +if (sa->aead_algo ==RTE_CRYPTO_AEAD_AES_GCM || + sa->aead_algo ==RTE_CRYPTO_AEAD_AES_CCM || + sa->aead_algo ==
RTE_CRYPTO_AEAD_CHACHA20_POLY1305) {examples/ipsec-secgw/sa.c +3
-0+ + if (ips->type == +RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {(quoted diff) +1
-0+ iv_length = 8;How is IV length dependent on the action type?
It should be same for all modes for a particular algorithm. Right?
The issue here with inline crypto and AEAD algorithms is that we have the IV and the salt used for building the nonce but only the IV is included in the ESP header. And technically and according to the RFCs the value in the inline branch is the correct one, the other is actually the nonce buffer length, not the IV length. I'm not sure if this is the proper fix, probably it's not, but it's probably a change that will not break it for other crypto devices.
v4 cover IPsec Sec GW new features
In reply to Radu NicolauUpdate the IPsec sample app with new features and updates:
- telemetry support
- add reset callback
- stats screen configurable as a command line parameter
- UDP encapsulation support for inline crypto
- ESN with configurable start value
Radu Nicolau (7):
examples/ipsec-secgw: add stats interval argument examples/ipsec-secgw: update create inline session examples/ipsec-secgw: add support for inline crypto UDP encapsulation examples/ipsec-secgw: support telemetry examples/ipsec-secgw: define initial ESN value examples/ipsec-secgw: add ethdev reset callback examples/ipsec-secgw: add support for additional algorithms
doc/guides/rel_notes/release_21_11.rst | 6 + doc/guides/sample_app_ug/ipsec_secgw.rst | 32 +- examples/ipsec-secgw/ipsec-secgw.c | 400 +++++++++++++++++++++-- examples/ipsec-secgw/ipsec-secgw.h | 48 ++- examples/ipsec-secgw/ipsec.c | 93 +++++- examples/ipsec-secgw/ipsec.h | 13 +- examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 156 ++++++++- 8 files changed, 680 insertions(+), 70 deletions(-)
Signature · 5 lines
v2: reworked the patchset to improve quality and address feedback v3: reworked the patchset to accomodate changes in the ipsec libray v4: removed TSO patch and reworked the patchset after feedback 2.25.1
PATCH v4 1/7 examples/ipsec-secgw: add stats interval argument
Add -t for stats screen update interval, disabled by default.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 17 -------------- 3 files changed, 25 insertions(+), 26 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
@@ -127,6 +127,7 @@ The application has a number of command line options:: -p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -w REPLAY_WINDOW_SIZE -e -a -c SAD_CACHE_SIZE + -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]
@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval in seconds. If set + to zero or omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs will be calculated based on number of cores, eth ports and crypto queues.
examples/ipsec-secgw/ipsec-secgw.c +20 -9
@@ -180,6 +180,7 @@ static uint32_t frag_tbl_sz;static uint32_t frame_buf_size =RTE_MBUF_DEFAULT_BUF_SIZE ;static uint32_t mtu_size =RTE_ETHER_MTU ;static uint64_t frag_ttl_ns =MAX_FRAG_TTL_NS ; +static uint32_t stats_interval;/* application wide librte_ipsec/SA parameters */ struct app_sa_prm app_sa_prm = {
@@ -291,7 +292,6 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph, } } -#if (STATS_INTERVAL >0 )/* Print out statistics on packet distribution */ static void
@@ -351,9 +351,8 @@ print_stats_cb(__rte_unused void *param) total_packets_dropped);printf ("\n====================================================\n" ); - rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb, NULL); +rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet (struct rte_mbuf *pkt,struct ipsec_traffic *t)
@@ -1396,6 +1395,7 @@ print_usage(const char *prgname)" [-e]" " [-a]" " [-c]" +" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]"
@@ -1420,6 +1420,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specified number\n" " of mbufs will be calculated based on number of cores,\n" " ports and crypto queues\n"
@@ -1629,7 +1631,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {switch (opt) {
@@ -1710,6 +1712,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);if (ret) {
@@ -3009,11 +3020,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb,NULL ); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch (ipsec_launch_one_lcore, eh_conf,CALL_MAIN );
examples/ipsec-secgw/ipsec-secgw.h +0 -17
@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4
@@ -83,7 +80,6 @@ struct ethaddr_info {uint64_t src, dst; }; -#if (STATS_INTERVAL > 0)struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -94,7 +90,6 @@ struct ipsec_core_statistics { } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */ extern struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS ];
@@ -115,38 +110,26 @@ is_unprotected_port(uint16_t port_id)static inline void core_stats_update_rx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */
Signature · 1 line
2.25.1
PATCH v4 2/7 examples/ipsec-secgw: update create inline session
In reply to Radu NicolauRework create inline session function as to update the session configuration parameters before create session is called. Also updated the rss key array size to prevent buffers overflows with PMDs that copy more than 40 bytes.
--- examples/ipsec-secgw/ipsec.c | 54 +++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-)
examples/ipsec-secgw/ipsec.c +47 -7
@@ -171,16 +171,56 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, .options = { 0 }, .replay_win_sz = 0, .direction = sa->direction, - .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, - .mode = (sa->flags ==IP4_TUNNEL || - sa->flags ==IP6_TUNNEL ) ? -RTE_SECURITY_IPSEC_SA_MODE_TUNNEL : - RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP } }, .crypto_xform = sa->xforms, .userdata = NULL, }; +if (IS_TRANSPORT (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT ; +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + } + }else if (IS_TUNNEL (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + }else { +RTE_LOG (ERR ,IPSEC ,"invalid tunnel type\n" ); +return -1 ; + } + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -266,10 +306,10 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->attr.ingress = (sa->direction ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS );if (sa->attr.ingress) { -uint8_t rss_key[40 ]; +uint8_t rss_key[64 ];struct rte_eth_rss_conf rss_conf = { .rss_key = rss_key, - .rss_key_len =40 , + .rss_key_len =sizeof (rss_key), };struct rte_eth_dev_info dev_info;uint16_t queue[RTE_MAX_QUEUES_PER_PORT ];
Signature · 1 line
2.25.1
PATCH v4 3/7 examples/ipsec-secgw: add support for inline crypto UDP encapsulation
In reply to Radu NicolauEnable UDP encapsulation for both transport and tunnel modes for the inline crypto offload path.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 3 ++- examples/ipsec-secgw/ipsec.c | 33 +++++++++++++++++++++--- examples/ipsec-secgw/ipsec.h | 7 ++++- examples/ipsec-secgw/sa.c | 9 +++++++ 4 files changed, 46 insertions(+), 6 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +2 -1
@@ -717,7 +717,8 @@ where each options means: ``<udp-encap>`` * Option to enable IPsec UDP encapsulation for NAT Traversal. - Only *lookaside-protocol-offload* mode is supported at the moment. + Only *lookaside-protocol-offload* and *inline-protocol-offload* modes are + supported at the moment. * Optional: Yes, it is disabled by default
examples/ipsec-secgw/ipsec.c +29 -4
@@ -221,6 +221,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, } } +if (sa->udp_encap) { + sess_conf.ipsec.options.udp_encap =1 ; + sess_conf.ipsec.udp.sport =htons (sa->udp.sport); + sess_conf.ipsec.udp.dport =htons (sa->udp.dport); + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -289,12 +295,31 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->ipv4_spec.hdr.src_addr = sa->src.ip.ip4; } - sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; - sa->pattern[2 ].spec = &sa->esp_spec; - sa->pattern[2 ].mask = &rte_flow_item_esp_mask; sa->esp_spec.hdr.spi =rte_cpu_to_be_32 (sa->spi); - sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; +if (sa->udp_encap) { + + sa->udp_spec.hdr.dst_port = +rte_cpu_to_be_16 (sa->udp.dport); + sa->udp_spec.hdr.src_port = +rte_cpu_to_be_16 (sa->udp.sport); + + sa->pattern[2 ].mask = &rte_flow_item_udp_mask; + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_UDP ; + sa->pattern[2 ].spec = &sa->udp_spec; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[3 ].spec = &sa->esp_spec; + sa->pattern[3 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[4 ].type =RTE_FLOW_ITEM_TYPE_END ; + }else { + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[2 ].spec = &sa->esp_spec; + sa->pattern[2 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; + } sa->action[0 ].type =RTE_FLOW_ACTION_TYPE_SECURITY ; sa->action[0 ].conf = ips->security.ses;
examples/ipsec-secgw/ipsec.h +6 -1
@@ -125,6 +125,10 @@ struct ipsec_sa {#define IP6_TRANSPORT (1 << 4)struct ip_addr src;struct ip_addr dst; +struct { +uint16_t sport; +uint16_t dport; + } udp;uint8_t cipher_key[MAX_KEY_SIZE ];uint16_t cipher_key_len;uint8_t auth_key[MAX_KEY_SIZE ];
@@ -140,7 +144,7 @@ struct ipsec_sa {uint8_t fdir_qid;uint8_t fdir_flag; -#define MAX_RTE_FLOW_PATTERN (4) +#define MAX_RTE_FLOW_PATTERN (5)#define MAX_RTE_FLOW_ACTIONS (3)struct rte_flow_item pattern[MAX_RTE_FLOW_PATTERN ];struct rte_flow_action action[MAX_RTE_FLOW_ACTIONS ];
@@ -149,6 +153,7 @@ struct ipsec_sa {struct rte_flow_item_ipv4 ipv4_spec;struct rte_flow_item_ipv6 ipv6_spec; }; +struct rte_flow_item_udp udp_spec;struct rte_flow_item_esp esp_spec;struct rte_flow *flow;struct rte_security_session_conf sess_conf;
examples/ipsec-secgw/sa.c +9 -0
@@ -17,6 +17,7 @@#include <rte_byteorder.h> #include <rte_errno.h> #include <rte_ip.h> +#include <rte_udp.h> #include <rte_random.h> #include <rte_ethdev.h> #include <rte_malloc.h>
@@ -771,6 +772,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, app_sa_prm.udp_encap =1 ; udp_encap_p =1 ;break ; +case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO : + rule->udp_encap =1 ; + rule->udp.sport =0 ; + rule->udp.dport =4500 ; +break ;default :APP_CHECK (0 , status, "UDP encapsulation not supported for "
@@ -858,6 +864,8 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound) }printf ("mode:" ); +if (sa->udp_encap) +printf ("UDP encapsulated " );switch (WITHOUT_TRANSPORT_VERSION (sa->flags)) {case IP4_TUNNEL :
@@ -1311,6 +1319,7 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.mode = (IS_TRANSPORT (ss->flags)) ?RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT :RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + prm->ipsec_xform.options.udp_encap = ss->udp_encap; prm->ipsec_xform.options.ecn =1 ; prm->ipsec_xform.options.copy_dscp =1 ;
Signature · 1 line
2.25.1
PATCH v4 4/7 examples/ipsec-secgw: support telemetry
In reply to Radu NicolauAdd telemetry support to the IPsec GW sample app and add support for per SA telemetry when using IPsec library.
--- doc/guides/rel_notes/release_21_11.rst | 4 + doc/guides/sample_app_ug/ipsec_secgw.rst | 11 + examples/ipsec-secgw/ipsec-secgw.c | 357 ++++++++++++++++++++++- examples/ipsec-secgw/ipsec-secgw.h | 31 ++ examples/ipsec-secgw/ipsec.h | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 15 +- 7 files changed, 402 insertions(+), 20 deletions(-)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -177,6 +177,10 @@ New Features * Added tests to verify tunnel header verification in IPsec inbound. * Added tests to verify inner checksum. +* **IPsec Security Gateway sample application new features.** + + * Added support for telemetry + Removed Items -------------
doc/guides/sample_app_ug/ipsec_secgw.rst +11 -0
@@ -726,6 +726,17 @@ where each options means: * *udp-encap* +``<telemetry>`` + + * Option to enable per SA telemetry. + Currently only supported with IPsec library path. + + * Optional: Yes, it is disabled by default + + * Syntax: + + * *telemetry* + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +341 -16
488 lines not on this page · raw message
examples/ipsec-secgw/ipsec-secgw.h +31 -0
@@ -80,6 +80,17 @@ struct ethaddr_info {uint64_t src, dst; }; +struct ipsec_spd_stats { +uint64_t protect; +uint64_t bypass; +uint64_t discard; +}; + +struct ipsec_sa_stats { +uint64_t hit; +uint64_t miss; +}; +struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -87,6 +98,26 @@ struct ipsec_core_statistics {uint64_t tx_call;uint64_t dropped;uint64_t burst_rx; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } outbound; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } inbound; + +struct { +uint64_t miss; + } lpm4; + +struct { +uint64_t miss; + } lpm6; } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ];
examples/ipsec-secgw/ipsec.h +2 -0
@@ -123,6 +123,8 @@ struct ipsec_sa {#define TRANSPORT (1 << 2)#define IP4_TRANSPORT (1 << 3)#define IP6_TRANSPORT (1 << 4) +#define SA_TELEMETRY_ENABLE (1 << 5) +struct ip_addr src;struct ip_addr dst;struct {
examples/ipsec-secgw/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev'] +deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev', 'telemetry'] allow_experimental_apis = true sources = files( 'esp.c',
examples/ipsec-secgw/sa.c +12 -3
@@ -323,6 +323,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,return ;if (atoi (tokens[1 ]) ==INVALID_SPI )return ; + rule->flags =0 ; rule->spi =atoi (tokens[1 ]); rule->portid =UINT16_MAX ; ips =ipsec_get_primary_session (rule);
@@ -339,14 +340,14 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (strcmp (tokens[ti],"ipv4-tunnel" ) ==0 ) { sa_cnt->nb_v4++; - rule->flags =IP4_TUNNEL ; + rule->flags |=IP4_TUNNEL ; }else if (strcmp (tokens[ti],"ipv6-tunnel" ) ==0 ) { sa_cnt->nb_v6++; - rule->flags =IP6_TUNNEL ; + rule->flags |=IP6_TUNNEL ; }else if (strcmp (tokens[ti],"transport" ) ==0 ) { sa_cnt->nb_v4++; sa_cnt->nb_v6++; - rule->flags =TRANSPORT ; + rule->flags |=TRANSPORT ; }else {APP_CHECK (0 , status,"unrecognized " "input \"%s\"" , tokens[ti]);
@@ -357,6 +358,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"telemetry" ) ==0 ) { + rule->flags |=SA_TELEMETRY_ENABLE ; +continue ; + } +if (strcmp (tokens[ti],"cipher_algo" ) ==0 ) {const struct supported_cipher_algo *algo;uint32_t key_len;
@@ -1395,6 +1401,9 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)if (rc <0 )return rc; +if (lsa->flags &SA_TELEMETRY_ENABLE ) +rte_ipsec_telemetry_sa_add (sa); +/* init primary processing session */ ips =ipsec_get_primary_session (lsa); rc =fill_ipsec_session (ips, sa);
Signature · 1 line
2.25.1
PATCH v4 5/7 examples/ipsec-secgw: define initial ESN value
In reply to Radu NicolauNew option added to the SA configuration arguments that allows setting an arbitrary start value for ESN.
For example in the SA below ESN will be enabled and first egress IPsec packet will have the ESN value 10000:
sa out 15 cipher_algo null auth_algo null mode ipv4-tunnel \
src 172.16.1.5 dst 172.16.2.5 \
esn 10000
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec.c | 6 ++++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 10 ++++++++++ 4 files changed, 27 insertions(+)
doc/guides/sample_app_ug/ipsec_secgw.rst +10 -0
@@ -737,6 +737,16 @@ where each options means: * *telemetry* + ``<esn>`` + + * Enable ESN and set the initial ESN value. + + * Optional: Yes, ESN not enabled by default + + * Syntax: + + * *esn N* N is the initial ESN value + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec.c +6 -0
@@ -227,6 +227,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sess_conf.ipsec.udp.dport =htons (sa->udp.dport); } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } + +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
examples/ipsec-secgw/ipsec.h +1 -0
@@ -143,6 +143,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint64_t esn;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +10 -0
@@ -684,6 +684,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
Signature · 1 line
2.25.1
PATCH v4 6/7 examples/ipsec-secgw: add ethdev reset callback
In reply to Radu NicolauApplications should not quietly ignore an ethdev reset event. Register an event handler for ethdev reset callback RTE_ETH_EVENT_INTR_RESET that prints a message and quits the application.
--- examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
examples/ipsec-secgw/ipsec-secgw.c +14 -0
@@ -2551,6 +2551,17 @@ inline_ipsec_event_callback(uint16_t port_id, enum rte_eth_event_type type,return -1 ; } +static int +ethdev_reset_event_callback (uint16_t port_id, + enum rte_eth_event_type type __rte_unused, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d\n" , port_id); +printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue, struct rte_mbuf *pkt[], uint16_t nb_pkts,
@@ -3317,6 +3328,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_IPSEC , inline_ipsec_event_callback,NULL ); }
Signature · 1 line
2.25.1
PATCH v4 7/7 examples/ipsec-secgw: add support for additional algorithms
In reply to Radu NicolauAdd support for AES-GMAC, AES_CTR, AES_XCBC_MAC,AES_CCM, CHACHA20_POLY1305
--- doc/guides/rel_notes/release_21_11.rst | 2 + doc/guides/sample_app_ug/ipsec_secgw.rst | 3 +- examples/ipsec-secgw/ipsec.h | 3 +- examples/ipsec-secgw/sa.c | 122 +++++++++++++++++++++-- 4 files changed, 119 insertions(+), 11 deletions(-)
doc/guides/rel_notes/release_21_11.rst +2 -0
@@ -180,6 +180,8 @@ New Features * **IPsec Security Gateway sample application new features.** * Added support for telemetry + * Added support for more AEAD algorithms: AES-GMAC, AES_CTR, AES_XCBC_MAC, + AES_CCM, CHACHA20_POLY1305 Removed Items
doc/guides/sample_app_ug/ipsec_secgw.rst +2 -1
@@ -106,7 +106,8 @@ Constraints * No IPv6 options headers. * No AH mode. -* Supported algorithms: AES-CBC, AES-CTR, AES-GCM, 3DES-CBC, HMAC-SHA1 and NULL. +* Supported algorithms: AES-CBC, AES-CTR, AES-GCM, 3DES-CBC, HMAC-SHA1, + AES-GMAC, AES_CTR, AES_XCBC_MAC, AES_CCM, CHACHA20_POLY1305 and NULL. * Each SA must be handle by a unique lcore (*1 RX queue per port*). Compiling the Application
examples/ipsec-secgw/ipsec.h +1 -2
@@ -63,8 +63,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 - +#define MAX_KEY_SIZE 64/* * application wide SA parameters */
examples/ipsec-secgw/sa.c +114 -8
185 lines not on this page · raw message
Signature · 1 line
2.25.1
v5 cover IPsec Sec GW new features
In reply to Radu NicolauUpdate the IPsec sample app with new features and updates:
- telemetry support
- add reset callback
- stats screen configurable as a command line parameter
- UDP encapsulation support for inline crypto
- ESN with configurable start value
Radu Nicolau (7):
examples/ipsec-secgw: add stats interval argument examples/ipsec-secgw: update create inline session examples/ipsec-secgw: add support for inline crypto UDP encapsulation examples/ipsec-secgw: support telemetry examples/ipsec-secgw: define initial ESN value examples/ipsec-secgw: add ethdev reset callback examples/ipsec-secgw: add support for additional algorithms
doc/guides/rel_notes/release_21_11.rst | 6 + doc/guides/sample_app_ug/ipsec_secgw.rst | 32 +- examples/ipsec-secgw/ipsec-secgw.c | 400 +++++++++++++++++++++-- examples/ipsec-secgw/ipsec-secgw.h | 48 ++- examples/ipsec-secgw/ipsec.c | 93 +++++- examples/ipsec-secgw/ipsec.h | 13 +- examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 156 ++++++++- 8 files changed, 680 insertions(+), 70 deletions(-)
Signature · 6 lines
v2: reworked the patchset to improve quality and address feedback v3: reworked the patchset to accomodate changes in the ipsec libray v4: removed TSO patch and reworked the patchset after feedback v5: rebased to RC1 2.25.1
PATCH v5 1/7 examples/ipsec-secgw: add stats interval argument
Add -t for stats screen update interval, disabled by default.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 17 -------------- 3 files changed, 25 insertions(+), 26 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
@@ -127,6 +127,7 @@ The application has a number of command line options:: -p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -w REPLAY_WINDOW_SIZE -e -a -c SAD_CACHE_SIZE + -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]
@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval in seconds. If set + to zero or omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs will be calculated based on number of cores, eth ports and crypto queues.
examples/ipsec-secgw/ipsec-secgw.c +20 -9
@@ -179,6 +179,7 @@ static uint32_t frag_tbl_sz;static uint32_t frame_buf_size =RTE_MBUF_DEFAULT_BUF_SIZE ;static uint32_t mtu_size =RTE_ETHER_MTU ;static uint64_t frag_ttl_ns =MAX_FRAG_TTL_NS ; +static uint32_t stats_interval;/* application wide librte_ipsec/SA parameters */ struct app_sa_prm app_sa_prm = {
@@ -289,7 +290,6 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph, } } -#if (STATS_INTERVAL >0 )/* Print out statistics on packet distribution */ static void
@@ -349,9 +349,8 @@ print_stats_cb(__rte_unused void *param) total_packets_dropped);printf ("\n====================================================\n" ); - rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb, NULL); +rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet (struct rte_mbuf *pkt,struct ipsec_traffic *t)
@@ -1394,6 +1393,7 @@ print_usage(const char *prgname)" [-e]" " [-a]" " [-c]" +" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]"
@@ -1418,6 +1418,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specified number\n" " of mbufs will be calculated based on number of cores,\n" " ports and crypto queues\n"
@@ -1627,7 +1629,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {switch (opt) {
@@ -1708,6 +1710,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);if (ret) {
@@ -3003,11 +3014,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb,NULL ); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch (ipsec_launch_one_lcore, eh_conf,CALL_MAIN );
examples/ipsec-secgw/ipsec-secgw.h +0 -17
@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4
@@ -83,7 +80,6 @@ struct ethaddr_info {uint64_t src, dst; }; -#if (STATS_INTERVAL > 0)struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -94,7 +90,6 @@ struct ipsec_core_statistics { } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */ extern struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS ];
@@ -115,38 +110,26 @@ is_unprotected_port(uint16_t port_id)static inline void core_stats_update_rx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */
Signature · 1 line
2.25.1
PATCH v5 2/7 examples/ipsec-secgw: update create inline session
In reply to Radu NicolauRework create inline session function as to update the session configuration parameters before create session is called. Also updated the rss key array size to prevent buffers overflows with PMDs that copy more than 40 bytes.
--- examples/ipsec-secgw/ipsec.c | 54 +++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-)
examples/ipsec-secgw/ipsec.c +47 -7
@@ -171,16 +171,56 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, .options = { 0 }, .replay_win_sz = 0, .direction = sa->direction, - .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, - .mode = (sa->flags ==IP4_TUNNEL || - sa->flags ==IP6_TUNNEL ) ? -RTE_SECURITY_IPSEC_SA_MODE_TUNNEL : - RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP } }, .crypto_xform = sa->xforms, .userdata = NULL, }; +if (IS_TRANSPORT (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT ; +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + } + }else if (IS_TUNNEL (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + }else { +RTE_LOG (ERR ,IPSEC ,"invalid tunnel type\n" ); +return -1 ; + } + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -266,10 +306,10 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->attr.ingress = (sa->direction ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS );if (sa->attr.ingress) { -uint8_t rss_key[40 ]; +uint8_t rss_key[64 ];struct rte_eth_rss_conf rss_conf = { .rss_key = rss_key, - .rss_key_len =40 , + .rss_key_len =sizeof (rss_key), };struct rte_eth_dev_info dev_info;uint16_t queue[RTE_MAX_QUEUES_PER_PORT ];
Signature · 1 line
2.25.1
PATCH v5 3/7 examples/ipsec-secgw: add support for inline crypto UDP encapsulation
In reply to Radu NicolauEnable UDP encapsulation for both transport and tunnel modes for the inline crypto offload path.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 3 ++- examples/ipsec-secgw/ipsec.c | 33 +++++++++++++++++++++--- examples/ipsec-secgw/ipsec.h | 7 ++++- examples/ipsec-secgw/sa.c | 9 +++++++ 4 files changed, 46 insertions(+), 6 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +2 -1
@@ -717,7 +717,8 @@ where each options means: ``<udp-encap>`` * Option to enable IPsec UDP encapsulation for NAT Traversal. - Only *lookaside-protocol-offload* mode is supported at the moment. + Only *lookaside-protocol-offload* and *inline-protocol-offload* modes are + supported at the moment. * Optional: Yes, it is disabled by default
examples/ipsec-secgw/ipsec.c +29 -4
@@ -221,6 +221,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, } } +if (sa->udp_encap) { + sess_conf.ipsec.options.udp_encap =1 ; + sess_conf.ipsec.udp.sport =htons (sa->udp.sport); + sess_conf.ipsec.udp.dport =htons (sa->udp.dport); + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -289,12 +295,31 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->ipv4_spec.hdr.src_addr = sa->src.ip.ip4; } - sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; - sa->pattern[2 ].spec = &sa->esp_spec; - sa->pattern[2 ].mask = &rte_flow_item_esp_mask; sa->esp_spec.hdr.spi =rte_cpu_to_be_32 (sa->spi); - sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; +if (sa->udp_encap) { + + sa->udp_spec.hdr.dst_port = +rte_cpu_to_be_16 (sa->udp.dport); + sa->udp_spec.hdr.src_port = +rte_cpu_to_be_16 (sa->udp.sport); + + sa->pattern[2 ].mask = &rte_flow_item_udp_mask; + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_UDP ; + sa->pattern[2 ].spec = &sa->udp_spec; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[3 ].spec = &sa->esp_spec; + sa->pattern[3 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[4 ].type =RTE_FLOW_ITEM_TYPE_END ; + }else { + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[2 ].spec = &sa->esp_spec; + sa->pattern[2 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; + } sa->action[0 ].type =RTE_FLOW_ACTION_TYPE_SECURITY ; sa->action[0 ].conf = ips->security.ses;
examples/ipsec-secgw/ipsec.h +6 -1
@@ -125,6 +125,10 @@ struct ipsec_sa {#define IP6_TRANSPORT (1 << 4)struct ip_addr src;struct ip_addr dst; +struct { +uint16_t sport; +uint16_t dport; + } udp;uint8_t cipher_key[MAX_KEY_SIZE ];uint16_t cipher_key_len;uint8_t auth_key[MAX_KEY_SIZE ];
@@ -140,7 +144,7 @@ struct ipsec_sa {uint8_t fdir_qid;uint8_t fdir_flag; -#define MAX_RTE_FLOW_PATTERN (4) +#define MAX_RTE_FLOW_PATTERN (5)#define MAX_RTE_FLOW_ACTIONS (3)struct rte_flow_item pattern[MAX_RTE_FLOW_PATTERN ];struct rte_flow_action action[MAX_RTE_FLOW_ACTIONS ];
@@ -149,6 +153,7 @@ struct ipsec_sa {struct rte_flow_item_ipv4 ipv4_spec;struct rte_flow_item_ipv6 ipv6_spec; }; +struct rte_flow_item_udp udp_spec;struct rte_flow_item_esp esp_spec;struct rte_flow *flow;struct rte_security_session_conf sess_conf;
examples/ipsec-secgw/sa.c +9 -0
@@ -17,6 +17,7 @@#include <rte_byteorder.h> #include <rte_errno.h> #include <rte_ip.h> +#include <rte_udp.h> #include <rte_random.h> #include <rte_ethdev.h> #include <rte_malloc.h>
@@ -771,6 +772,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, app_sa_prm.udp_encap =1 ; udp_encap_p =1 ;break ; +case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO : + rule->udp_encap =1 ; + rule->udp.sport =0 ; + rule->udp.dport =4500 ; +break ;default :APP_CHECK (0 , status, "UDP encapsulation not supported for "
@@ -858,6 +864,8 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound) }printf ("mode:" ); +if (sa->udp_encap) +printf ("UDP encapsulated " );switch (WITHOUT_TRANSPORT_VERSION (sa->flags)) {case IP4_TUNNEL :
@@ -1311,6 +1319,7 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.mode = (IS_TRANSPORT (ss->flags)) ?RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT :RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + prm->ipsec_xform.options.udp_encap = ss->udp_encap; prm->ipsec_xform.options.ecn =1 ; prm->ipsec_xform.options.copy_dscp =1 ;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v5 3/7] examples/ipsec-secgw: add support for inline crypto UDP encapsulation
Quoted 22 lines
Enable UDP encapsulation for both transport and tunnel modes for the inline crypto offload path.
Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/sample_app_ug/ipsec_secgw.rst | 3 ++- examples/ipsec-secgw/ipsec.c | 33 +++++++++++++++++++++--- examples/ipsec-secgw/ipsec.h | 7 ++++- examples/ipsec-secgw/sa.c | 9 +++++++ 4 files changed, 46 insertions(+), 6 deletions(-)doc/guides/sample_app_ug/ipsec_secgw.rst +1
-1@@ -717,7 +717,8 @@ where each options means: ``<udp-encap>`` * Option to enable IPsec UDP encapsulation for NAT Traversal. - Only *lookaside-protocol-offload* mode is supported at the moment. + Only *lookaside-protocol-offload* and *inline-protocol-offload* modes
Quoted 2 lines
are
+ supported at the moment.
Patch says inline crypto is supported but here inline protocol offload is supported.
With this fixed,
PATCH v5 4/7 examples/ipsec-secgw: support telemetry
In reply to Radu NicolauAdd telemetry support to the IPsec GW sample app and add support for per SA telemetry when using IPsec library.
--- doc/guides/rel_notes/release_21_11.rst | 4 + doc/guides/sample_app_ug/ipsec_secgw.rst | 11 + examples/ipsec-secgw/ipsec-secgw.c | 357 ++++++++++++++++++++++- examples/ipsec-secgw/ipsec-secgw.h | 31 ++ examples/ipsec-secgw/ipsec.h | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 15 +- 7 files changed, 402 insertions(+), 20 deletions(-)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -305,6 +305,10 @@ New Features * Pcapng format with timestamps and meta-data. * Fixes packet capture with stripped VLAN tags. +* **IPsec Security Gateway sample application new features.** + + * Added support for telemetry + Removed Items -------------
doc/guides/sample_app_ug/ipsec_secgw.rst +11 -0
@@ -726,6 +726,17 @@ where each options means: * *udp-encap* +``<telemetry>`` + + * Option to enable per SA telemetry. + Currently only supported with IPsec library path. + + * Optional: Yes, it is disabled by default + + * Syntax: + + * *telemetry* + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +341 -16
488 lines not on this page · raw message
examples/ipsec-secgw/ipsec-secgw.h +31 -0
@@ -80,6 +80,17 @@ struct ethaddr_info {uint64_t src, dst; }; +struct ipsec_spd_stats { +uint64_t protect; +uint64_t bypass; +uint64_t discard; +}; + +struct ipsec_sa_stats { +uint64_t hit; +uint64_t miss; +}; +struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -87,6 +98,26 @@ struct ipsec_core_statistics {uint64_t tx_call;uint64_t dropped;uint64_t burst_rx; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } outbound; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } inbound; + +struct { +uint64_t miss; + } lpm4; + +struct { +uint64_t miss; + } lpm6; } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ];
examples/ipsec-secgw/ipsec.h +2 -0
@@ -123,6 +123,8 @@ struct ipsec_sa {#define TRANSPORT (1 << 2)#define IP4_TRANSPORT (1 << 3)#define IP6_TRANSPORT (1 << 4) +#define SA_TELEMETRY_ENABLE (1 << 5) +struct ip_addr src;struct ip_addr dst;struct {
examples/ipsec-secgw/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev'] +deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev', 'telemetry'] allow_experimental_apis = true sources = files( 'esp.c',
examples/ipsec-secgw/sa.c +12 -3
@@ -323,6 +323,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,return ;if (atoi (tokens[1 ]) ==INVALID_SPI )return ; + rule->flags =0 ; rule->spi =atoi (tokens[1 ]); rule->portid =UINT16_MAX ; ips =ipsec_get_primary_session (rule);
@@ -339,14 +340,14 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (strcmp (tokens[ti],"ipv4-tunnel" ) ==0 ) { sa_cnt->nb_v4++; - rule->flags =IP4_TUNNEL ; + rule->flags |=IP4_TUNNEL ; }else if (strcmp (tokens[ti],"ipv6-tunnel" ) ==0 ) { sa_cnt->nb_v6++; - rule->flags =IP6_TUNNEL ; + rule->flags |=IP6_TUNNEL ; }else if (strcmp (tokens[ti],"transport" ) ==0 ) { sa_cnt->nb_v4++; sa_cnt->nb_v6++; - rule->flags =TRANSPORT ; + rule->flags |=TRANSPORT ; }else {APP_CHECK (0 , status,"unrecognized " "input \"%s\"" , tokens[ti]);
@@ -357,6 +358,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"telemetry" ) ==0 ) { + rule->flags |=SA_TELEMETRY_ENABLE ; +continue ; + } +if (strcmp (tokens[ti],"cipher_algo" ) ==0 ) {const struct supported_cipher_algo *algo;uint32_t key_len;
@@ -1395,6 +1401,9 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)if (rc <0 )return rc; +if (lsa->flags &SA_TELEMETRY_ENABLE ) +rte_ipsec_telemetry_sa_add (sa); +/* init primary processing session */ ips =ipsec_get_primary_session (lsa); rc =fill_ipsec_session (ips, sa);
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v5 4/7] examples/ipsec-secgw: support telemetry
Quoted 31 lines
examples/ipsec-secgw/ipsec-secgw.c +26
-0+static int +handle_telemetry_cmd_ipsec_secgw_stats(const char *cmd __rte_unused, +const char *params,struct rte_tel_data *data) +{ +uint64_t total_pkts_dropped =0 , total_pkts_tx =0 , total_pkts_rx =0 ; +unsigned int coreid; + +rte_tel_data_start_dict (data); + +if (params) { + coreid = (uint32_t )atoi (params); +if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + + total_pkts_dropped = core_statistics[coreid].dropped; + total_pkts_tx = core_statistics[coreid].tx; + total_pkts_rx = core_statistics[coreid].rx; + + }else { +for (coreid =0 ; coreid <RTE_MAX_LCORE ; coreid++) { + +/* skip disabled cores */ +if (rte_lcore_is_enabled (coreid) ==0 ) +continue ; + + total_pkts_dropped +=core_statistics[coreid].dropped;
examples/ipsec-secgw/ipsec-secgw.c +4
-0+ total_pkts_tx += core_statistics[coreid].tx; + total_pkts_rx += core_statistics[coreid].rx; + } + }
examples/ipsec-secgw/ipsec-secgw.c calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, · line 2901
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.c +10
-0+ +/* add telemetry key/values pairs */ +rte_tel_data_add_dict_u64 (data,"packets received" , + total_pkts_rx); + +rte_tel_data_add_dict_u64 (data,"packets transmitted" , + total_pkts_tx); + +rte_tel_data_add_dict_u64 (data,"packets dopped" , + total_pkts_dropped);
Fix typo dopped
Quoted 158 lines
examples/ipsec-secgw/ipsec-secgw.c +22
-0+ + +return 0 ; +} + +static void +update_lcore_statistics (struct ipsec_core_statistics *total,uint32_t coreid) +{ +struct ipsec_core_statistics *lcore_stats; + +/* skip disabled cores */ +if (rte_lcore_is_enabled (coreid) ==0 ) +return ; + + lcore_stats = &core_statistics[coreid]; + + total->rx = lcore_stats->rx; + total->dropped = lcore_stats->dropped; + total->tx = lcore_stats->tx; + +/* outbound stats */ + total->outbound.spd6.protect += lcore_stats-Quoted 1 line
outbound.spd6.protect;
(quoted diff) +1
-0+ total->outbound.spd6.bypass += lcore_stats-Quoted 1 line
outbound.spd6.bypass;
(quoted diff) +1
-0+ total->outbound.spd6.discard += lcore_stats-Quoted 1 line
outbound.spd6.discard;
(quoted diff) +2
-0+ + total->outbound.spd4.protect += lcore_stats-Quoted 1 line
outbound.spd4.protect;
(quoted diff) +1
-0+ total->outbound.spd4.bypass += lcore_stats-Quoted 1 line
outbound.spd4.bypass;
(quoted diff) +1
-0+ total->outbound.spd4.discard += lcore_stats-Quoted 1 line
outbound.spd4.discard;
examples/ipsec-secgw/ipsec-secgw.c +35
-0+ + total->outbound.sad.miss += lcore_stats->outbound.sad.miss; + +/* inbound stats */ + total->inbound.spd6.protect += lcore_stats->inbound.spd6.protect; + total->inbound.spd6.bypass += lcore_stats->inbound.spd6.bypass; + total->inbound.spd6.discard += lcore_stats->inbound.spd6.discard; + + total->inbound.spd4.protect += lcore_stats->inbound.spd4.protect; + total->inbound.spd4.bypass += lcore_stats->inbound.spd4.bypass; + total->inbound.spd4.discard += lcore_stats->inbound.spd4.discard; + + total->inbound.sad.miss += lcore_stats->inbound.sad.miss; + + +/* routing stats */ + total->lpm4.miss += lcore_stats->lpm4.miss; + total->lpm6.miss += lcore_stats->lpm6.miss; +} + +static void +update_statistics (struct ipsec_core_statistics *total,uint32_t coreid) +{ +memset (total,0 ,sizeof (*total)); + +if (coreid !=UINT32_MAX ) { +update_lcore_statistics (total, coreid); + }else { +for (coreid =0 ; coreid <RTE_MAX_LCORE ; coreid++) +update_lcore_statistics (total, coreid); + } +} + +static int +handle_telemetry_cmd_ipsec_secgw_stats_outbound(const char *cmd
__rte_unused,examples/ipsec-secgw/ipsec-secgw.c +63
-0+ const char *params, struct rte_tel_data *data) +{ + struct ipsec_core_statistics total_stats; + +struct rte_tel_data *spd4_data =rte_tel_data_alloc (); +struct rte_tel_data *spd6_data =rte_tel_data_alloc (); +struct rte_tel_data *sad_data =rte_tel_data_alloc (); + +unsigned int coreid =UINT32_MAX ; + +/* verify allocated telemetry data structures */ +if (!spd4_data || !spd6_data || !sad_data) +return -ENOMEM ; + +/* initialize telemetry data structs as dicts */ +rte_tel_data_start_dict (data); + +rte_tel_data_start_dict (spd4_data); +rte_tel_data_start_dict (spd6_data); +rte_tel_data_start_dict (sad_data); + +if (params) { + coreid = (uint32_t )atoi (params); +if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + } + +update_statistics (&total_stats, coreid); + +/* add spd 4 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd4_data,"protect" , + total_stats.outbound.spd4.protect); +rte_tel_data_add_dict_u64 (spd4_data,"bypass" , + total_stats.outbound.spd4.bypass); +rte_tel_data_add_dict_u64 (spd4_data,"discard" , + total_stats.outbound.spd4.discard); + +rte_tel_data_add_dict_container (data,"spd4" , spd4_data,0 ); + +/* add spd 6 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd6_data,"protect" , + total_stats.outbound.spd6.protect); +rte_tel_data_add_dict_u64 (spd6_data,"bypass" , + total_stats.outbound.spd6.bypass); +rte_tel_data_add_dict_u64 (spd6_data,"discard" , + total_stats.outbound.spd6.discard); + +rte_tel_data_add_dict_container (data,"spd6" , spd6_data,0 ); + +/* add sad telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (sad_data,"miss" , + total_stats.outbound.sad.miss); + +rte_tel_data_add_dict_container (data,"sad" , sad_data,0 ); + +return 0 ; +} + +static int +handle_telemetry_cmd_ipsec_secgw_stats_inbound(const char *cmd
__rte_unused,examples/ipsec-secgw/ipsec-secgw.c +24
-0+ const char *params, struct rte_tel_data *data) +{ + struct ipsec_core_statistics total_stats; + +struct rte_tel_data *spd4_data =rte_tel_data_alloc (); +struct rte_tel_data *spd6_data =rte_tel_data_alloc (); +struct rte_tel_data *sad_data =rte_tel_data_alloc (); + +unsigned int coreid =UINT32_MAX ; + +/* verify allocated telemetry data structures */ +if (!spd4_data || !spd6_data || !sad_data) +return -ENOMEM ; + +/* initialize telemetry data structs as dicts */ +rte_tel_data_start_dict (data); +rte_tel_data_start_dict (spd4_data); +rte_tel_data_start_dict (spd6_data); +rte_tel_data_start_dict (sad_data); + +/* add children dicts to parent dict */ + +if (params) { + coreid = (uint32_t )atoi (params);
examples/ipsec-secgw/ipsec-secgw.c calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, · line 3061
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.c +10
-0+if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + } + +update_statistics (&total_stats, coreid); + +/* add sad telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (sad_data,"miss" , + total_stats.outbound.sad.miss);
This should be inbound I guess.
Quoted 47 lines
examples/ipsec-secgw/ipsec-secgw.c +30
-0+ +rte_tel_data_add_dict_container (data,"sad" , sad_data,0 ); + +/* add spd 4 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd4_data,"protect" , + total_stats.inbound.spd4.protect); +rte_tel_data_add_dict_u64 (spd4_data,"bypass" , + total_stats.inbound.spd4.bypass); +rte_tel_data_add_dict_u64 (spd4_data,"discard" , + total_stats.inbound.spd4.discard); + +rte_tel_data_add_dict_container (data,"spd4" , spd4_data,0 ); + +/* add spd 6 telemetry key/values pairs */ + +rte_tel_data_add_dict_u64 (spd6_data,"protect" , + total_stats.inbound.spd6.protect); +rte_tel_data_add_dict_u64 (spd6_data,"bypass" , + total_stats.inbound.spd6.bypass); +rte_tel_data_add_dict_u64 (spd6_data,"discard" , + total_stats.inbound.spd6.discard); + +rte_tel_data_add_dict_container (data,"spd6" , spd6_data,0 ); + +return 0 ; +} + +static int +handle_telemetry_cmd_ipsec_secgw_stats_routing(const char *cmd
__rte_unused,examples/ipsec-secgw/ipsec-secgw.c +16
-0+ const char *params, struct rte_tel_data *data) +{ + struct ipsec_core_statistics total_stats; + +struct rte_tel_data *lpm4_data =rte_tel_data_alloc (); +struct rte_tel_data *lpm6_data =rte_tel_data_alloc (); + +unsigned int coreid =UINT32_MAX ; + +/* initialize telemetry data structs as dicts */ +rte_tel_data_start_dict (data); +rte_tel_data_start_dict (lpm4_data); +rte_tel_data_start_dict (lpm6_data); + + +if (params) {
examples/ipsec-secgw/ipsec-secgw.c calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, · line 3117
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.c +10
-0+ coreid = (uint32_t )atoi (params); +if (rte_lcore_is_enabled (coreid) ==0 ) +return -EINVAL ; + } + +update_statistics (&total_stats, coreid); + +/* add lpm 4 telemetry key/values pairs */ +rte_tel_data_add_dict_u64 (lpm4_data,"miss" , + total_stats.outbound.spd4.protect);
Again typo, total_stats.lpm4.miss
examples/ipsec-secgw/ipsec-secgw.c calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, · line 3123
Quoted 6 lines
examples/ipsec-secgw/ipsec-secgw.c +6
-0+ +rte_tel_data_add_dict_container (data,"IPv4 LPM" , lpm4_data,0 ); + +/* add lpm 6 telemetry key/values pairs */ +rte_tel_data_add_dict_u64 (lpm6_data,"miss" , + total_stats.outbound.spd6.protect);
Here also
Total_stats.lpm6.miss
examples/ipsec-secgw/ipsec-secgw.c calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, · line 3135
Quoted 12 lines
examples/ipsec-secgw/ipsec-secgw.c +12
-0+ +rte_tel_data_add_dict_container (data,"IPv6 LPM" , lpm6_data,0 ); + +return 0 ; +} + +static void +ipsec_secgw_telemetry_init (void ) +{ +rte_telemetry_register_cmd ("/examples/ipsec-secgw/stats" , + handle_telemetry_cmd_ipsec_secgw_stats, + "Returns outbound global stats. "
Returns global stats
Review
Quoted 12 lines
examples/ipsec-secgw/ipsec-secgw.c +3
-0+ "Optional Parameters: int <logical core id>"); + + rte_telemetry_register_cmd("/examples/ipsec-secgw/stats/outbound",
examples/ipsec-secgw/ipsec-secgw.c +5
-0+ handle_telemetry_cmd_ipsec_secgw_stats_outbound, +"Returns outbound global stats. " + "Optional Parameters: int <logical core id>"); + + rte_telemetry_register_cmd("/examples/ipsec-secgw/stats/inbound",
(quoted diff) +2
-0+ handle_telemetry_cmd_ipsec_secgw_stats_inbound, + "Returns outbound global stats. "
This should be inbound.
examples/ipsec-secgw/ipsec-secgw.c calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq, · line 3150
Quoted 5 lines
examples/ipsec-secgw/ipsec-secgw.c +5
-0+ "Optional Parameters: int <logical core id>"); + +rte_telemetry_register_cmd ("/examples/ipsec-secgw/stats/routing" , + handle_telemetry_cmd_ipsec_secgw_stats_routing, + "Returns outbound global stats. "
Returns routing stats.
Please review the patch for any other Typos before submitting v6.
PATCH v5 5/7 examples/ipsec-secgw: define initial ESN value
In reply to Radu NicolauNew option added to the SA configuration arguments that allows setting an arbitrary start value for ESN.
For example in the SA below ESN will be enabled and first egress IPsec packet will have the ESN value 10000:
sa out 15 cipher_algo null auth_algo null mode ipv4-tunnel \
src 172.16.1.5 dst 172.16.2.5 \
esn 10000
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec.c | 6 ++++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 10 ++++++++++ 4 files changed, 27 insertions(+)
doc/guides/sample_app_ug/ipsec_secgw.rst +10 -0
@@ -737,6 +737,16 @@ where each options means: * *telemetry* + ``<esn>`` + + * Enable ESN and set the initial ESN value. + + * Optional: Yes, ESN not enabled by default + + * Syntax: + + * *esn N* N is the initial ESN value + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec.c +6 -0
@@ -227,6 +227,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sess_conf.ipsec.udp.dport =htons (sa->udp.dport); } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } + +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
examples/ipsec-secgw/ipsec.h +1 -0
@@ -143,6 +143,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint64_t esn;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +10 -0
@@ -684,6 +684,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v5 5/7] examples/ipsec-secgw: define initial ESN value
Quoted 6 lines
New option added to the SA configuration arguments that allows setting an arbitrary start value for ESN.
For example in the SA below ESN will be enabled and first egress IPsec packet will have the ESN value 10000:
Quoted 6 lines
sa out 15
cipher_algonullauth_algonull mode ipv4-tunnel \
src 172.16.1.5 dst 172.16.2.5 \
esn 10000Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>
PATCH v5 6/7 examples/ipsec-secgw: add ethdev reset callback
In reply to Radu NicolauApplications should not quietly ignore an ethdev reset event. Register an event handler for ethdev reset callback RTE_ETH_EVENT_INTR_RESET that prints a message and quits the application.
--- examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
examples/ipsec-secgw/ipsec-secgw.c +14 -0
@@ -2545,6 +2545,17 @@ inline_ipsec_event_callback(uint16_t port_id, enum rte_eth_event_type type,return -1 ; } +static int +ethdev_reset_event_callback (uint16_t port_id, + enum rte_eth_event_type type __rte_unused, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d\n" , port_id); +printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue, struct rte_mbuf *pkt[], uint16_t nb_pkts,
@@ -3311,6 +3322,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_IPSEC , inline_ipsec_event_callback,NULL ); }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v5 6/7] examples/ipsec-secgw: add ethdev reset callback
Quoted 17 lines
Applications should not quietly ignore an ethdev reset event. Register an event handler for ethdev reset callback
RTE_ETH_EVENT_INTR_RESETthat prints a message and quits the application.Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)examples/ipsec- renamed from examples/ipsec-secgw/ipsec-secgw.c +0
-0
secgw/ipsec-secgw.c
index1ef24b7b5c..bfa2070b8d100644
examples/ipsec-secgw/ipsec-secgw.c inline_ipsec_event_callback(uint16_t port_id, · line 2554
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.c +6
-0@@ -2545,6 +2545,17 @@ inline_ipsec_event_callback(uint16_t port_id,enum rte_eth_event_type type, return -1; } +static int +ethdev_reset_event_callback (uint16_t port_id, + enum rte_eth_event_type type __rte_unused, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d\n" , port_id);
You can also print the type of eth event that has happened. With this fixed,
Quoted 22 lines
examples/ipsec-secgw/ipsec-secgw.c +5
-0+printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue,examples/ipsec-secgw/ipsec-secgw.c +3
-0struct rte_mbuf *pkt[], uint16_t nb_pkts,@@ -3311,6 +3322,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); + rte_eth_dev_callback_register(portid, RTE_ETH_EVENT_IPSEC, inline_ipsec_event_callback,NULL);
}
--
2.25.1
PATCH v5 7/7 examples/ipsec-secgw: add support for additional algorithms
In reply to Radu NicolauAdd support for AES-GMAC, AES_CTR, AES_XCBC_MAC,AES_CCM, CHACHA20_POLY1305
--- doc/guides/rel_notes/release_21_11.rst | 2 + doc/guides/sample_app_ug/ipsec_secgw.rst | 3 +- examples/ipsec-secgw/ipsec.h | 3 +- examples/ipsec-secgw/sa.c | 122 +++++++++++++++++++++-- 4 files changed, 119 insertions(+), 11 deletions(-)
doc/guides/rel_notes/release_21_11.rst +2 -0
@@ -308,6 +308,8 @@ New Features * **IPsec Security Gateway sample application new features.** * Added support for telemetry + * Added support for more AEAD algorithms: AES-GMAC, AES_CTR, AES_XCBC_MAC, + AES_CCM, CHACHA20_POLY1305 Removed Items
doc/guides/sample_app_ug/ipsec_secgw.rst +2 -1
@@ -106,7 +106,8 @@ Constraints * No IPv6 options headers. * No AH mode. -* Supported algorithms: AES-CBC, AES-CTR, AES-GCM, 3DES-CBC, HMAC-SHA1 and NULL. +* Supported algorithms: AES-CBC, AES-CTR, AES-GCM, 3DES-CBC, HMAC-SHA1, + AES-GMAC, AES_CTR, AES_XCBC_MAC, AES_CCM, CHACHA20_POLY1305 and NULL. * Each SA must be handle by a unique lcore (*1 RX queue per port*). Compiling the Application
examples/ipsec-secgw/ipsec.h +1 -2
@@ -63,8 +63,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 - +#define MAX_KEY_SIZE 64/* * application wide SA parameters */
examples/ipsec-secgw/sa.c +114 -8
185 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v5 7/7] examples/ipsec-secgw: add support for additional algorithms
Quoted 6 lines
Add support for AES-GMAC,
AES_CTR,AES_XCBC_MAC,AES_CCM,CHACHA20_POLY1305Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>---
v6 cover IPsec Sec GW new features
In reply to Radu NicolauUpdate the IPsec sample app with new features and updates:
- telemetry support
- add reset callback
- stats screen configurable as a command line parameter
- UDP encapsulation support for inline crypto
- ESN with configurable start value
Radu Nicolau (7):
examples/ipsec-secgw: add stats interval argument examples/ipsec-secgw: update create inline session examples/ipsec-secgw: add support for inline crypto UDP encapsulation examples/ipsec-secgw: support telemetry examples/ipsec-secgw: define initial ESN value examples/ipsec-secgw: add ethdev reset callback examples/ipsec-secgw: add support for additional algorithms
doc/guides/rel_notes/release_21_11.rst | 6 + doc/guides/sample_app_ug/ipsec_secgw.rst | 32 +- examples/ipsec-secgw/ipsec-secgw.c | 400 +++++++++++++++++++++-- examples/ipsec-secgw/ipsec-secgw.h | 48 ++- examples/ipsec-secgw/ipsec.c | 93 +++++- examples/ipsec-secgw/ipsec.h | 13 +- examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 156 ++++++++- 8 files changed, 680 insertions(+), 70 deletions(-)
Signature · 7 lines
v2: reworked the patchset to improve quality and address feedback v3: reworked the patchset to accomodate changes in the ipsec libray v4: removed TSO patch and reworked the patchset after feedback v5: rebased to RC1 v6: addressed feeedback 2.25.1
PATCH v6 1/7 examples/ipsec-secgw: add stats interval argument
Add -t for stats screen update interval, disabled by default.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 5 ++++ examples/ipsec-secgw/ipsec-secgw.c | 29 ++++++++++++++++-------- examples/ipsec-secgw/ipsec-secgw.h | 17 -------------- 3 files changed, 25 insertions(+), 26 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
@@ -127,6 +127,7 @@ The application has a number of command line options:: -p PORTMASK -P -u PORTMASK -j FRAMESIZE -l -w REPLAY_WINDOW_SIZE -e -a -c SAD_CACHE_SIZE + -t STATISTICS_INTERVAL -s NUMBER_OF_MBUFS_IN_PACKET_POOL -f CONFIG_FILE_PATH --config (port,queue,lcore)[,(port,queue,lcore)]
@@ -176,6 +177,10 @@ Where: Zero value disables cache. Default value: 128. +* ``-t``: specifies the statistics screen update interval in seconds. If set + to zero or omitted statistics screen is disabled. + Default value: 0. + * ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs will be calculated based on number of cores, eth ports and crypto queues.
examples/ipsec-secgw/ipsec-secgw.c +20 -9
@@ -179,6 +179,7 @@ static uint32_t frag_tbl_sz;static uint32_t frame_buf_size =RTE_MBUF_DEFAULT_BUF_SIZE ;static uint32_t mtu_size =RTE_ETHER_MTU ;static uint64_t frag_ttl_ns =MAX_FRAG_TTL_NS ; +static uint32_t stats_interval;/* application wide librte_ipsec/SA parameters */ struct app_sa_prm app_sa_prm = {
@@ -289,7 +290,6 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph, } } -#if (STATS_INTERVAL >0 )/* Print out statistics on packet distribution */ static void
@@ -349,9 +349,8 @@ print_stats_cb(__rte_unused void *param) total_packets_dropped);printf ("\n====================================================\n" ); - rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb, NULL); +rte_eal_alarm_set (stats_interval *US_PER_S , print_stats_cb,NULL ); } -#endif /* STATS_INTERVAL */ static inline void prepare_one_packet (struct rte_mbuf *pkt,struct ipsec_traffic *t)
@@ -1394,6 +1393,7 @@ print_usage(const char *prgname)" [-e]" " [-a]" " [-c]" +" [-t STATS_INTERVAL]" " [-s NUMBER_OF_MBUFS_IN_PKT_POOL]" " -f CONFIG_FILE" " --config (port,queue,lcore)[,(port,queue,lcore)]"
@@ -1418,6 +1418,8 @@ print_usage(const char *prgname)" -a enables SA SQN atomic behaviour\n" " -c specifies inbound SAD cache size,\n" " zero value disables the cache (default value: 128)\n" +" -t specifies statistics screen update interval,\n" +" zero disables statistics screen (default value: 0)\n" " -s number of mbufs in packet pool, if not specified number\n" " of mbufs will be calculated based on number of cores,\n" " ports and crypto queues\n"
@@ -1627,7 +1629,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) argvopt = argv; -while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:s:" , +while ((opt =getopt_long (argc, argvopt,"aelp:Pu:f:j:w:c:t:s:" , lgopts, &option_index)) !=EOF ) {switch (opt) {
@@ -1708,6 +1710,15 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf) } app_sa_prm.cache_sz = ret;break ; +case 't' : + ret =parse_decimal (optarg); +if (ret <0 ) { +printf ("Invalid interval value: %s\n" , optarg); +print_usage (prgname); +return -1 ; + } + stats_interval = ret; +break ;case CMD_LINE_OPT_CONFIG_NUM : ret =parse_config (optarg);if (ret) {
@@ -3003,11 +3014,11 @@ main(int32_t argc, char **argv)check_all_ports_link_status (enabled_port_mask); -#if (STATS_INTERVAL >0 ) -rte_eal_alarm_set (STATS_INTERVAL *US_PER_S , print_stats_cb,NULL ); -#else -RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" ); -#endif /* STATS_INTERVAL */ +if (stats_interval >0 ) +rte_eal_alarm_set (stats_interval *US_PER_S , + print_stats_cb,NULL ); +else +RTE_LOG (INFO ,IPSEC ,"Stats display disabled\n" );/* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch (ipsec_launch_one_lcore, eh_conf,CALL_MAIN );
examples/ipsec-secgw/ipsec-secgw.h +0 -17
@@ -6,9 +6,6 @@#include <stdbool.h> -#ifndef STATS_INTERVAL -#define STATS_INTERVAL 0 -#endif #define NB_SOCKETS 4
@@ -83,7 +80,6 @@ struct ethaddr_info {uint64_t src, dst; }; -#if (STATS_INTERVAL > 0)struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -94,7 +90,6 @@ struct ipsec_core_statistics { } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */ extern struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS ];
@@ -115,38 +110,26 @@ is_unprotected_port(uint16_t port_id)static inline void core_stats_update_rx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].rx += n; core_statistics[lcore_id].rx_call++;if (n ==MAX_PKT_BURST ) core_statistics[lcore_id].burst_rx += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_tx (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].tx += n; core_statistics[lcore_id].tx_call++; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }static inline void core_stats_update_drop (int n) { -#if (STATS_INTERVAL >0 )int lcore_id =rte_lcore_id (); core_statistics[lcore_id].dropped += n; -#else -RTE_SET_USED (n); -#endif /* STATS_INTERVAL */ }/* helper routine to free bulk of packets */
Signature · 1 line
2.25.1
Re: [dpdk-dev] [EXT] [PATCH v6 1/7] examples/ipsec-secgw: add stats interval argument
examples/ipsec-secgw/ipsec-secgw.h struct ipsec_core_statistics { · line 97
Quoted 9 lines
examples/ipsec-secgw/ipsec-secgw.h +0
-2-#if (STATS_INTERVAL > 0)struct ipsec_core_statistics {uint64_t tx;uint64_t rx;@@ -94,7 +90,6 @@ struct ipsec_core_statistics { } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */
Did you check compilation with this patchset? Even CI is reporting compilation issues. core_statistics need to be declared in .c file.
Re: [dpdk-dev] [EXT] [PATCH v6 1/7] examples/ipsec-secgw: add stats interval argument
Quoted 11 lines · Akhil Goyal
examples/ipsec-secgw/ipsec-secgw.h struct ipsec_core_statistics { · line 97
Quoted 9 lines
examples/ipsec-secgw/ipsec-secgw.h +0
-2-#if (STATS_INTERVAL > 0)struct ipsec_core_statistics {uint64_t tx;uint64_t rx;@@ -94,7 +90,6 @@ struct ipsec_core_statistics { } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */ Did you check compilation with this patchset? Even CI is reporting compilation issues.
core_statisticsneed to be declared in .c file.
Hi Akhil, I did check on my local dev system and it passed, but I can see the problem.
But the issue was not introduced by this patchset, it was only made apparent by removing the #ifdef. It was introduced by this patch:
commit 1329602b6c8f20949ebaefb7aa55f7dca6d1b4f4
Author: Anoob Joseph <[email protected]>
Date: Wed May 13 23:15:19 2020 +0530
examples/ipsec-secgw: add per-core packet statistics
I will send a fix shortly.
Re: [dpdk-dev] [EXT] [PATCH v6 1/7] examples/ipsec-secgw: add stats interval argument
Quoted 11 lines · Akhil Goyal
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.h struct ipsec_core_statistics { · line 97
Quoted 9 lines
examples/ipsec-secgw/ipsec-secgw.h +0
-2-#if (STATS_INTERVAL > 0)struct ipsec_core_statistics {uint64_t tx;uint64_t rx;@@ -94,7 +90,6 @@ struct ipsec_core_statistics { } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ]; -#endif /* STATS_INTERVAL */ Did you check compilation with this patchset? Even CI is reporting
Quoted 9 lines
compilation issues.
Quoted 1 line
core_statisticsneed to be declared in .c file.Hi Akhil, I did check on my local dev system and it passed, but I can see the problem.
But the issue was not introduced by this patchset, it was only made apparent by removing the #ifdef. It was introduced by this patch:
Yes the issue was not visible as it was compiled off, but since your patch Removed ifdefs, the compilation will be broken. Not sure how it passed your Dev environment.
Quoted 7 lines
commit
1329602b6c8f20949ebaefb7aa55f7dca6d1b4f4
Author: Anoob Joseph <[email protected]>
Date: Wed May 13 23:15:19 2020 +0530examples/ipsec-secgw: add per-core packet statistics
I will send a fix shortly.
PATCH v6 2/7 examples/ipsec-secgw: update create inline session
In reply to Radu NicolauRework create inline session function as to update the session configuration parameters before create session is called. Also updated the rss key array size to prevent buffers overflows with PMDs that copy more than 40 bytes.
--- examples/ipsec-secgw/ipsec.c | 54 +++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-)
examples/ipsec-secgw/ipsec.c +47 -7
@@ -171,16 +171,56 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, .options = { 0 }, .replay_win_sz = 0, .direction = sa->direction, - .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, - .mode = (sa->flags ==IP4_TUNNEL || - sa->flags ==IP6_TUNNEL ) ? -RTE_SECURITY_IPSEC_SA_MODE_TUNNEL : - RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP } }, .crypto_xform = sa->xforms, .userdata = NULL, }; +if (IS_TRANSPORT (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT ; +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + } + }else if (IS_TUNNEL (sa->flags)) { + sess_conf.ipsec.mode =RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + +if (IS_IP4 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV4 ; + + sess_conf.ipsec.tunnel.ipv4.src_ip.s_addr = + sa->src.ip.ip4; + sess_conf.ipsec.tunnel.ipv4.dst_ip.s_addr = + sa->dst.ip.ip4; + }else if (IS_IP6 (sa->flags)) { + sess_conf.ipsec.tunnel.type = +RTE_SECURITY_IPSEC_TUNNEL_IPV6 ; + +memcpy (sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr, + sa->src.ip.ip6.ip6_b,16 ); +memcpy (sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr, + sa->dst.ip.ip6.ip6_b,16 ); + }else { +RTE_LOG (ERR ,IPSEC ,"invalid tunnel type\n" ); +return -1 ; + } + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -266,10 +306,10 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->attr.ingress = (sa->direction ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS );if (sa->attr.ingress) { -uint8_t rss_key[40 ]; +uint8_t rss_key[64 ];struct rte_eth_rss_conf rss_conf = { .rss_key = rss_key, - .rss_key_len =40 , + .rss_key_len =sizeof (rss_key), };struct rte_eth_dev_info dev_info;uint16_t queue[RTE_MAX_QUEUES_PER_PORT ];
Signature · 1 line
2.25.1
PATCH v6 3/7 examples/ipsec-secgw: add support for inline crypto UDP encapsulation
In reply to Radu NicolauEnable UDP encapsulation for both transport and tunnel modes for the inline crypto offload path.
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 3 ++- examples/ipsec-secgw/ipsec.c | 33 +++++++++++++++++++++--- examples/ipsec-secgw/ipsec.h | 7 ++++- examples/ipsec-secgw/sa.c | 9 +++++++ 4 files changed, 46 insertions(+), 6 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +2 -1
@@ -717,7 +717,8 @@ where each options means: ``<udp-encap>`` * Option to enable IPsec UDP encapsulation for NAT Traversal. - Only *lookaside-protocol-offload* mode is supported at the moment. + Only *lookaside-protocol-offload* and *inline-crypto-offload* modes are + supported at the moment. * Optional: Yes, it is disabled by default
examples/ipsec-secgw/ipsec.c +29 -4
@@ -221,6 +221,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, } } +if (sa->udp_encap) { + sess_conf.ipsec.options.udp_encap =1 ; + sess_conf.ipsec.udp.sport =htons (sa->udp.sport); + sess_conf.ipsec.udp.dport =htons (sa->udp.dport); + } +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
@@ -289,12 +295,31 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sa->ipv4_spec.hdr.src_addr = sa->src.ip.ip4; } - sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; - sa->pattern[2 ].spec = &sa->esp_spec; - sa->pattern[2 ].mask = &rte_flow_item_esp_mask; sa->esp_spec.hdr.spi =rte_cpu_to_be_32 (sa->spi); - sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; +if (sa->udp_encap) { + + sa->udp_spec.hdr.dst_port = +rte_cpu_to_be_16 (sa->udp.dport); + sa->udp_spec.hdr.src_port = +rte_cpu_to_be_16 (sa->udp.sport); + + sa->pattern[2 ].mask = &rte_flow_item_udp_mask; + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_UDP ; + sa->pattern[2 ].spec = &sa->udp_spec; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[3 ].spec = &sa->esp_spec; + sa->pattern[3 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[4 ].type =RTE_FLOW_ITEM_TYPE_END ; + }else { + sa->pattern[2 ].type =RTE_FLOW_ITEM_TYPE_ESP ; + sa->pattern[2 ].spec = &sa->esp_spec; + sa->pattern[2 ].mask = &rte_flow_item_esp_mask; + + sa->pattern[3 ].type =RTE_FLOW_ITEM_TYPE_END ; + } sa->action[0 ].type =RTE_FLOW_ACTION_TYPE_SECURITY ; sa->action[0 ].conf = ips->security.ses;
examples/ipsec-secgw/ipsec.h +6 -1
@@ -125,6 +125,10 @@ struct ipsec_sa {#define IP6_TRANSPORT (1 << 4)struct ip_addr src;struct ip_addr dst; +struct { +uint16_t sport; +uint16_t dport; + } udp;uint8_t cipher_key[MAX_KEY_SIZE ];uint16_t cipher_key_len;uint8_t auth_key[MAX_KEY_SIZE ];
@@ -140,7 +144,7 @@ struct ipsec_sa {uint8_t fdir_qid;uint8_t fdir_flag; -#define MAX_RTE_FLOW_PATTERN (4) +#define MAX_RTE_FLOW_PATTERN (5)#define MAX_RTE_FLOW_ACTIONS (3)struct rte_flow_item pattern[MAX_RTE_FLOW_PATTERN ];struct rte_flow_action action[MAX_RTE_FLOW_ACTIONS ];
@@ -149,6 +153,7 @@ struct ipsec_sa {struct rte_flow_item_ipv4 ipv4_spec;struct rte_flow_item_ipv6 ipv6_spec; }; +struct rte_flow_item_udp udp_spec;struct rte_flow_item_esp esp_spec;struct rte_flow *flow;struct rte_security_session_conf sess_conf;
examples/ipsec-secgw/sa.c +9 -0
@@ -17,6 +17,7 @@#include <rte_byteorder.h> #include <rte_errno.h> #include <rte_ip.h> +#include <rte_udp.h> #include <rte_random.h> #include <rte_ethdev.h> #include <rte_malloc.h>
@@ -771,6 +772,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, app_sa_prm.udp_encap =1 ; udp_encap_p =1 ;break ; +case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO : + rule->udp_encap =1 ; + rule->udp.sport =0 ; + rule->udp.dport =4500 ; +break ;default :APP_CHECK (0 , status, "UDP encapsulation not supported for "
@@ -858,6 +864,8 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound) }printf ("mode:" ); +if (sa->udp_encap) +printf ("UDP encapsulated " );switch (WITHOUT_TRANSPORT_VERSION (sa->flags)) {case IP4_TUNNEL :
@@ -1311,6 +1319,7 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss, prm->ipsec_xform.mode = (IS_TRANSPORT (ss->flags)) ?RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT :RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ; + prm->ipsec_xform.options.udp_encap = ss->udp_encap; prm->ipsec_xform.options.ecn =1 ; prm->ipsec_xform.options.copy_dscp =1 ;
Signature · 1 line
2.25.1
PATCH v6 4/7 examples/ipsec-secgw: support telemetry
In reply to Radu NicolauAdd telemetry support to the IPsec GW sample app and add support for per SA telemetry when using IPsec library.
--- doc/guides/rel_notes/release_21_11.rst | 4 + doc/guides/sample_app_ug/ipsec_secgw.rst | 11 + examples/ipsec-secgw/ipsec-secgw.c | 357 ++++++++++++++++++++++- examples/ipsec-secgw/ipsec-secgw.h | 31 ++ examples/ipsec-secgw/ipsec.h | 2 + examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 15 +- 7 files changed, 402 insertions(+), 20 deletions(-)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -310,6 +310,10 @@ New Features * Pcapng format with timestamps and meta-data. * Fixes packet capture with stripped VLAN tags. +* **IPsec Security Gateway sample application new features.** + + * Added support for telemetry + Removed Items -------------
doc/guides/sample_app_ug/ipsec_secgw.rst +11 -0
@@ -726,6 +726,17 @@ where each options means: * *udp-encap* +``<telemetry>`` + + * Option to enable per SA telemetry. + Currently only supported with IPsec library path. + + * Optional: Yes, it is disabled by default + + * Syntax: + + * *telemetry* + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +341 -16
488 lines not on this page · raw message
examples/ipsec-secgw/ipsec-secgw.h +31 -0
@@ -80,6 +80,17 @@ struct ethaddr_info {uint64_t src, dst; }; +struct ipsec_spd_stats { +uint64_t protect; +uint64_t bypass; +uint64_t discard; +}; + +struct ipsec_sa_stats { +uint64_t hit; +uint64_t miss; +}; +struct ipsec_core_statistics {uint64_t tx;uint64_t rx;
@@ -87,6 +98,26 @@ struct ipsec_core_statistics {uint64_t tx_call;uint64_t dropped;uint64_t burst_rx; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } outbound; + +struct { +struct ipsec_spd_stats spd4; +struct ipsec_spd_stats spd6; +struct ipsec_sa_stats sad; + } inbound; + +struct { +uint64_t miss; + } lpm4; + +struct { +uint64_t miss; + } lpm6; } __rte_cache_aligned;struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE ];
examples/ipsec-secgw/ipsec.h +2 -0
@@ -123,6 +123,8 @@ struct ipsec_sa {#define TRANSPORT (1 << 2)#define IP4_TRANSPORT (1 << 3)#define IP6_TRANSPORT (1 << 4) +#define SA_TELEMETRY_ENABLE (1 << 5) +struct ip_addr src;struct ip_addr dst;struct {
examples/ipsec-secgw/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev'] +deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev', 'telemetry'] allow_experimental_apis = true sources = files( 'esp.c',
examples/ipsec-secgw/sa.c +12 -3
@@ -323,6 +323,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,return ;if (atoi (tokens[1 ]) ==INVALID_SPI )return ; + rule->flags =0 ; rule->spi =atoi (tokens[1 ]); rule->portid =UINT16_MAX ; ips =ipsec_get_primary_session (rule);
@@ -339,14 +340,14 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,if (strcmp (tokens[ti],"ipv4-tunnel" ) ==0 ) { sa_cnt->nb_v4++; - rule->flags =IP4_TUNNEL ; + rule->flags |=IP4_TUNNEL ; }else if (strcmp (tokens[ti],"ipv6-tunnel" ) ==0 ) { sa_cnt->nb_v6++; - rule->flags =IP6_TUNNEL ; + rule->flags |=IP6_TUNNEL ; }else if (strcmp (tokens[ti],"transport" ) ==0 ) { sa_cnt->nb_v4++; sa_cnt->nb_v6++; - rule->flags =TRANSPORT ; + rule->flags |=TRANSPORT ; }else {APP_CHECK (0 , status,"unrecognized " "input \"%s\"" , tokens[ti]);
@@ -357,6 +358,11 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"telemetry" ) ==0 ) { + rule->flags |=SA_TELEMETRY_ENABLE ; +continue ; + } +if (strcmp (tokens[ti],"cipher_algo" ) ==0 ) {const struct supported_cipher_algo *algo;uint32_t key_len;
@@ -1395,6 +1401,9 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)if (rc <0 )return rc; +if (lsa->flags &SA_TELEMETRY_ENABLE ) +rte_ipsec_telemetry_sa_add (sa); +/* init primary processing session */ ips =ipsec_get_primary_session (lsa); rc =fill_ipsec_session (ips, sa);
Signature · 1 line
2.25.1
PATCH v6 5/7 examples/ipsec-secgw: define initial ESN value
In reply to Radu NicolauNew option added to the SA configuration arguments that allows setting an arbitrary start value for ESN.
For example in the SA below ESN will be enabled and first egress IPsec packet will have the ESN value 10000:
sa out 15 cipher_algo null auth_algo null mode ipv4-tunnel \
src 172.16.1.5 dst 172.16.2.5 \
esn 10000
--- doc/guides/sample_app_ug/ipsec_secgw.rst | 10 ++++++++++ examples/ipsec-secgw/ipsec.c | 6 ++++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/sa.c | 10 ++++++++++ 4 files changed, 27 insertions(+)
doc/guides/sample_app_ug/ipsec_secgw.rst +10 -0
@@ -737,6 +737,16 @@ where each options means: * *telemetry* + ``<esn>`` + + * Enable ESN and set the initial ESN value. + + * Optional: Yes, ESN not enabled by default + + * Syntax: + + * *esn N* N is the initial ESN value + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec.c +6 -0
@@ -227,6 +227,12 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, sess_conf.ipsec.udp.dport =htons (sa->udp.dport); } +if (sa->esn >0 ) { + sess_conf.ipsec.options.esn =1 ; + sess_conf.ipsec.esn.value = sa->esn; + } + +RTE_LOG_DP (DEBUG ,IPSEC ,"Create session for SA spi %u on port %u\n" , sa->spi, sa->portid);
examples/ipsec-secgw/ipsec.h +1 -0
@@ -143,6 +143,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint64_t esn;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/sa.c +10 -0
@@ -684,6 +684,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"esn" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->esn =atoll (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
Signature · 1 line
2.25.1
PATCH v6 6/7 examples/ipsec-secgw: add ethdev reset callback
In reply to Radu NicolauApplications should not quietly ignore an ethdev reset event. Register an event handler for ethdev reset callback RTE_ETH_EVENT_INTR_RESET that prints a message and quits the application.
--- examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
examples/ipsec-secgw/ipsec-secgw.c +14 -0
@@ -2545,6 +2545,17 @@ inline_ipsec_event_callback(uint16_t port_id, enum rte_eth_event_type type,return -1 ; } +static int +ethdev_reset_event_callback (uint16_t port_id, +enum rte_eth_event_type type, + void *param __rte_unused, void *ret_param __rte_unused) +{ +printf ("Reset Event on port id %d type %d\n" , port_id, type); +printf ("Force quit application" ); + force_quit = true; +return 0 ; +} + static uint16_t rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue, struct rte_mbuf *pkt[], uint16_t nb_pkts,
@@ -3311,6 +3322,9 @@ main(int32_t argc, char **argv) rte_strerror(-ret), portid); } +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_INTR_RESET , + ethdev_reset_event_callback,NULL ); +rte_eth_dev_callback_register (portid,RTE_ETH_EVENT_IPSEC , inline_ipsec_event_callback,NULL ); }
Signature · 1 line
2.25.1
PATCH v6 7/7 examples/ipsec-secgw: add support for additional algorithms
In reply to Radu NicolauAdd support for AES-GMAC, AES_CTR, AES_XCBC_MAC,AES_CCM, CHACHA20_POLY1305
--- doc/guides/rel_notes/release_21_11.rst | 2 + doc/guides/sample_app_ug/ipsec_secgw.rst | 3 +- examples/ipsec-secgw/ipsec.h | 3 +- examples/ipsec-secgw/sa.c | 122 +++++++++++++++++++++-- 4 files changed, 119 insertions(+), 11 deletions(-)
doc/guides/rel_notes/release_21_11.rst +2 -0
@@ -313,6 +313,8 @@ New Features * **IPsec Security Gateway sample application new features.** * Added support for telemetry + * Added support for more AEAD algorithms: AES-GMAC, AES_CTR, AES_XCBC_MAC, + AES_CCM, CHACHA20_POLY1305 Removed Items
doc/guides/sample_app_ug/ipsec_secgw.rst +2 -1
@@ -106,7 +106,8 @@ Constraints * No IPv6 options headers. * No AH mode. -* Supported algorithms: AES-CBC, AES-CTR, AES-GCM, 3DES-CBC, HMAC-SHA1 and NULL. +* Supported algorithms: AES-CBC, AES-CTR, AES-GCM, 3DES-CBC, HMAC-SHA1, + AES-GMAC, AES_CTR, AES_XCBC_MAC, AES_CCM, CHACHA20_POLY1305 and NULL. * Each SA must be handle by a unique lcore (*1 RX queue per port*). Compiling the Application
examples/ipsec-secgw/ipsec.h +1 -2
@@ -63,8 +63,7 @@ struct ip_addr { } ip; }; -#define MAX_KEY_SIZE 36 - +#define MAX_KEY_SIZE 64/* * application wide SA parameters */
examples/ipsec-secgw/sa.c +114 -8
185 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 26 lines
Update the IPsec sample app with new features and updates:
- telemetry support
- add reset callback
- stats screen configurable as a command line parameter
- UDP encapsulation support for inline crypto
- ESN with configurable start valueRadu Nicolau (7):
examples/ipsec-secgw: add stats interval argument examples/ipsec-secgw: update create inline session examples/ipsec-secgw: add support for inline crypto UDP encapsulation examples/ipsec-secgw: support telemetry examples/ipsec-secgw: define initial ESN value examples/ipsec-secgw: add ethdev reset callback examples/ipsec-secgw: add support for additional algorithmsdoc/guides/rel_notes/release_21_11.rst | 6 + doc/guides/sample_app_ug/ipsec_secgw.rst | 32 +- examples/ipsec-secgw/ipsec-secgw.c | 400 +++++++++++++++++++++-- examples/ipsec-secgw/ipsec-secgw.h | 48 ++- examples/ipsec-secgw/ipsec.c | 93 +++++- examples/ipsec-secgw/ipsec.h | 13 +- examples/ipsec-secgw/meson.build | 2 +- examples/ipsec-secgw/sa.c | 156 ++++++++- 8 files changed, 680 insertions(+), 70 deletions(-)
Quoted 6 lines
--
v2: reworked the patchset to improve quality and address feedback
v3: reworked the patchset to accomodate changes in the ipsec libray
v4: removed TSO patch and reworked the patchset after feedback
v5: rebased to RC1
v6: addressed feeedback
This patch had a lot of issues which should have been addressed before submitting on ML. Please take care in future.
Rebased over TOT.
Applied to dpdk-next-crypto