From owner-cvs-all Sat Sep 21 10:10: 7 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB57C37B401; Sat, 21 Sep 2002 10:10:04 -0700 (PDT) Received: from ebb.errno.com (ebb.errno.com [66.127.85.87]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2648143E3B; Sat, 21 Sep 2002 10:10:04 -0700 (PDT) (envelope-from sam@errno.com) Received: from melange (melange.errno.com [66.127.85.82]) (authenticated bits=0) by ebb.errno.com (8.12.5/8.12.1) with ESMTP id g8LHA01H084981 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Sat, 21 Sep 2002 10:10:01 -0700 (PDT)?g (envelope-from sam@errno.com)œ X-Authentication-Warning: ebb.errno.com: Host melange.errno.com [66.127.85.82] claimed to be melange Message-ID: <112201c26191$b8ddefe0$52557f42@errno.com> From: "Sam Leffler" To: "Julian Elischer" , "John Baldwin" Cc: "Darren Reed" , , References: Subject: Re: cvs commit: src/sys/kern uipc_mbuf.c Date: Sat, 21 Sep 2002 10:10:00 -0700 Organization: Errno Consulting MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > On Fri, 20 Sep 2002, John Baldwin wrote: > > > > > On 20-Sep-2002 Darren Reed wrote: > > > btw, I think m_length() as a function which does something besides return > > > the length of an mbuf is wrong. I think that kind of task is better delt > > > with by keeping a pointer to the last mbuf in the chain. I'd recommend > > > that m_length() do what it suggests it do and have another one, m_lastbuf() > > > or something to do that job. Well, no, needing m_lastbuf() just sucks > > > bigtime. Some thought to making m_length() a M_LENGTH() might be an idea > > > too (that thought crossed my mind elsewhere), but that'd only fit well if > > > mbufs were fixed up with a tail pointer. > > > > FWIW, I agree with this. If the function name needs to be changed to > > make it more intuitive, so be it. There is nothing intuitive about > > a function named foo_length() not returning the length of 'foo'. > > > > m_iterate() > There is already an m_apply routine in other systems (I pulled in a copy for crypto use): /* * Apply function f to the data in an mbuf chain starting "off" bytes from the * beginning, continuing for "len" bytes. */ extern int m_apply(struct mbuf *m, int off, int len, int (*f)(caddr_t, caddr_t, unsigned int), caddr_t fstate); (and please no comments about caddr_t use). Similarly, a more general alternative to m_length returning a pointer to the last mbuf is m_getptr that takes an mbuf pointer and an offset (in bytes) and returns a pointer to the mbuf that holds data at that offset into the packet and, optionally, a byte offset within that mbuf. struct mbuf *m_getptr(struct mbuf *, int, int *); Rather than haphazardly sticking in new mbuf routines it would be good if *bsd could standardize on some set of base set of routines to improve code portability. At the very least it'd be good to try and add compatible interfaces when trying to replace redundant code with a core routine. Sam To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message