X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl2fwd-crypto%2Fmain.c;h=4f5161649234b6f9884002be08e29c0468a55df7;hb=a1978aa23bf4a8dd34087173f7769250d050315e;hp=1016ceb841489007bb356577d2e752115f6a2b1e;hpb=58266cc91efbf45e24fee3a15e23816da6941501;p=dpdk.git diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 1016ceb841..4f51616492 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -616,12 +616,26 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid, struct l2fwd_crypto_options *options) { uint16_t dst_port; + uint32_t pad_len; + struct rte_ipv4_hdr *ip_hdr; + uint32_t ipdata_offset = sizeof(struct rte_ether_hdr); + ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) + + ipdata_offset); dst_port = l2fwd_dst_ports[portid]; if (options->mac_updating) l2fwd_mac_updating(m, dst_port); + if (options->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) + rte_pktmbuf_trim(m, options->auth_xform.auth.digest_length); + + if (options->cipher_xform.cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT) { + pad_len = m->pkt_len - rte_be_to_cpu_16(ip_hdr->total_length) - + ipdata_offset; + rte_pktmbuf_trim(m, pad_len); + } + l2fwd_send_packet(m, dst_port); } @@ -2112,12 +2126,21 @@ check_capabilities(struct l2fwd_crypto_options *options, uint8_t cdev_id) cap->sym.cipher.key_size.max, cap->sym.cipher.key_size.increment) != 0) { - RTE_LOG(DEBUG, USER1, - "Device %u does not support cipher " - "key length\n", + if (dev_info.feature_flags & + RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY) { + RTE_LOG(DEBUG, USER1, + "Key length does not match the device " + "%u capability. Key may be wrapped\n", cdev_id); - return -1; + } else { + RTE_LOG(DEBUG, USER1, + "Key length does not match the device " + "%u capability\n", + cdev_id); + return -1; + } } + /* * Check if length of the cipher key to be randomly generated * is supported by the algorithm chosen. @@ -2812,5 +2835,8 @@ main(int argc, char **argv) return -1; } + /* clean up the EAL */ + rte_eal_cleanup(); + return 0; }