From owner-p4-projects@FreeBSD.ORG Wed Nov 5 20:29:37 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9585A16A4D0; Wed, 5 Nov 2003 20:29:37 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5990116A4CE for ; Wed, 5 Nov 2003 20:29:37 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B157343F75 for ; Wed, 5 Nov 2003 20:29:36 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hA64TaXJ083241 for ; Wed, 5 Nov 2003 20:29:36 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hA64TaET083238 for perforce@freebsd.org; Wed, 5 Nov 2003 20:29:36 -0800 (PST) (envelope-from sam@freebsd.org) Date: Wed, 5 Nov 2003 20:29:36 -0800 (PST) Message-Id: <200311060429.hA64TaET083238@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 41556 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2003 04:29:38 -0000 X-List-Received-Date: Thu, 06 Nov 2003 04:29:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=41556 Change 41556 by sam@sam_ebb on 2003/11/05 20:29:12 When tcp_respond is given a tcp control block the associated inpcb must be locked in case the path through ip_output modifies it's contents (e.g. to change the route); assert this. While here cleanup code that references the inpcb. Affected files ... .. //depot/projects/netperf/sys/netinet/tcp_subr.c#9 edit Differences ... ==== //depot/projects/netperf/sys/netinet/tcp_subr.c#9 (text+ko) ==== @@ -378,6 +378,7 @@ int isipv6; #endif /* INET6 */ int ipflags = 0; + struct inpcb *inp; KASSERT(tp != NULL || m != NULL, ("tcp_respond: tp and m both NULL")); @@ -388,18 +389,23 @@ ip = ipgen; if (tp) { + inp = tp->t_inpcb; + KASSERT(inp != NULL, ("tcp control block w/o inpcb")); + INP_INFO_WLOCK_ASSERT(&tcpcbinfo); + INP_LOCK_ASSERT(inp); if (!(flags & TH_RST)) { - win = sbspace(&tp->t_inpcb->inp_socket->so_rcv); + win = sbspace(&inp->inp_socket->so_rcv); if (win > (long)TCP_MAXWIN << tp->rcv_scale) win = (long)TCP_MAXWIN << tp->rcv_scale; } #ifdef INET6 if (isipv6) - ro6 = &tp->t_inpcb->in6p_route; + ro6 = &inp->in6p_route; else #endif /* INET6 */ - ro = &tp->t_inpcb->inp_route; + ro = &inp->inp_route; } else { + inp = NULL; #ifdef INET6 if (isipv6) { ro6 = &sro6; @@ -480,12 +486,12 @@ m->m_pkthdr.len = tlen; m->m_pkthdr.rcvif = (struct ifnet *) 0; #ifdef MAC - if (tp != NULL && tp->t_inpcb != NULL) { + if (inp != NULL) { /* * Packet is associated with a socket, so allow the * label of the response to reflect the socket label. */ - mac_create_mbuf_from_socket(tp->t_inpcb->inp_socket, m); + mac_create_mbuf_from_socket(inp->inp_socket, m); } else { /* * Packet is not associated with a socket, so possibly @@ -510,7 +516,7 @@ nth->th_sum = in6_cksum(m, IPPROTO_TCP, sizeof(struct ip6_hdr), tlen - sizeof(struct ip6_hdr)); - ip6->ip6_hlim = in6_selecthlim(tp ? tp->t_inpcb : NULL, + ip6->ip6_hlim = in6_selecthlim(inp, ro6 && ro6->ro_rt ? ro6->ro_rt->rt_ifp : NULL); @@ -523,26 +529,25 @@ m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); } #ifdef TCPDEBUG - if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) + if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG)) tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0); #endif #ifdef INET6 if (isipv6) { - (void)ip6_output(m, NULL, ro6, ipflags, NULL, NULL, - tp ? tp->t_inpcb : NULL); + (void) ip6_output(m, NULL, ro6, ipflags, NULL, NULL, inp); if (ro6 == &sro6 && ro6->ro_rt) { RTFREE(ro6->ro_rt); ro6->ro_rt = NULL; } } else #endif /* INET6 */ - { - (void) ip_output(m, NULL, ro, ipflags, NULL, tp ? tp->t_inpcb : NULL); - if (ro == &sro && ro->ro_rt) { - RTFREE(ro->ro_rt); - ro->ro_rt = NULL; + { + (void) ip_output(m, NULL, ro, ipflags, NULL, inp); + if (ro == &sro && ro->ro_rt) { + RTFREE(ro->ro_rt); + ro->ro_rt = NULL; + } } - } } /*