From owner-freebsd-net@FreeBSD.ORG Thu Oct 20 12:13:58 2005 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2F15216A41F for ; Thu, 20 Oct 2005 12:13:58 +0000 (GMT) (envelope-from kamal_ckk@yahoo.com) Received: from web35712.mail.mud.yahoo.com (web35712.mail.mud.yahoo.com [66.163.179.166]) by mx1.FreeBSD.org (Postfix) with SMTP id C796543D62 for ; Thu, 20 Oct 2005 12:13:57 +0000 (GMT) (envelope-from kamal_ckk@yahoo.com) Received: (qmail 37164 invoked by uid 60001); 20 Oct 2005 12:13:57 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=sRO4KoQhrbGeAAd5jEON+UFiXHOAh3/MiGp9lJ0/WpTNY/zQW0K2eEIZ6K6AbJRprXcwzDn6UChPButpMoeJuCNsZcyz+Hvi7Zn7MKcOltAz26OzBmC8pNwTXzonh/eOQs1yckBWxyotoNKyqnqrw/7GrLn3wx17uN/9Ii85xWc= ; Message-ID: <20051020121357.37162.qmail@web35712.mail.mud.yahoo.com> Received: from [202.79.62.15] by web35712.mail.mud.yahoo.com via HTTP; Thu, 20 Oct 2005 05:13:57 PDT Date: Thu, 20 Oct 2005 05:13:57 -0700 (PDT) From: kamal kc To: freebsd MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: mbuf passed to if_output() in ip_output() X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Oct 2005 12:13:58 -0000 dear everybody, i have encountered a problem big enough for me to handle. Actually i am trying to compress the data contained in the ip packets. i see that the data to be passed by ip to link layer output routine is contained in mbuf *m. Now what i tried to do is I tried to copy the original mbufs to newer mbufs and passed the newer mbufs to the if_output() instead of the older ones. And I tried to release the older mbufs myself. For this purpose i wrote the routine below. But it doesn't seem to work. The problem I encounter is the mbuf in the ip_output doesnot seem to be released and gets printed(by my custom routine) infinitely. What is the problem ??? Please help kamal PS. i have put the code with which i tried to replace the original mbufs void copy_the_memorybuffer(struct mbuf **m) { struct mbuf *tmp_mbuf; struct mbuf *mbuf_pointer=*m; //original mbuf header struct mbuf **mnext; struct mbuf **second_mbuf_pointer; struct mbuf **second_packet_pointer; struct mbuf **next_packet; unsigned int ipheaderlength; unsigned int packet_length; unsigned char *ip_char_buffer; int i; //loop variable second_packet_pointer=&mbuf_pointer->m_nextpkt; next_packet=&mbuf_pointer->m_nextpkt; for(;*next_packet;*next_packet=(*next_packet)->m_nextpkt) { if(((*next_packet)->m_flags & M_PKTHDR)!=0) { struct ip *dest_ip; dest_ip=mtod((*next_packet),struct ip *); dest_ip->ip_tos=66; printf("\nDestination ip (next_packet)=%s\n",inet_ntoa(dest_ip->ip_dst)); } second_mbuf_pointer=&(*next_packet)->m_next; mnext=&(*next_packet)->m_next; //keep the first packet as it is for(;*mnext;*mnext=(*mnext)->m_next) //loop until the end of memory buffer { printf("\ninside the for loop(mnext)\n"); if(((*mnext)->m_flags & M_PKTHDR)!=0) //this is the start of the packet { MGETHDR(tmp_mbuf,M_WAIT,(*mnext)->m_type); if(((*mnext)->m_flags & M_EXT)!=0) //uses a cluster MCLGET(tmp_mbuf,M_WAIT); struct ip *my_ip; my_ip=mtod(*mnext,struct ip *); my_ip->ip_tos=55; printf("\nDestination ip=%s\n",inet_ntoa(my_ip->ip_dst)); ipheaderlength=my_ip->ip_hl<<2; //4*ip header length= real header length packet_length=(*mnext)->m_len; ip_char_buffer=(unsigned char *)my_ip; for(i=0;im_data[i]=(*mnext)->m_data[i]; } for(i=ipheaderlength;im_data[i]=(*mnext)->m_data[i]; } tmp_mbuf->m_pkthdr.len=(*mnext)->m_pkthdr.len; tmp_mbuf->m_pkthdr.rcvif=(struct ifnet *)0; tmp_mbuf->m_pkthdr.header=(*mnext)->m_pkthdr.header; tmp_mbuf->m_pkthdr.csum_flags=(*mnext)->m_pkthdr.csum_flags; tmp_mbuf->m_pkthdr.csum_data=(*mnext)->m_pkthdr.csum_data; } else //the mbuf is not the packet header so it does not contain the ip header { MGET(tmp_mbuf,M_WAIT,(*mnext)->m_type); if(((*mnext)->m_flags & M_EXT)!=0) MCLGET(tmp_mbuf,M_WAIT); packet_length=(*mnext)->m_len; for(i=0;im_data[i]=(*mnext)->m_data[i]; } } tmp_mbuf->m_len=(*mnext)->m_len; tmp_mbuf->m_flags=(*mnext)->m_flags; tmp_mbuf->m_nextpkt=(*mnext)->m_nextpkt; tmp_mbuf->m_next=(*mnext)->m_next; *mnext=tmp_mbuf; } m_freem(*second_mbuf_pointer); } *m=mbuf_pointer; return; } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com