Skip to content

Commit

Permalink
linux-gen: pktio: dpdk: fix IPv4 csum calculation when l4 offset is n…
Browse files Browse the repository at this point in the history
…ot set

IPv4 header contains length of the header and options in IHL field. It
can be used to replace L3 length calculation based on offsets.
This patch fixes bug: https://bugs.linaro.org/show_bug.cgi?id=3686.

Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-and-tested-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
  • Loading branch information
Bogdan Pricope authored and muvarov committed Mar 29, 2018
1 parent 72febba commit 0225a8a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions platform/linux-generic/pktio/dpdk.c
Expand Up @@ -656,11 +656,7 @@ static inline void pkt_set_ol_tx(odp_pktout_config_opt_t *pktout_cfg,
if (!ipv4_chksum_pkt && !udp_chksum_pkt && !tcp_chksum_pkt)
return;

if (pkt_p->l4_offset == ODP_PACKET_OFFSET_INVALID)
return;

mbuf->l2_len = pkt_p->l3_offset - pkt_p->l2_offset;
mbuf->l3_len = pkt_p->l4_offset - pkt_p->l3_offset;

if (l3_proto_v4)
mbuf->ol_flags = PKT_TX_IPV4;
Expand All @@ -671,8 +667,14 @@ static inline void pkt_set_ol_tx(odp_pktout_config_opt_t *pktout_cfg,
mbuf->ol_flags |= PKT_TX_IP_CKSUM;

((struct ipv4_hdr *)l3_hdr)->hdr_checksum = 0;
mbuf->l3_len = _ODP_IPV4HDR_IHL(*(uint8_t *)l3_hdr) * 4;
}

if (pkt_p->l4_offset == ODP_PACKET_OFFSET_INVALID)
return;

mbuf->l3_len = pkt_p->l4_offset - pkt_p->l3_offset;

l4_hdr = (void *)(mbuf_data + pkt_p->l4_offset);

if (udp_chksum_pkt) {
Expand Down

0 comments on commit 0225a8a

Please sign in to comment.