Good point on the parser since it's validating as well as parsing the packet. I'll add those checks in v3. For the other case, these are ODP owned and maintained data structures and are assumed to be valid. In particular, we don't support zero-length segments so the returned seglen must be non-zero here. If a bogus handle is passed then of course results are undefined, but that's a separate issue.
On Wed, Dec 10, 2014 at 12:07 PM, Stuart Haslam <stuart.has...@arm.com> wrote: > On Tue, Dec 09, 2014 at 10:28:09PM +0000, Bill Fischofer wrote: > > Signed-off-by: Bill Fischofer <bill.fischo...@linaro.org> > > --- > > v2 reflects review comments by Stuart > > > > - Correct miscelaneous errors in packet parser > > > > example/generator/odp_generator.c | 82 +- > > example/ipsec/odp_ipsec.c | 37 +- > > example/ipsec/odp_ipsec_stream.c | 25 +- > > example/l2fwd/odp_l2fwd.c | 3 +- > > example/packet/odp_pktio.c | 9 +- > > helper/include/odph_ip.h | 35 +- > > helper/include/odph_packet.h | 97 --- > > helper/include/odph_udp.h | 5 +- > > platform/linux-generic/Makefile.am | 1 - > > platform/linux-generic/include/api/odp_packet.h | 727 > ++++++++++++---- > > .../linux-generic/include/api/odp_platform_types.h | 21 +- > > .../linux-generic/include/odp_buffer_inlines.h | 54 ++ > > .../linux-generic/include/odp_buffer_internal.h | 1 + > > .../linux-generic/include/odp_packet_internal.h | 81 +- > > platform/linux-generic/odp_crypto.c | 11 +- > > platform/linux-generic/odp_packet.c | 912 > ++++++++++++++++----- > > platform/linux-generic/odp_packet_socket.c | 93 +-- > > 17 files changed, 1558 insertions(+), 636 deletions(-) > > delete mode 100644 helper/include/odph_packet.h > > > > [...] > > > +int odp_packet_copydata_out(odp_packet_t pkt, uint32_t offset, > > + uint32_t len, void *dst) > > { > > - if (ipv6->next_hdr == ODPH_IPPROTO_ESP || > > - ipv6->next_hdr == ODPH_IPPROTO_AH) { > > - pkt_hdr->input_flags.ipopt = 1; > > - pkt_hdr->input_flags.ipsec = 1; > > - return 0; > > + void *mapaddr; > > + uint32_t seglen, cpylen; > > + uint8_t *dstaddr = (uint8_t *)dst; > > + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); > > + > > + while (len > 0) { > > + mapaddr = packet_offset_map(pkt_hdr, offset, &seglen); > > + if (mapaddr == NULL) > > + return -1; > > + cpylen = len > seglen ? seglen : len; > > + memcpy(dstaddr, mapaddr, cpylen); > > + offset += cpylen; > > + dstaddr += cpylen; > > + len -= cpylen; > > } > > If seglen winds up being 0 the above loop never exits so I suppose that > should be checked along with the mapaddr. > > I just hit this issue when trying to update the pktio unit test to use > this API, it could well be that I screwed something up (still looking) > but even so the infinite loop can be avoided. > > [...] > > > +int odp_packet_copydata_in(odp_packet_t pkt, uint32_t offset, > > + uint32_t len, const void *src) > > +{ > > + void *mapaddr; > > + uint32_t seglen, cpylen; > > + const uint8_t *srcaddr = (const uint8_t *)src; > > + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); > > + > > + while (len > 0) { > > + mapaddr = packet_offset_map(pkt_hdr, offset, &seglen); > > + if (mapaddr == NULL) > > + return -1; > > + cpylen = len > seglen ? seglen : len; > > + memcpy(mapaddr, srcaddr, cpylen); > > + offset += cpylen; > > + srcaddr += cpylen; > > + len -= cpylen; > > } > > Same here. > > -- > Stuart. > >
_______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp