From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-outbound-2.vmware.com (smtp-outbound-2.vmware.com [208.91.2.13]) by dpdk.org (Postfix) with ESMTP id D8553591A for ; Sat, 8 Nov 2014 02:48:18 +0100 (CET) Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 7A0002866A for ; Fri, 7 Nov 2014 17:57:40 -0800 (PST) Received: from prmh-edge-ivybridge-13.eng.vmware.com (prmh-edge-ivybridge-13.eng.vmware.com [10.24.235.96]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 7513719BBA; Fri, 7 Nov 2014 17:57:40 -0800 (PST) From: Jia Yu To: dev@dpdk.org Date: Fri, 7 Nov 2014 09:49:15 -0800 Message-Id: <1415382555-43748-1-git-send-email-jyu@vmware.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] librte_kni: Add buildtime checks for rte_kni_mbuf and rte_mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Nov 2014 01:48:19 -0000 Adding this check is to avoid breakage from future data structure changes. Signed-off-by: Jia Yu --- lib/librte_kni/rte_kni.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 31ecb33..f5c449c 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"); -- 1.9.1