From 3fbc22a6729f577e03a5be527671a3d7ac11ef25 Mon Sep 17 00:00:00 2001 From: Jielong Zhou Date: Fri, 28 Jun 2019 15:04:00 +0800 Subject: l4p/udp: enqueue fragmented packets as a whole Send or discard fragments of single IP/UDP packet as a whole, because part of fragments could not be reassembled. Also avoid mbuf leak, for former version would never free part of segments which are not sended. Change-Id: I8cd13e60ced973a8f5d7d24369c3cbee64a38836 Signed-off-by: Jielong Zhou --- lib/libtle_l4p/udp_rxtx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/libtle_l4p/udp_rxtx.c b/lib/libtle_l4p/udp_rxtx.c index 76f6316..84a13ea 100644 --- a/lib/libtle_l4p/udp_rxtx.c +++ b/lib/libtle_l4p/udp_rxtx.c @@ -457,7 +457,7 @@ stream_drb_alloc(struct tle_udp_stream *s, struct tle_drb *drbs[], static inline uint16_t queue_pkt_out(struct tle_udp_stream *s, struct tle_dev *dev, const void *pkt[], uint16_t nb_pkt, - struct tle_drb *drbs[], uint32_t *nb_drb) + struct tle_drb *drbs[], uint32_t *nb_drb, uint8_t all_or_nothing) { uint32_t bsz, i, n, nb, nbc, nbm; @@ -479,8 +479,11 @@ queue_pkt_out(struct tle_udp_stream *s, struct tle_dev *dev, return 0; /* not enough free drbs, reduce number of packets to send. */ - else if (nb != nbm) + else if (nb != nbm) { + if (all_or_nothing) + return 0; nb_pkt = nb * bsz; + } /* enqueue packets to the destination device. */ nbc = nb; @@ -581,7 +584,7 @@ tle_udp_stream_send(struct tle_stream *us, struct rte_mbuf *pkt[], if (k != i) { k += queue_pkt_out(s, dst.dev, (const void **)(uintptr_t)&pkt[k], i - k, - drb, &nb); + drb, &nb, 0); /* stream TX queue is full. */ if (k != i) { @@ -603,7 +606,7 @@ tle_udp_stream_send(struct tle_stream *us, struct rte_mbuf *pkt[], } n = queue_pkt_out(s, dst.dev, - (const void **)(uintptr_t)frag, rc, drb, &nb); + (const void **)(uintptr_t)frag, rc, drb, &nb, 1); if (n == 0) { while (rc-- != 0) rte_pktmbuf_free(frag[rc]); -- cgit 1.2.3-korg