| 539 | } |
| 540 | |
| 541 | static inline int |
| 542 | process_ipsec_ev_outbound(struct ipsec_ctx *ctx, struct route_table *rt, |
| 543 | const struct eh_event_link_info *ev_link, struct rte_event *ev) |
| 544 | { |
| 545 | struct rte_ipsec_session *sess; |
| 546 | struct rte_ether_hdr *ethhdr; |
| 547 | struct sa_ctx *sa_ctx; |
| 548 | struct rte_mbuf *pkt; |
| 549 | uint16_t port_id = 0; |
| 550 | struct ipsec_sa *sa; |
| 551 | enum pkt_type type; |
| 552 | uint32_t sa_idx; |
| 553 | uint8_t *nlp; |
| 554 | |
| 555 | /* Get pkt from event */ |
| 556 | pkt = ev->mbuf; |
| 557 | |
| 558 | /* Check the packet type */ |
| 559 | type = process_ipsec_get_pkt_type(pkt, &nlp); |
| 560 | |
| 561 | switch (type) { |
| 562 | case PKT_TYPE_PLAIN_IPV4: |
| 563 | /* Check if we have a match */ |
| 564 | if (check_sp(ctx->sp4_ctx, nlp, &sa_idx) == 0) { |
| 565 | /* No valid match */ |
| 566 | goto drop_pkt_and_exit; |
| 567 | } |
| 568 | break; |
| 569 | case PKT_TYPE_PLAIN_IPV6: |
| 570 | /* Check if we have a match */ |
| 571 | if (check_sp(ctx->sp6_ctx, nlp, &sa_idx) == 0) { |
| 572 | /* No valid match */ |
| 573 | goto drop_pkt_and_exit; |
| 574 | } |
| 575 | break; |
| 576 | default: |
| 577 | /* |
| 578 | * Only plain IPv4 & IPv6 packets are allowed |
| 579 | * on protected port. Drop the rest. |
| 580 | */ |
| 581 | RTE_LOG_DP(DEBUG, IPSEC, "Unsupported packet type = %d\n", type); |
| 582 | goto drop_pkt_and_exit; |
| 583 | } |
| 584 | |
| 585 | ethhdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); |
| 586 | /* Check if the packet has to be bypassed */ |
| 587 | if (sa_idx == BYPASS) { |
| 588 | port_id = get_route(pkt, rt, type); |
| 589 | if (unlikely(port_id == RTE_MAX_ETHPORTS)) { |
| 590 | /* no match */ |
| 591 | goto drop_pkt_and_exit; |
| 592 | } |
| 593 | /* else, we have a matching route */ |
| 594 | goto send_pkt; |
| 595 | } |
| 596 | |
| 597 | /* Validate sa_idx */ |
| 598 | if (unlikely(sa_idx >= ctx->sa_ctx->nb_sa)) |
no test coverage detected