From owner-p4-projects@FreeBSD.ORG Tue Feb 13 16:16:20 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 98FF116A401; Tue, 13 Feb 2007 16:16:20 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 552AE16A420 for ; Tue, 13 Feb 2007 16:16:20 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 32FDB13C48E for ; Tue, 13 Feb 2007 16:16:20 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l1DGGKhI064061 for ; Tue, 13 Feb 2007 16:16:20 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l1DGGJIX064058 for perforce@freebsd.org; Tue, 13 Feb 2007 16:16:19 GMT (envelope-from piso@freebsd.org) Date: Tue, 13 Feb 2007 16:16:19 GMT Message-Id: <200702131616.l1DGGJIX064058@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to piso@freebsd.org using -f From: Paolo Pisati To: Perforce Change Reviews Cc: Subject: PERFORCE change 114456 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Feb 2007 16:16:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=114456 Change 114456 by piso@piso_newluxor on 2007/02/13 16:15:24 Make irc module (almost) groks mbuf: unfortunately, using a normal mbuf was too much of a pain with the current code, so i had to resort to a contiguous buffer of memory. Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_irc.c#19 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_irc.c#19 (text+ko) ==== @@ -170,6 +170,9 @@ struct ip *pip; struct tcphdr *tc; int i; /* Iterator through the source */ +#ifdef _KERNEL + char mpkt[65536]; +#endif /* Calculate data length of TCP packet */ PULLUP_TCPHDR(pip, ptr); @@ -188,9 +191,34 @@ return; /* Place string pointer at beginning of data */ - // XXX broken +#ifdef _KERNEL + /* + * XXX first we copy the entire mbuf chain content (minus ip+tcp hdr) + * into a contiguos buffer of memory and later, when we've finished + * to operate on the buffer, we copy back buffer's content into + * the mbuf. + * In case the copy operations are too expensive, we could avoid + * one using the mbuf as the contiguos buffer of memory: + * + * o pkt < MHLEN: pullup the entire pkt in the mbuf data sect + * o MHLEN < pkt < 2k: use a normal mbuf cluster + * o 2k < pkt < 4k: use a 4k mbuf cluster (jumbo) + * o 4k < pkt < 9k: use a 9k mbuf cluster (jumbo9) + * o 9k < pkt < 16k: use a 16k mbuf cluster (jumbo16) + * o pkt > 16k: use mpkt buffer (worst case) + * + * WATCH OUT: pkt could grow, so beware of boundaries in case + * an mbuf/mbuf cluster is used, check maxsize. + */ + + // XXX so far only the worst case is implemented... + m_copydata(*ptr, hlen, m_length(*ptr, NULL), mpkt); + sptr = mpkt; + maxsize = 65536; /* size of mpkt */ +#else sptr = (char *)pip; sptr += hlen; +#endif maxsize -= hlen; /* We're interested in maximum size of * data, not packet */ @@ -433,6 +461,9 @@ lPACKET_DONE: iCopy = iCopy > maxsize - copyat ? maxsize - copyat : iCopy; memcpy(sptr + copyat, newpacket, iCopy); +#ifdef _KERNEL + m_copyback(*ptr, hlen, iCopy + copyat, sptr); +#endif /* Save information regarding modified seq and ack numbers */ {