From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qg0-x22e.google.com (mail-qg0-x22e.google.com [IPv6:2607:f8b0:400d:c04::22e]) by dpdk.org (Postfix) with ESMTP id D3DE368BB for ; Sun, 16 Mar 2014 14:01:49 +0100 (CET) Received: by mail-qg0-f46.google.com with SMTP id e89so13342648qgf.5 for ; Sun, 16 Mar 2014 06:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=tgnObDInhj1CxEpOsY25QyoCdyefe+PnGaqEaZaLthA=; b=VISCN8nBO0u4W/CWnEljenoYSIt60P0UTn6eO7vD0u25PjdBaMm36SGFSxO2cPB+KU g4tD5SH6KAgF14Uz4velnDdN1hFUoOP2UK/dKviznJHKF9DztqLcbPYvYUnkZ0vfRWMk 60QZSksQnJ4dw3rX6e22H2elo2DnDMbqJlSpO79JoPP76KOmL45y0wP/UwfxqN1U0lxM HdFw8tbBsn1zS4IE5eIVpF/ASCSFFL5ymBNJO79JQ3dJmVBX+LGDQpiWgdApVD6xb5QU lxeV+Wzy/Rr8mFdZOXWtZeLU5teTVslgEZmgYCKze2IDmlVUDdg5CQtzyQ+Wuti8ilsx 0s2Q== MIME-Version: 1.0 X-Received: by 10.140.88.80 with SMTP id s74mr20817204qgd.74.1394975000890; Sun, 16 Mar 2014 06:03:20 -0700 (PDT) Received: by 10.96.69.97 with HTTP; Sun, 16 Mar 2014 06:03:20 -0700 (PDT) In-Reply-To: <20140314161047.GD1390@x220.localdomain> References: <20140314161047.GD1390@x220.localdomain> Date: Sun, 16 Mar 2014 18:33:20 +0530 Message-ID: From: sabu kurian To: Chris Wright Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 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: Sun, 16 Mar 2014 13:01:50 -0000 Hello chris, Thanks for your reply. I tried dumping the contents of mbuf as you have suggested. This is what I get: dump mbuf at 0x0x6c7620, phys=7f34d91eba28, buf_len=59488 pkt_len=0, ol_flags=0, nb_segs=0, in_port=0 and soon after that I get a segmentation fault. Do you have any idea on what could be causing it ? Regards On Fri, Mar 14, 2014 at 9:40 PM, Chris Wright wrote: > * 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 >