mbuf: enforce no option for dynamic fields and flags
PATCH 1/1 mbuf: enforce no option for dynamic fields and flags
As stated in the API, dynamic field and flags should be created with no additional flag (simply in the API for future changes).
Fix the dynamic flag register helper which was not enforcing it and add unit tests.
--- app/test/test_mbuf.c | 18 ++++++++++++++++++ lib/mbuf/rte_mbuf_dyn.c | 4 ++++ 2 files changed, 22 insertions(+)
app/test/test_mbuf.c +18 -0
@@ -2577,6 +2577,16 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool) .align = 3, .flags = 0, }; +const struct rte_mbuf_dynfield dynfield_fail_flag = { + .name ="test-dynfield" , + .size =sizeof (uint8_t ), + .align = __alignof__(uint8_t ), + .flags =1 , + }; +const struct rte_mbuf_dynflag dynflag_fail_flag = { + .name ="test-dynflag" , + .flags =1 , + };const struct rte_mbuf_dynflag dynflag = { .name ="test-dynflag" , .flags =0 ,
@@ -2638,6 +2648,14 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool)if (ret !=-1 )GOTO_FAIL ("dynamic field creation should fail (not avail)" ); + ret =rte_mbuf_dynfield_register (&dynfield_fail_flag); +if (ret !=-1 ) +GOTO_FAIL ("dynamic field creation should fail (invalid flag)" ); + + ret =rte_mbuf_dynflag_register (&dynflag_fail_flag); +if (ret !=-1 ) +GOTO_FAIL ("dynamic flag creation should fail (invalid flag)" ); + flag =rte_mbuf_dynflag_register (&dynflag);if (flag ==-1 ) GOTO_FAIL("failed to register dynamic flag, flag=%d: %s",
lib/mbuf/rte_mbuf_dyn.c +4 -0
@@ -498,6 +498,10 @@ rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *params, {int ret; +if (params->flags !=0 ) { + rte_errno =EINVAL ; +return -1 ; + } if (req >= RTE_SIZEOF_FIELD(struct rte_mbuf, ol_flags) * CHAR_BIT && req !=UINT_MAX ) { rte_errno =EINVAL ;
Signature · 1 line
2.23.0
Quoted 9 lines · On Tue, 12 Oct 2021 21:39:57 +0200 David Marchand <[email protected]>…
As stated in the API, dynamic field and flags should be created with no additional flag (simply in the API for future changes).
Fix the dynamic flag register helper which was not enforcing it and add unit tests.
Fixes 4958ca3a443a ("mbuf: support dynamic fields and flags")Signed-off-by David Marchand <[email protected]>
Andrew Rybchenko
Acked-byQuoted 6 lines · Stephen Hemminger
Quoted 3 lines · On Tue, 12 Oct 2021 21:39:57 +0200 David Marchand <[email protected]>…
As stated in the API, dynamic field and flags should be created with no additional flag (simply in the API for future changes).
Quoted 9 lines
Quoted 6 lines
Fix the dynamic flag register helper which was not enforcing it and add unit tests.
Fixes 4958ca3a443a ("mbuf: support dynamic fields and flags")Signed-off-by David Marchand <[email protected]>
Quoted 7 lines · Andrew Rybchenko
Quoted 6 lines · Stephen Hemminger
Quoted 3 lines · On Tue, 12 Oct 2021 21:39:57 +0200 David Marchand <[email protected]>…
As stated in the API, dynamic field and flags should be created with no additional flag (simply in the API for future changes).
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Fix the dynamic flag register helper which was not enforcing it and add unit tests.
Fixes 4958ca3a443a ("mbuf: support dynamic fields and flags")Signed-off-by David Marchand <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand
Quoted 6 lines · David Marchand
As stated in the API, dynamic field and flags should be created with no additional flag (simply in the API for future changes).
Fix the dynamic flag register helper which was not enforcing it and add unit tests.
Quoted 7 lines
Fixes 4958ca3a443a ("mbuf: support dynamic fields and flags")Signed-off-by David Marchand <[email protected]>--- app/test/test_mbuf.c | 18 ++++++++++++++++++ lib/mbuf/rte_mbuf_dyn.c | 4 ++++ 2 files changed, 22 insertions(+)