From owner-p4-projects@FreeBSD.ORG Wed Apr 16 15:25:06 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 72CFA37B404; Wed, 16 Apr 2003 15:25:06 -0700 (PDT) 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 1215F37B401 for ; Wed, 16 Apr 2003 15:25:06 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 11AA543FAF for ; Wed, 16 Apr 2003 15:25:05 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h3GMP40U016129 for ; Wed, 16 Apr 2003 15:25:04 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h3GMP4r9016126 for perforce@freebsd.org; Wed, 16 Apr 2003 15:25:04 -0700 (PDT) Date: Wed, 16 Apr 2003 15:25:04 -0700 (PDT) Message-Id: <200304162225.h3GMP4r9016126@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 29098 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: Wed, 16 Apr 2003 22:25:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=29098 Change 29098 by rwatson@rwatson_tislabs on 2003/04/16 15:24:52 Add socket and mbuf arguments to tcp_twrespond(): this guarantees us a source of a label for use when generating a TCP packet. This prevent panics due to a lack of a useful label in the resulting mbuf. Affected files ... .. //depot/projects/trustedbsd/mac/sys/netinet/tcp_input.c#37 edit .. //depot/projects/trustedbsd/mac/sys/netinet/tcp_subr.c#30 edit .. //depot/projects/trustedbsd/mac/sys/netinet/tcp_var.h#11 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/netinet/tcp_input.c#37 (text+ko) ==== @@ -2931,7 +2931,7 @@ */ if (thflags != TH_ACK || tlen != 0 || th->th_seq != tw->rcv_nxt || th->th_ack != tw->snd_nxt) - tcp_twrespond(tw, TH_ACK); + tcp_twrespond(tw, NULL, m, TH_ACK); goto drop; reset: ==== //depot/projects/trustedbsd/mac/sys/netinet/tcp_subr.c#30 (text+ko) ==== @@ -1648,16 +1648,16 @@ } tcp_discardcb(tp); so = inp->inp_socket; - so->so_pcb = NULL; tw->tw_cred = crhold(so->so_cred); tw->tw_so_options = so->so_options; + if (acknow) + tcp_twrespond(tw, so, NULL, TH_ACK); + so->so_pcb = NULL; sotryfree(so); inp->inp_socket = NULL; inp->inp_ppcb = (caddr_t)tw; inp->inp_vflag |= INP_TIMEWAIT; tcp_timer_2msl_reset(tw, tw_time); - if (acknow) - tcp_twrespond(tw, TH_ACK); INP_UNLOCK(inp); } @@ -1684,19 +1684,12 @@ } /* - * XXXMAC: Really, we need to pass in the mbuf we are responding to - * so that we have a label to assign to the outgoing packet here. - * Question: will one always be available? Should we pass in the - * socket in the twstart case? Perhaps: - * - * tcp_twrespond(struct tcptw *tw, struct socket *so, struct mbuf *m, - * int flags) - * - * Where one of the socket or mbuf must be non-NULL so as to provide - * a label. + * One of so and msrc must be non-NULL for use by the MAC Framework to + * construct a label for ay resulting packet. */ int -tcp_twrespond(struct tcptw *tw, int flags) +tcp_twrespond(struct tcptw *tw, struct socket *so, struct mbuf *msrc, + int flags) { struct inpcb *inp = tw->tw_inpcb; struct tcphdr *th; @@ -1710,19 +1703,20 @@ int isipv6 = inp->inp_inc.inc_isipv6; #endif + KASSERT(so != NULL || msrc != NULL, + ("tcp_twrespond: so and msrc NULL")); + m = m_gethdr(M_DONTWAIT, MT_HEADER); if (m == NULL) return (ENOBUFS); m->m_data += max_linkhdr; -#if 0 #ifdef MAC if (so != NULL) mac_create_mbuf_from_socket(so, m); else mac_create_mbuf_netlayer(msrc, m); #endif -#endif #ifdef INET6 if (isipv6) { ==== //depot/projects/trustedbsd/mac/sys/netinet/tcp_var.h#11 (text+ko) ==== @@ -490,7 +490,7 @@ tcp_quench(struct inpcb *, int); void tcp_respond(struct tcpcb *, void *, struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int); -int tcp_twrespond(struct tcptw *, int); +int tcp_twrespond(struct tcptw *, struct socket *, struct mbuf *, int); struct rtentry * tcp_rtlookup(struct in_conninfo *); void tcp_setpersist(struct tcpcb *);