Date: Tue, 13 Feb 2007 16:16:19 GMT From: Paolo Pisati <piso@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 114456 for review Message-ID: <200702131616.l1DGGJIX064058@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 */ {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702131616.l1DGGJIX064058>