* [dpdk-dev] [PATCH 1/2] mbuf: check sanity of data_len and pkt_len as well
@ 2017-11-16 14:04 Ilya Matveychikov
2017-12-01 16:37 ` Olivier MATZ
2017-12-09 21:39 ` [dpdk-dev] [PATCH v2] " Ilya V. Matveychikov
0 siblings, 2 replies; 6+ messages in thread
From: Ilya Matveychikov @ 2017-11-16 14:04 UTC (permalink / raw)
To: dev
Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
---
lib/librte_mbuf/rte_mbuf.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 7543662f7..491685c36 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -202,8 +202,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
void
rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
{
- const struct rte_mbuf *m_seg;
- unsigned int nb_segs;
+ unsigned int nb_segs, pkt_len;
if (m == NULL)
rte_panic("mbuf is NULL\n");
@@ -220,18 +219,26 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
if ((cnt == 0) || (cnt == UINT16_MAX))
rte_panic("bad ref cnt\n");
+ /* data_len supposed to be not more than pkt_len */
+ if (m->data_len > m->pkt_len)
+ rte_panic("bad data_len\n");
+
/* nothing to check for sub-segments */
if (is_header == 0)
return;
nb_segs = m->nb_segs;
- m_seg = m;
- while (m_seg && nb_segs != 0) {
- m_seg = m_seg->next;
- nb_segs--;
- }
- if (nb_segs != 0)
+ pkt_len = m->pkt_len;
+
+ do {
+ nb_segs -= 1;
+ pkt_len -= m->data_len;
+ } while ((m = m->next) != NULL);
+
+ if (nb_segs)
rte_panic("bad nb_segs\n");
+ if (pkt_len)
+ rte_panic("bad pkt_len\n");
}
/* dump a mbuf on console */
--
2.15.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] mbuf: check sanity of data_len and pkt_len as well
2017-11-16 14:04 [dpdk-dev] [PATCH 1/2] mbuf: check sanity of data_len and pkt_len as well Ilya Matveychikov
@ 2017-12-01 16:37 ` Olivier MATZ
2017-12-09 21:39 ` [dpdk-dev] [PATCH v2] " Ilya V. Matveychikov
1 sibling, 0 replies; 6+ messages in thread
From: Olivier MATZ @ 2017-12-01 16:37 UTC (permalink / raw)
To: Ilya Matveychikov; +Cc: dev
Hi Ilya,
On Thu, Nov 16, 2017 at 06:04:43PM +0400, Ilya Matveychikov wrote:
> Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
Please, add a commit log.
> ---
> lib/librte_mbuf/rte_mbuf.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> index 7543662f7..491685c36 100644
> --- a/lib/librte_mbuf/rte_mbuf.c
> +++ b/lib/librte_mbuf/rte_mbuf.c
> @@ -202,8 +202,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
> void
> rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
> {
> - const struct rte_mbuf *m_seg;
> - unsigned int nb_segs;
> + unsigned int nb_segs, pkt_len;
>
> if (m == NULL)
> rte_panic("mbuf is NULL\n");
> @@ -220,18 +219,26 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
> if ((cnt == 0) || (cnt == UINT16_MAX))
> rte_panic("bad ref cnt\n");
>
> + /* data_len supposed to be not more than pkt_len */
> + if (m->data_len > m->pkt_len)
> + rte_panic("bad data_len\n");
> +
This check should only be done if is_header == 1.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] mbuf: check sanity of data_len and pkt_len as well
2017-11-16 14:04 [dpdk-dev] [PATCH 1/2] mbuf: check sanity of data_len and pkt_len as well Ilya Matveychikov
2017-12-01 16:37 ` Olivier MATZ
@ 2017-12-09 21:39 ` Ilya V. Matveychikov
2017-12-14 8:50 ` Olivier MATZ
1 sibling, 1 reply; 6+ messages in thread
From: Ilya V. Matveychikov @ 2017-12-09 21:39 UTC (permalink / raw)
To: dev; +Cc: olivier.matz, Ilya V. Matveychikov
Update rte_mbuf_sanity_check() to check sanity of data_len and pkt_len
fields. For segmented packets it is supposed that head's pkt_len field
should be the sum of all segments data_len values.
Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
---
lib/librte_mbuf/rte_mbuf.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 7543662f7..937fd70ea 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -202,8 +202,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
void
rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
{
- const struct rte_mbuf *m_seg;
- unsigned int nb_segs;
+ unsigned int nb_segs, pkt_len;
if (m == NULL)
rte_panic("mbuf is NULL\n");
@@ -224,14 +223,22 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
if (is_header == 0)
return;
+ /* data_len is supposed to be not more than pkt_len */
+ if (m->data_len > m->pkt_len)
+ rte_panic("bad data_len\n");
+
nb_segs = m->nb_segs;
- m_seg = m;
- while (m_seg && nb_segs != 0) {
- m_seg = m_seg->next;
- nb_segs--;
- }
- if (nb_segs != 0)
+ pkt_len = m->pkt_len;
+
+ do {
+ nb_segs -= 1;
+ pkt_len -= m->data_len;
+ } while ((m = m->next) != NULL);
+
+ if (nb_segs)
rte_panic("bad nb_segs\n");
+ if (pkt_len)
+ rte_panic("bad pkt_len\n");
}
/* dump a mbuf on console */
--
2.14.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mbuf: check sanity of data_len and pkt_len as well
2017-12-09 21:39 ` [dpdk-dev] [PATCH v2] " Ilya V. Matveychikov
@ 2017-12-14 8:50 ` Olivier MATZ
2017-12-14 9:31 ` Olivier MATZ
0 siblings, 1 reply; 6+ messages in thread
From: Olivier MATZ @ 2017-12-14 8:50 UTC (permalink / raw)
To: Ilya V. Matveychikov; +Cc: dev
On Sun, Dec 10, 2017 at 12:39:18AM +0300, Ilya V. Matveychikov wrote:
> Update rte_mbuf_sanity_check() to check sanity of data_len and pkt_len
> fields. For segmented packets it is supposed that head's pkt_len field
> should be the sum of all segments data_len values.
>
> Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mbuf: check sanity of data_len and pkt_len as well
2017-12-14 8:50 ` Olivier MATZ
@ 2017-12-14 9:31 ` Olivier MATZ
2018-01-11 23:23 ` Thomas Monjalon
0 siblings, 1 reply; 6+ messages in thread
From: Olivier MATZ @ 2017-12-14 9:31 UTC (permalink / raw)
To: Ilya V. Matveychikov; +Cc: dev
On Thu, Dec 14, 2017 at 09:50:25AM +0100, Olivier MATZ wrote:
> On Sun, Dec 10, 2017 at 12:39:18AM +0300, Ilya V. Matveychikov wrote:
> > Update rte_mbuf_sanity_check() to check sanity of data_len and pkt_len
> > fields. For segmented packets it is supposed that head's pkt_len field
> > should be the sum of all segments data_len values.
> >
> > Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
>
> Thanks
Just realized the title does not match ./devtools/check-git-log.sh
constraints. I suggest instead:
mbuf: check sanity of data and packet lengths
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mbuf: check sanity of data_len and pkt_len as well
2017-12-14 9:31 ` Olivier MATZ
@ 2018-01-11 23:23 ` Thomas Monjalon
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-01-11 23:23 UTC (permalink / raw)
To: Ilya V. Matveychikov; +Cc: dev, Olivier MATZ
14/12/2017 10:31, Olivier MATZ:
> On Thu, Dec 14, 2017 at 09:50:25AM +0100, Olivier MATZ wrote:
> > On Sun, Dec 10, 2017 at 12:39:18AM +0300, Ilya V. Matveychikov wrote:
> > > Update rte_mbuf_sanity_check() to check sanity of data_len and pkt_len
> > > fields. For segmented packets it is supposed that head's pkt_len field
> > > should be the sum of all segments data_len values.
> > >
> > > Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
> >
> > Acked-by: Olivier Matz <olivier.matz@6wind.com>
> >
> > Thanks
>
> Just realized the title does not match ./devtools/check-git-log.sh
> constraints. I suggest instead:
>
> mbuf: check sanity of data and packet lengths
Applied, thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-01-11 23:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16 14:04 [dpdk-dev] [PATCH 1/2] mbuf: check sanity of data_len and pkt_len as well Ilya Matveychikov
2017-12-01 16:37 ` Olivier MATZ
2017-12-09 21:39 ` [dpdk-dev] [PATCH v2] " Ilya V. Matveychikov
2017-12-14 8:50 ` Olivier MATZ
2017-12-14 9:31 ` Olivier MATZ
2018-01-11 23:23 ` Thomas Monjalon
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).