From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 12 18:05:14 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05AA416A417 for ; Tue, 12 Feb 2008 18:05:14 +0000 (UTC) (envelope-from freebsd.dev@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.226]) by mx1.freebsd.org (Postfix) with ESMTP id 76F7213C467 for ; Tue, 12 Feb 2008 18:05:13 +0000 (UTC) (envelope-from freebsd.dev@gmail.com) Received: by wr-out-0506.google.com with SMTP id 68so4586237wri.3 for ; Tue, 12 Feb 2008 10:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=tZwNLr/zDKLD339d3H/Dm8RF46gVI5cRRyz2+lkRdic=; b=m8TgNW9NKxUGtyiYavAP1+YupZsExmJSUjOeVDCNYBt1GxYnWDPsppOGqNCkVLQpOtLxd7y46Orr4u3qJXs8Y1PGVJcBdTa0eujemWiAOydjd3XR7i1a6aS5ncAYhGtTze8fAdVICa7X/HAxF1AIePaJHSnPoH5KxIkSfxJj3Pg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Ae3lpEUM/ThO7UYbH8p9OeN+EI9C1jtLZK0qZiXsj1nmO7BIbGUCT5zwGx+lRnkopAv0nFcr35n3qlJLj5kKfgl7o1Aj9AaE1PgB0joNVXcggHNXw+ldVXrP2HYFxfKkYX4PrZne3vLbwSzGosc/z02ZU9I+VHZMRaiESdYnHAs= Received: by 10.140.147.18 with SMTP id u18mr1141315rvd.202.1202839511244; Tue, 12 Feb 2008 10:05:11 -0800 (PST) Received: by 10.141.20.13 with HTTP; Tue, 12 Feb 2008 10:05:11 -0800 (PST) Message-ID: <50cd4e5f0802121005s191a7875s98ffe2ca512389bc@mail.gmail.com> Date: Tue, 12 Feb 2008 12:05:11 -0600 From: "Biks N" To: "Sam Leffler" In-Reply-To: <47AB7775.2040000@errno.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <50cd4e5f0802071222w1222d901o3ce8770b5f5725b4@mail.gmail.com> <47AB7775.2040000@errno.com> Cc: freebsd-hackers@freebsd.org Subject: Re: retrive data from mbuf chain X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Feb 2008 18:05:14 -0000 Hi, thanks to everyone for providing me with different ideas. First I am trying to use m_copydata() method because I think it will be easy for me to copy data back and forth (using m_copydataback() ). But right now I am having problem using m_copydata() function. I want to copy data in all mbufs (only payload but no tcp/ip header) except the first Mbuf in chain. If payload is small enough to fit within 1st mbuf then I don't need that either. I am getting kernel panic ( please see below). I can see custom message "Starting m_copydata()" in log file. So I assume the problem is due to incorrect parameter in m_copydata(). here is the sample of code I am trying to use: /********************************/ caddr_t my_data_copy = NULL; /* check if m_len < m_pkthdr.len */ if ( m->m_len < m->m_pkthdr.len ) { /* copy data if there are more than 1 Mbufs in Chain */ log (LOG_DEBUG,"Starting m_copydata() \n"); m_copydata( m, m->m_len , m->m_pkthdr.len - m->m_len , my_data_copy); log (LOG_DEBUG,"%d Byte of Data copied\n", m->m_pkthdr.len - m->m_len); } else { /* skip if there is only 1 MBUF */ //log (LOG_DEBUG,"There must Only 1 MBUF in chain\n"); } /********************************/ Kernel Panic: Feb 12 11:36:09 bsd1 /kernel: Fatal trap 12: page fault while in kernel mode Feb 12 11:36:09 bsd1 /kernel: fault virtual address = 0x0 Feb 12 11:36:09 bsd1 /kernel: fault code = supervisor write, page not present Feb 12 11:36:09 bsd1 /kernel: instruction pointer = 0x8:0xc024efc2 Feb 12 11:36:09 bsd1 /kernel: stack pointer = 0x10:0xd15e8d08 Feb 12 11:36:09 bsd1 /kernel: frame pointer = 0x10:0xd15e8d2c Feb 12 11:36:09 bsd1 /kernel: code segment = base 0x0, limit 0xfffff, type 0x1b Feb 12 11:36:09 bsd1 /kernel: = DPL 0, pres 1, def32 1, gran 1 Feb 12 11:36:09 bsd1 /kernel: processor eflags = interrupt enabled, resume, IOPL = 0 Feb 12 11:36:09 bsd1 /kernel: current process = 154 (ping) Feb 12 11:36:09 bsd1 /kernel: interrupt mask = Feb 12 11:36:09 bsd1 /kernel: I am using "ping -s 1200 host" to send larger packets so that system creates at least 2 mbufs. ------------ On Feb 7, 2008 3:26 PM, Sam Leffler wrote: > > Biks N wrote: > > Hi, > > > > I am new to FreeBSD kernel programming. > > > > Currently I am trying to work on mbuf data manupulation. > > > > >From my understanding: data (payload) is stored into one or more mufs > > which are chained together through m_next pointer. > > > > Now, I need to retrive all data in mbuf chain ( mbufs linked by > > m_next). I am working ip_output() in netinet/ip_output.c > > > > Does there exist inbuilt function/macro to retrive all the data in mbuf chain? > > > > man 9 mbuf; look for m_copydata. > > Sam > >