dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] mbuf: outer offsets must be zero for non-tunnel packets
Date: Fri, 21 Jun 2019 13:34:19 +0300	[thread overview]
Message-ID: <20190621103419.11626-1-ivan.malov@oktetlabs.ru> (raw)
In-Reply-To: <20190412150542.12026-1-ivan.malov@oktetlabs.ru>
In-Reply-To: <20190412150542.12026-1-ivan.malov@oktetlabs.ru>

Make sure that outer L2 and L3 header length fields are
equal to zero for non-tunnel packets in order to ensure
consistent and predictable behaviour in network drivers.
Explain this expectation in comments to help developers.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
---

Notes:
    At the time of writing a couple of network drivers rely on
    the statement (i40e, ice) whilst more drivers have runtime
    conditional checks to guard all references to these fields.
    This patch is likely to relieve datapath checks in drivers.

 lib/librte_mbuf/rte_mbuf.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 0d9fef0..cb8b34e 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -702,7 +702,12 @@ struct rte_mbuf {
 			uint64_t tso_segsz:RTE_MBUF_TSO_SEGSZ_BITS;
 			/**< TCP TSO segment size */
 
-			/* fields for TX offloading of tunnels */
+			/*
+			 * Fields for Tx offloading of tunnels.
+			 * These fields must be equal to zero in the case
+			 * when (ol_flags & PKT_TX_TUNNEL_MASK) == 0,
+			 * i.e. for all non-tunnel packets.
+			 */
 			uint64_t outer_l3_len:RTE_MBUF_OUTL3_LEN_BITS;
 			/**< Outer L3 (IP) Hdr Length. */
 			uint64_t outer_l2_len:RTE_MBUF_OUTL2_LEN_BITS;
@@ -2376,6 +2381,11 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail
 			!(ol_flags & PKT_TX_OUTER_IPV4))
 		return -EINVAL;
 
+	/* Outer L2/L3 offsets must be equal to zero for non-tunnel packets. */
+	if ((ol_flags & PKT_TX_TUNNEL_MASK) == 0 &&
+	    m->outer_l2_len + m->outer_l3_len != 0)
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
1.8.3.1


  reply	other threads:[~2019-06-21 10:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12 15:05 [dpdk-dev] [RFC PATCH] mbuf: outer offsets must be zero for non-tunnel packets Ivan Malov
2019-06-21 10:34 ` Ivan Malov [this message]
2019-06-21 11:10   ` [dpdk-dev] [PATCH] " Ananyev, Konstantin
2019-06-21 12:35     ` Andrew Rybchenko
2019-06-24 12:59       ` Ananyev, Konstantin
2019-06-24 13:33         ` Andrew Rybchenko
2019-06-24 16:02 ` [dpdk-dev] [PATCH v2] mbuf: outer offsets are undefined " Ivan Malov
2019-06-27 13:09   ` Ananyev, Konstantin
2019-06-27 21:06 ` [dpdk-dev] [PATCH v3] " Ivan Malov
2019-07-01 13:10   ` Olivier Matz
2019-07-01 14:37     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190621103419.11626-1-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).