| 119 | } |
| 120 | |
| 121 | static __rte_always_inline void |
| 122 | prepare_one_packet(void *ctx, struct rte_mbuf *pkt, |
| 123 | struct ipsec_traffic *t) |
| 124 | { |
| 125 | uint32_t ptype = pkt->packet_type; |
| 126 | const struct rte_ipv4_hdr *iph4; |
| 127 | const struct rte_ipv6_hdr *iph6; |
| 128 | uint32_t tun_type, l3_type; |
| 129 | uint64_t tx_offload; |
| 130 | uint16_t l3len; |
| 131 | |
| 132 | if (is_ip_reassembly_incomplete(pkt) > 0) { |
| 133 | free_reassembly_fail_pkt(pkt); |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | tun_type = ptype & RTE_PTYPE_TUNNEL_MASK; |
| 138 | l3_type = ptype & RTE_PTYPE_L3_MASK; |
| 139 | |
| 140 | if (RTE_ETH_IS_IPV4_HDR(l3_type)) { |
| 141 | iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt, |
| 142 | RTE_ETHER_HDR_LEN); |
| 143 | adjust_ipv4_pktlen(pkt, iph4, 0); |
| 144 | |
| 145 | if (tun_type == RTE_PTYPE_TUNNEL_ESP) { |
| 146 | t->ipsec.pkts[(t->ipsec.num)++] = pkt; |
| 147 | } else { |
| 148 | t->ip4.data[t->ip4.num] = &iph4->next_proto_id; |
| 149 | t->ip4.pkts[(t->ip4.num)++] = pkt; |
| 150 | } |
| 151 | tx_offload = sizeof(*iph4) << RTE_MBUF_L2_LEN_BITS; |
| 152 | } else if (RTE_ETH_IS_IPV6_HDR(l3_type)) { |
| 153 | int next_proto; |
| 154 | size_t ext_len; |
| 155 | uint8_t *p; |
| 156 | |
| 157 | /* get protocol type */ |
| 158 | iph6 = (const struct rte_ipv6_hdr *)rte_pktmbuf_adj(pkt, |
| 159 | RTE_ETHER_HDR_LEN); |
| 160 | adjust_ipv6_pktlen(pkt, iph6, 0); |
| 161 | |
| 162 | l3len = sizeof(struct ip6_hdr); |
| 163 | |
| 164 | if (tun_type == RTE_PTYPE_TUNNEL_ESP) { |
| 165 | t->ipsec.pkts[(t->ipsec.num)++] = pkt; |
| 166 | } else { |
| 167 | t->ip6.data[t->ip6.num] = &iph6->proto; |
| 168 | t->ip6.pkts[(t->ip6.num)++] = pkt; |
| 169 | } |
| 170 | |
| 171 | /* Determine l3 header size up to ESP extension by walking |
| 172 | * through extension headers. |
| 173 | */ |
| 174 | if (l3_type == RTE_PTYPE_L3_IPV6_EXT || |
| 175 | l3_type == RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) { |
| 176 | p = rte_pktmbuf_mtod(pkt, uint8_t *); |
| 177 | next_proto = iph6->proto; |
| 178 | while (next_proto != IPPROTO_ESP && |
no test coverage detected