* [PATCH] net/tap: fix L4 checksum
@ 2023-08-22 7:32 David Marchand
2023-08-22 8:55 ` Olivier Matz
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Marchand @ 2023-08-22 7:32 UTC (permalink / raw)
To: dev
Cc: stable, Ales Musil, Thomas Monjalon, Ophir Munk, Keith Wiles,
Raslan Darawsheh
The L4 checksum offloading API does not require l4_len to be set.
Make the driver discover the L4 headers size by itself.
Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packets")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Tested-by: Ales Musil <amusil@redhat.com>
---
.mailmap | 1 +
drivers/net/tap/rte_eth_tap.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/.mailmap b/.mailmap
index 864d33ee46..b6a21b35cb 100644
--- a/.mailmap
+++ b/.mailmap
@@ -40,6 +40,7 @@ Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Aleksandr Miloshenko <a.miloshenko@f5.com>
Aleksey Baulin <aleksey.baulin@gmail.com>
Aleksey Katargin <gureedo@gmail.com>
+Ales Musil <amusil@redhat.com>
Alexander Bechikov <asb.tyum@gmail.com>
Alexander Belyakov <abelyako@gmail.com>
Alexander Chernavin <achernavin@netgate.com>
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f75559..0ab214847a 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -645,13 +645,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM))) {
+ unsigned int l4_len = 0;
+
is_cksum = 1;
+ if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+ RTE_MBUF_F_TX_UDP_CKSUM)
+ l4_len = sizeof(struct rte_udp_hdr);
+ else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+ RTE_MBUF_F_TX_TCP_CKSUM)
+ l4_len = sizeof(struct rte_tcp_hdr);
+
/* Support only packets with at least layer 4
* header included in the first segment
*/
seg_len = rte_pktmbuf_data_len(mbuf);
- l234_hlen = mbuf->l2_len + mbuf->l3_len + mbuf->l4_len;
+ l234_hlen = mbuf->l2_len + mbuf->l3_len + l4_len;
if (seg_len < l234_hlen)
return -1;
@@ -661,7 +670,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *),
l234_hlen);
tap_tx_l3_cksum(m_copy, mbuf->ol_flags,
- mbuf->l2_len, mbuf->l3_len, mbuf->l4_len,
+ mbuf->l2_len, mbuf->l3_len, l4_len,
&l4_cksum, &l4_phdr_cksum,
&l4_raw_cksum);
iovecs[k].iov_base = m_copy;
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/tap: fix L4 checksum
2023-08-22 7:32 [PATCH] net/tap: fix L4 checksum David Marchand
@ 2023-08-22 8:55 ` Olivier Matz
2023-08-22 15:44 ` David Marchand
2023-08-23 16:01 ` [PATCH v2 1/3] net/tap: fix L4 checksum offloading David Marchand
2023-08-24 7:18 ` [PATCH v3 " David Marchand
2 siblings, 1 reply; 6+ messages in thread
From: Olivier Matz @ 2023-08-22 8:55 UTC (permalink / raw)
To: David Marchand
Cc: dev, stable, Ales Musil, Thomas Monjalon, Ophir Munk,
Keith Wiles, Raslan Darawsheh
Hi David,
On Tue, Aug 22, 2023 at 09:32:44AM +0200, David Marchand wrote:
> The L4 checksum offloading API does not require l4_len to be set.
> Make the driver discover the L4 headers size by itself.
>
> Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packets")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Tested-by: Ales Musil <amusil@redhat.com>
> ---
> .mailmap | 1 +
> drivers/net/tap/rte_eth_tap.c | 13 +++++++++++--
> 2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/.mailmap b/.mailmap
> index 864d33ee46..b6a21b35cb 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -40,6 +40,7 @@ Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Aleksandr Miloshenko <a.miloshenko@f5.com>
> Aleksey Baulin <aleksey.baulin@gmail.com>
> Aleksey Katargin <gureedo@gmail.com>
> +Ales Musil <amusil@redhat.com>
> Alexander Bechikov <asb.tyum@gmail.com>
> Alexander Belyakov <abelyako@gmail.com>
> Alexander Chernavin <achernavin@netgate.com>
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index bf98f75559..0ab214847a 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -645,13 +645,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
> ((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) ||
> (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM ||
> (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM))) {
While looking at the patch, I noticed this line:
mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4)
I think only RTE_MBUF_F_TX_IP_CKSUM should be checked.
> + unsigned int l4_len = 0;
> +
> is_cksum = 1;
>
> + if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> + RTE_MBUF_F_TX_UDP_CKSUM)
> + l4_len = sizeof(struct rte_udp_hdr);
> + else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> + RTE_MBUF_F_TX_TCP_CKSUM)
> + l4_len = sizeof(struct rte_tcp_hdr);
> +
> /* Support only packets with at least layer 4
> * header included in the first segment
> */
> seg_len = rte_pktmbuf_data_len(mbuf);
> - l234_hlen = mbuf->l2_len + mbuf->l3_len + mbuf->l4_len;
> + l234_hlen = mbuf->l2_len + mbuf->l3_len + l4_len;
> if (seg_len < l234_hlen)
> return -1;
>
> @@ -661,7 +670,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
> rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *),
> l234_hlen);
> tap_tx_l3_cksum(m_copy, mbuf->ol_flags,
> - mbuf->l2_len, mbuf->l3_len, mbuf->l4_len,
> + mbuf->l2_len, mbuf->l3_len, l4_len,
> &l4_cksum, &l4_phdr_cksum,
> &l4_raw_cksum);
> iovecs[k].iov_base = m_copy;
> --
> 2.41.0
>
Using rte_ipv4_udptcp_cksum() in this code would probably simplify it, and may
solve other issues (for instance the 0 checksum for UDP which has a special
meaning).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/tap: fix L4 checksum
2023-08-22 8:55 ` Olivier Matz
@ 2023-08-22 15:44 ` David Marchand
0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2023-08-22 15:44 UTC (permalink / raw)
To: Olivier Matz
Cc: dev, stable, Ales Musil, Thomas Monjalon, Ophir Munk,
Keith Wiles, Raslan Darawsheh
On Tue, Aug 22, 2023 at 10:55 AM Olivier Matz <olivier.matz@6wind.com> wrote:
>
> Hi David,
>
> On Tue, Aug 22, 2023 at 09:32:44AM +0200, David Marchand wrote:
> > The L4 checksum offloading API does not require l4_len to be set.
> > Make the driver discover the L4 headers size by itself.
> >
> > Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packets")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > Tested-by: Ales Musil <amusil@redhat.com>
> > ---
> > .mailmap | 1 +
> > drivers/net/tap/rte_eth_tap.c | 13 +++++++++++--
> > 2 files changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/.mailmap b/.mailmap
> > index 864d33ee46..b6a21b35cb 100644
> > --- a/.mailmap
> > +++ b/.mailmap
> > @@ -40,6 +40,7 @@ Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> > Aleksandr Miloshenko <a.miloshenko@f5.com>
> > Aleksey Baulin <aleksey.baulin@gmail.com>
> > Aleksey Katargin <gureedo@gmail.com>
> > +Ales Musil <amusil@redhat.com>
> > Alexander Bechikov <asb.tyum@gmail.com>
> > Alexander Belyakov <abelyako@gmail.com>
> > Alexander Chernavin <achernavin@netgate.com>
> > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> > index bf98f75559..0ab214847a 100644
> > --- a/drivers/net/tap/rte_eth_tap.c
> > +++ b/drivers/net/tap/rte_eth_tap.c
> > @@ -645,13 +645,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
> > ((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) ||
> > (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM ||
> > (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM))) {
>
> While looking at the patch, I noticed this line:
>
> mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4)
>
> I think only RTE_MBUF_F_TX_IP_CKSUM should be checked.
And tap_tx_l3_cksum is wrong too:
if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4)) {
This is a separate issue, I'll send another patch.
>
> > + unsigned int l4_len = 0;
> > +
> > is_cksum = 1;
> >
> > + if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> > + RTE_MBUF_F_TX_UDP_CKSUM)
> > + l4_len = sizeof(struct rte_udp_hdr);
> > + else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> > + RTE_MBUF_F_TX_TCP_CKSUM)
> > + l4_len = sizeof(struct rte_tcp_hdr);
> > +
> > /* Support only packets with at least layer 4
> > * header included in the first segment
> > */
> > seg_len = rte_pktmbuf_data_len(mbuf);
> > - l234_hlen = mbuf->l2_len + mbuf->l3_len + mbuf->l4_len;
> > + l234_hlen = mbuf->l2_len + mbuf->l3_len + l4_len;
> > if (seg_len < l234_hlen)
> > return -1;
> >
> > @@ -661,7 +670,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
> > rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *),
> > l234_hlen);
> > tap_tx_l3_cksum(m_copy, mbuf->ol_flags,
> > - mbuf->l2_len, mbuf->l3_len, mbuf->l4_len,
> > + mbuf->l2_len, mbuf->l3_len, l4_len,
> > &l4_cksum, &l4_phdr_cksum,
> > &l4_raw_cksum);
> > iovecs[k].iov_base = m_copy;
> > --
> > 2.41.0
> >
>
> Using rte_ipv4_udptcp_cksum() in this code would probably simplify it, and may
> solve other issues (for instance the 0 checksum for UDP which has a special
> meaning).
I agree such a rework would make the code easier to read, and may
solve other issues.
But I prefer to keep my original fix as is, and do what you propose as
a followup patch.
--
David Marchand
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/3] net/tap: fix L4 checksum offloading
2023-08-22 7:32 [PATCH] net/tap: fix L4 checksum David Marchand
2023-08-22 8:55 ` Olivier Matz
@ 2023-08-23 16:01 ` David Marchand
2023-08-24 7:18 ` [PATCH v3 " David Marchand
2 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2023-08-23 16:01 UTC (permalink / raw)
To: dev
Cc: olivier.matz, stable, Ales Musil, Thomas Monjalon, Ophir Munk,
Keith Wiles, Raslan Darawsheh
The L4 checksum offloading API does not require l4_len to be set.
Make the driver discover the L4 headers size by itself.
Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packets")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Tested-by: Ales Musil <amusil@redhat.com>
---
.mailmap | 1 +
drivers/net/tap/rte_eth_tap.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/.mailmap b/.mailmap
index 864d33ee46..b6a21b35cb 100644
--- a/.mailmap
+++ b/.mailmap
@@ -40,6 +40,7 @@ Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Aleksandr Miloshenko <a.miloshenko@f5.com>
Aleksey Baulin <aleksey.baulin@gmail.com>
Aleksey Katargin <gureedo@gmail.com>
+Ales Musil <amusil@redhat.com>
Alexander Bechikov <asb.tyum@gmail.com>
Alexander Belyakov <abelyako@gmail.com>
Alexander Chernavin <achernavin@netgate.com>
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f75559..0ab214847a 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -645,13 +645,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM))) {
+ unsigned int l4_len = 0;
+
is_cksum = 1;
+ if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+ RTE_MBUF_F_TX_UDP_CKSUM)
+ l4_len = sizeof(struct rte_udp_hdr);
+ else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+ RTE_MBUF_F_TX_TCP_CKSUM)
+ l4_len = sizeof(struct rte_tcp_hdr);
+
/* Support only packets with at least layer 4
* header included in the first segment
*/
seg_len = rte_pktmbuf_data_len(mbuf);
- l234_hlen = mbuf->l2_len + mbuf->l3_len + mbuf->l4_len;
+ l234_hlen = mbuf->l2_len + mbuf->l3_len + l4_len;
if (seg_len < l234_hlen)
return -1;
@@ -661,7 +670,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *),
l234_hlen);
tap_tx_l3_cksum(m_copy, mbuf->ol_flags,
- mbuf->l2_len, mbuf->l3_len, mbuf->l4_len,
+ mbuf->l2_len, mbuf->l3_len, l4_len,
&l4_cksum, &l4_phdr_cksum,
&l4_raw_cksum);
iovecs[k].iov_base = m_copy;
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] net/tap: fix L4 checksum offloading
2023-08-22 7:32 [PATCH] net/tap: fix L4 checksum David Marchand
2023-08-22 8:55 ` Olivier Matz
2023-08-23 16:01 ` [PATCH v2 1/3] net/tap: fix L4 checksum offloading David Marchand
@ 2023-08-24 7:18 ` David Marchand
2023-11-02 1:21 ` Ferruh Yigit
2 siblings, 1 reply; 6+ messages in thread
From: David Marchand @ 2023-08-24 7:18 UTC (permalink / raw)
To: dev
Cc: olivier.matz, stable, Ales Musil, Thomas Monjalon, Keith Wiles,
Raslan Darawsheh, Ophir Munk
The L4 checksum offloading API does not require l4_len to be set.
Make the driver discover the L4 headers size by itself.
Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packets")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Tested-by: Ales Musil <amusil@redhat.com>
---
.mailmap | 1 +
drivers/net/tap/rte_eth_tap.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/.mailmap b/.mailmap
index 864d33ee46..b6a21b35cb 100644
--- a/.mailmap
+++ b/.mailmap
@@ -40,6 +40,7 @@ Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Aleksandr Miloshenko <a.miloshenko@f5.com>
Aleksey Baulin <aleksey.baulin@gmail.com>
Aleksey Katargin <gureedo@gmail.com>
+Ales Musil <amusil@redhat.com>
Alexander Bechikov <asb.tyum@gmail.com>
Alexander Belyakov <abelyako@gmail.com>
Alexander Chernavin <achernavin@netgate.com>
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f75559..0ab214847a 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -645,13 +645,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM))) {
+ unsigned int l4_len = 0;
+
is_cksum = 1;
+ if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+ RTE_MBUF_F_TX_UDP_CKSUM)
+ l4_len = sizeof(struct rte_udp_hdr);
+ else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+ RTE_MBUF_F_TX_TCP_CKSUM)
+ l4_len = sizeof(struct rte_tcp_hdr);
+
/* Support only packets with at least layer 4
* header included in the first segment
*/
seg_len = rte_pktmbuf_data_len(mbuf);
- l234_hlen = mbuf->l2_len + mbuf->l3_len + mbuf->l4_len;
+ l234_hlen = mbuf->l2_len + mbuf->l3_len + l4_len;
if (seg_len < l234_hlen)
return -1;
@@ -661,7 +670,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *),
l234_hlen);
tap_tx_l3_cksum(m_copy, mbuf->ol_flags,
- mbuf->l2_len, mbuf->l3_len, mbuf->l4_len,
+ mbuf->l2_len, mbuf->l3_len, l4_len,
&l4_cksum, &l4_phdr_cksum,
&l4_raw_cksum);
iovecs[k].iov_base = m_copy;
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/3] net/tap: fix L4 checksum offloading
2023-08-24 7:18 ` [PATCH v3 " David Marchand
@ 2023-11-02 1:21 ` Ferruh Yigit
0 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2023-11-02 1:21 UTC (permalink / raw)
To: David Marchand, dev
Cc: olivier.matz, stable, Ales Musil, Thomas Monjalon, Keith Wiles,
Raslan Darawsheh, Ophir Munk
On 8/24/2023 8:18 AM, David Marchand wrote:
> The L4 checksum offloading API does not require l4_len to be set.
> Make the driver discover the L4 headers size by itself.
>
> Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packets")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Tested-by: Ales Musil <amusil@redhat.com>
>
For series,
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-02 1:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22 7:32 [PATCH] net/tap: fix L4 checksum David Marchand
2023-08-22 8:55 ` Olivier Matz
2023-08-22 15:44 ` David Marchand
2023-08-23 16:01 ` [PATCH v2 1/3] net/tap: fix L4 checksum offloading David Marchand
2023-08-24 7:18 ` [PATCH v3 " David Marchand
2023-11-02 1:21 ` Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).