From: Jia Yu Date: Fri, 7 Nov 2014 17:49:15 +0000 (-0800) Subject: kni: add build-time checks for mbuf mapping X-Git-Tag: spdx-start~10171 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5bad0b917ef2c3dc36395bd6af481809b1a017a8;p=dpdk.git kni: add build-time checks for mbuf mapping Adding this check is to avoid breakage from future data structure changes. Signed-off-by: Jia Yu Acked-by: Thomas Monjalon --- diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index ab5ca38284..fdb75094eb 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -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");