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

Function ipsec_process

dpdk/examples/ipsec-secgw/ipsec_process.c:239–294  ·  view source on GitHub ↗

* Process ipsec packets. * If packet belong to SA that is subject of inline-crypto, * then process it immediately. * Otherwise do necessary preparations and queue it to related * crypto-dev queue. */

Source from the content-addressed store, hash-verified

237 * crypto-dev queue.
238 */
239void
240ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
241{
242 uint32_t i, k, n;
243 struct ipsec_sa *sa;
244 struct rte_ipsec_group *pg;
245 struct rte_ipsec_session *ips;
246 struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)];
247
248 n = sa_group(trf->ipsec.saptr, trf->ipsec.pkts, grp, trf->ipsec.num);
249
250 for (i = 0; i != n; i++) {
251
252 pg = grp + i;
253 sa = ipsec_mask_saptr(pg->id.ptr);
254
255 /* fallback to cryptodev with RX packets which inline
256 * processor was unable to process
257 */
258 if (sa != NULL)
259 ips = (pg->id.val & IPSEC_SA_OFFLOAD_FALLBACK_FLAG) ?
260 ipsec_get_fallback_session(sa) :
261 ipsec_get_primary_session(sa);
262
263 /* no valid HW session for that SA */
264 if (sa == NULL || unlikely(check_ipsec_session(ips) != 0))
265 k = 0;
266
267 /* process packets inline */
268 else {
269 switch (ips->type) {
270 /* enqueue packets to crypto dev */
271 case RTE_SECURITY_ACTION_TYPE_NONE:
272 case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
273 k = ipsec_prepare_crypto_group(ctx, sa, ips,
274 pg->m, pg->cnt);
275 break;
276 case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
277 case RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL:
278 k = ipsec_process_inline_group(ips, sa,
279 trf, pg->m, pg->cnt);
280 break;
281 case RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO:
282 k = ipsec_process_cpu_group(ips, sa,
283 trf, pg->m, pg->cnt);
284 break;
285 default:
286 k = 0;
287 }
288 }
289
290 /* drop packets that cannot be enqueued/processed */
291 if (k != pg->cnt)
292 free_pkts(pg->m + k, pg->cnt - k);
293 }
294}
295
296static inline uint32_t

Callers 4

process_pkts_inboundFunction · 0.85
process_pkts_outboundFunction · 0.85

Calls 9

sa_groupFunction · 0.85
ipsec_mask_saptrFunction · 0.85
check_ipsec_sessionFunction · 0.85
ipsec_process_cpu_groupFunction · 0.85
free_pktsFunction · 0.70

Tested by

no test coverage detected