librte_kni: Add buildtime checks for rte_kni_mbuf and rte_mbuf
PATCH 1/1 librte_kni: Add buildtime checks for rte_kni_mbuf and rte_mbuf
Adding this check is to avoid breakage from future data structure changes.
Signed-off-by Jia Yu <[email protected]>
--- lib/librte_kni/rte_kni.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_kni/rte_kni.c +15 -0
@@ -595,6 +595,21 @@ kni_allocate_mbufs(struct rte_kni *kni)int i, ret;struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM ]; +RTE_BUILD_BUG_ON (offsetof(struct rte_mbuf , pool) != + offsetof(struct rte_kni_mbuf , pool)); +RTE_BUILD_BUG_ON (offsetof(struct rte_mbuf , buf_addr) != + offsetof(struct rte_kni_mbuf , buf_addr)); +RTE_BUILD_BUG_ON (offsetof(struct rte_mbuf , next) != + offsetof(struct rte_kni_mbuf , next)); +RTE_BUILD_BUG_ON (offsetof(struct rte_mbuf , data_off) != + offsetof(struct rte_kni_mbuf , data_off)); +RTE_BUILD_BUG_ON (offsetof(struct rte_mbuf , data_len) != + offsetof(struct rte_kni_mbuf , data_len)); +RTE_BUILD_BUG_ON (offsetof(struct rte_mbuf , pkt_len) != + offsetof(struct rte_kni_mbuf , pkt_len)); +RTE_BUILD_BUG_ON (offsetof(struct rte_mbuf , ol_flags) != + offsetof(struct rte_kni_mbuf , ol_flags)); +/* Check if pktmbuf pool has been configured */ if (kni->pktmbuf_pool ==NULL ) {RTE_LOG (ERR ,KNI ,"No valid mempool for allocating mbufs\n" );
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): 1415382555-43748-1-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org
Quoted 3 lines
Adding this check is to avoid breakage from future data structure changes.
Signed-off-by Jia Yu <[email protected]>
Excellent idea!
Acked-by Thomas Monjalon <[email protected]>
Applied
Thanks
Signature · 1 line
Thomas