From d2b55249bcb52f9251e4d2da379ac89058ecc54d Mon Sep 17 00:00:00 2001 From: Piotr Azarewicz Date: Wed, 28 Oct 2015 14:30:44 +0100 Subject: [PATCH] port: fix reassembly and fragmentation Bug fixes for ring ports with IPv4/IPv6 reassembly support. Previous implementation can't work properly due to incorrect choosing process function. Also, assuming that, when processing ip packet, ip header is know we can set l3_len parameter here. Fix usage RTE_MBUF_METADATA_* macros due to redefinition the macros. Fixes: 50f54a84dfb7 ("port: add IPv6 reassembly port") Fixes: ba92d511ddac ("port: move metadata offset reference at mbuf head") Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- lib/librte_port/rte_port_frag.c | 5 +++-- lib/librte_port/rte_port_ras.c | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/librte_port/rte_port_frag.c b/lib/librte_port/rte_port_frag.c index 3720d5dba3..0fcace99b6 100644 --- a/lib/librte_port/rte_port_frag.c +++ b/lib/librte_port/rte_port_frag.c @@ -229,9 +229,10 @@ rte_port_ring_reader_frag_rx(void *port, /* Copy meta-data from input jumbo packet to its fragments */ for (i = 0; i < p->n_frags; i++) { - uint8_t *src = RTE_MBUF_METADATA_UINT8_PTR(pkt, 0); + uint8_t *src = + RTE_MBUF_METADATA_UINT8_PTR(pkt, sizeof(struct rte_mbuf)); uint8_t *dst = - RTE_MBUF_METADATA_UINT8_PTR(p->frags[i], 0); + RTE_MBUF_METADATA_UINT8_PTR(p->frags[i], sizeof(struct rte_mbuf)); memcpy(dst, src, p->metadata_size); } diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index 8a2e5545b9..c4bb508133 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -144,7 +144,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; - port->f_ras = (is_ipv4 == 0) ? process_ipv4 : process_ipv6; + port->f_ras = (is_ipv4 == 1) ? process_ipv4 : process_ipv6; return port; } @@ -182,7 +182,7 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) /* Assume there is no ethernet header */ struct ipv4_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv4_hdr *); - /* Get "Do not fragment" flag and fragment offset */ + /* Get "More fragments" flag and fragment offset */ uint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset); uint16_t frag_offset = (uint16_t)(frag_field & IPV4_HDR_OFFSET_MASK); uint16_t frag_flag = (uint16_t)(frag_field & IPV4_HDR_MF_FLAG); @@ -195,6 +195,8 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = &p->death_row; + pkt->l3_len = sizeof(*pkt_hdr); + /* Process this fragment */ mo = rte_ipv4_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr); @@ -225,6 +227,8 @@ process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = &p->death_row; + pkt->l3_len = sizeof(*pkt_hdr) + sizeof(*frag_hdr); + /* Process this fragment */ mo = rte_ipv6_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr, frag_hdr); -- 2.20.1