From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 0E8255907 for ; Fri, 14 Mar 2014 17:09:18 +0100 (CET) Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2EGAm62012590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Mar 2014 12:10:48 -0400 Received: from x220.localdomain (ovpn-113-176.phx2.redhat.com [10.3.113.176]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id s2EGAmFP014267; Fri, 14 Mar 2014 12:10:48 -0400 Date: Fri, 14 Mar 2014 09:10:47 -0700 From: Chris Wright To: sabu kurian Message-ID: <20140314161047.GD1390@x220.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21+63 (2f2ebc24920d) (2011-07-01) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Segmentation Fault on printf() 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: Fri, 14 Mar 2014 16:09:19 -0000 * sabu kurian (sabu2kurian@gmail.com) wrote: > Hello friends, > > I'm trying to print the ether_type for a packet that I captured from a port > on my machine. Suppose 'm' holds the packet. 'm' is of type 'struct > rte_mbuf'. Intels API reference for DPDK says 'ether_type' is of uint16_t. > I used the following code to retrieve ether_type. > > void * eth_type; > struct ether_hdr *eth; > > eth = rte_pktmbuf_mtod(m, struct ether_hdr *); > eth_type = ð->ether_type; > > printf("\n Type is %" PRIu16 , *((uint16_t *)eth_type)); Looks ok, albeit slightly overly complicated. struct ether_hdr *eth; uint16_t eth_type; eth = rte_pktmbuf_mtod(m, struct ether_hdr *); eth_type = eth->ether_type; printf("\n Type is %" PRIu16 , eth_type)); This would remove all the extra casting. Perhaps the mbuf is the problem here. And if so, the above snippet would segfault on eth->ether_type showing you that mbuf is invalid. You could try to (above mtod): rte_pktmbuf_dump(m, sizeof(struct ether_hdr)); as that will show key contents of mbuf and packet data (and do some basic validation along the way). thanks, -chris