From owner-p4-projects@FreeBSD.ORG Thu Feb 8 18:17:05 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 0A2C216A403; Thu, 8 Feb 2007 18:17:05 +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 A32BE16A400 for ; Thu, 8 Feb 2007 18:17:04 +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 95AA613C4BC for ; Thu, 8 Feb 2007 18:17:04 +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 l18IH414071045 for ; Thu, 8 Feb 2007 18:17:04 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l18IH4CR071042 for perforce@freebsd.org; Thu, 8 Feb 2007 18:17:04 GMT (envelope-from piso@freebsd.org) Date: Thu, 8 Feb 2007 18:17:04 GMT Message-Id: <200702081817.l18IH4CR071042@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 114253 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: Thu, 08 Feb 2007 18:17:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=114253 Change 114253 by piso@piso_newluxor on 2007/02/08 18:16:27 Convert the cu_seeme module to (almost)use mbuf. Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_cuseeme.c#16 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_cuseeme.c#16 (text+ko) ==== @@ -187,7 +187,9 @@ struct cu_header *cu; struct alias_link *cu_lnk; - // XXX broken + PULLUP_SIZE(pip, ptr, (pip->ip_hl << 2) + ntohs(ud->uh_ulen) + + sizeof(struct cu_header)); + ud = ip_next(pip); cu = udp_next(ud); if (cu->addr) cu->addr = (u_int32_t) GetAliasAddress(lnk).s_addr; @@ -212,29 +214,56 @@ struct oc_header *oc; struct client_info *ci; char *end; - int i; + int i, client_count, ci_count, s; +#ifdef _KERNEL + int off; + struct mbuf *m; +#endif (void)la; - PULLUP_UDPHDR(pip, ptr); + PULLUP_IPHDR(pip, ptr); + s = (pip->ip_hl << 2) + sizeof(struct udphdr) + + sizeof(struct oc_header) + sizeof(struct client_info); + PULLUP_SIZE(pip, ptr, s); if (pip == NULL) return; alias_addr.s_addr = pip->ip_dst.s_addr; ud = ip_next(pip); - // XXX broken cu = udp_next(ud); oc = (struct oc_header *)(cu + 1); ci = (struct client_info *)(oc + 1); end = (char *)ud + ntohs(ud->uh_ulen); + client_count = oc->client_count; + ci_count = (ntohs(ud->uh_ulen) - sizeof(struct udphdr) - + sizeof(struct cu_header) - sizeof(struct oc_header)) / + sizeof(struct client_info); if ((char *)oc <= end) { if (cu->dest_addr) cu->dest_addr = (u_int32_t) original_addr.s_addr; if (ntohs(cu->data_type) == 101) /* Find and change our address */ - for (i = 0; (char *)(ci + 1) <= end && i < oc->client_count; i++, ci++) + for (i = 0; i < ci_count && i < client_count; i++) { +#ifdef _KERNEL + m = m_getptr(*ptr, s, &off); + // XXX to avoid crossing mbuf boundary with + // XXX off + sizeof(struct client_info) i should + // XXX m_split(m, off, M_TRYWAIT) first and + // XXX m_pullup(m, sizeof(struct client_info)), + // XXX and m_cat() later but I'm worried about + // XXX performance... + m = m_pullup(m, off + sizeof(struct client_info)); + s += sizeof(struct client_info); + ci = mtod(m, struct client_info *); + ci = (struct client_info *)&(((char *)ci)[off]); +#endif if (ci->address == (u_int32_t) alias_addr.s_addr) { ci->address = (u_int32_t) original_addr.s_addr; break; } +#ifndef _KERNEL + ci++; +#endif + } } }