diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2022-03-22 11:03:21 +0200 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2022-03-31 16:35:49 +0300 |
commit | fbfc5eec19894a74a4c7ce197df8f89c75a89d0e (patch) | |
tree | 1320ea17d98f131b54b07f706986a9823cf33381 /platform/linux-generic/pktio | |
parent | dcc3103f509a4fea326f8afbdabc7033d13c17c0 (diff) |
linux-gen: pktio: socket: copy segmented data to memory for parsing
If received packet data segments are smaller than the parser
contiguous data requirement, copy to memory.
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'platform/linux-generic/pktio')
-rw-r--r-- | platform/linux-generic/pktio/socket.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 16d375bd4..6884471d4 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -22,6 +22,7 @@ #include <odp_debug_internal.h> #include <odp_errno_define.h> #include <odp_classification_internal.h> +#include <odp_macros_internal.h> #include <sys/socket.h> #include <stdio.h> @@ -282,10 +283,16 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, } if (layer) { - uint16_t seg_len = pkt_len; - - if (msgvec[i].msg_hdr.msg_iov->iov_len < pkt_len) - seg_len = msgvec[i].msg_hdr.msg_iov->iov_len; + uint8_t buf[PARSE_BYTES]; + uint16_t seg_len = msgvec[i].msg_hdr.msg_iov->iov_len; + + /* Make sure there is enough data for the packet + * parser in the case of a segmented packet. */ + if (odp_unlikely(seg_len < PARSE_BYTES && pkt_len > seg_len)) { + seg_len = MIN(pkt_len, PARSE_BYTES); + odp_packet_copy_to_mem(pkt, 0, seg_len, buf); + base = buf; + } if (_odp_packet_parse_common(&pkt_hdr->p, base, pkt_len, seg_len, layer, chksums, |