Index:ipf/ip_state.c

--- ip_state-4.1.23.c	Sat May 26 23:05:14 2007
+++ ip_state-4.1.23a.c	Wed Jul  4 19:08:49 2007
@@ -1402,77 +1402,77 @@
 /* ------------------------------------------------------------------------ */
 /* Function:    fr_tcpstate                                                 */
 /* Returns:     int - 1 == packet matches state entry, 0 == it does not     */
 /* Parameters:  fin(I)   - pointer to packet information                    */
 /*              tcp(I)   - pointer to TCP packet header                     */
 /*              is(I)  - pointer to master state structure                  */
 /*                                                                          */
 /* Check to see if a packet with TCP headers fits within the TCP window.    */
 /* Change timeout depending on whether new packet is a SYN-ACK returning    */
 /* for a SYN or a RST or FIN which indicate time to close up shop.          */
 /* ------------------------------------------------------------------------ */
 static int fr_tcpstate(fin, tcp, is)
 fr_info_t *fin;
 tcphdr_t *tcp;
 ipstate_t *is;
 {
 	int source, ret = 0, flags;
 	tcpdata_t  *fdata, *tdata;
 
 	source = !fin->fin_rev;
 	if (((is->is_flags & IS_TCPFSM) != 0) && (source == 1) && 
 	    (ntohs(is->is_sport) != fin->fin_data[0]))
 		source = 0;
 	fdata = &is->is_tcp.ts_data[!source];
 	tdata = &is->is_tcp.ts_data[source];
 
 	MUTEX_ENTER(&is->is_lock);
 
 	/*
 	 * If a SYN packet is received for a connection that is on the way out
 	 * but hasn't yet departed then advance this session along the way.
 	 */
 	if ((tcp->th_flags & TH_OPENING) == TH_SYN) {
 		if ((is->is_state[0] > IPF_TCPS_ESTABLISHED) &&
 		    (is->is_state[1] > IPF_TCPS_ESTABLISHED)) {
 			is->is_state[!source] = IPF_TCPS_CLOSED;
 			fr_movequeue(&is->is_sti, is->is_sti.tqe_ifq,
 				     &ips_deletetq);
-			MUTEX_ENTER(&is->is_lock);
+			MUTEX_EXIT(&is->is_lock);
 			return 0;
 		}
 	}
 
 	if (fr_tcpinwindow(fin, fdata, tdata, tcp, is->is_flags)) {
 #ifdef	IPFILTER_SCAN
 		if (is->is_flags & (IS_SC_CLIENT|IS_SC_SERVER)) {
 			ipsc_packet(fin, is);
 			if (FR_ISBLOCK(is->is_pass)) {
 				MUTEX_EXIT(&is->is_lock);
 				return 1;
 			}
 		}
 #endif
 
 		/*
 		 * Nearing end of connection, start timeout.
 		 */
 		ret = fr_tcp_age(&is->is_sti, fin, ips_tqtqb, is->is_flags);
 		if (ret == 0) {
 			MUTEX_EXIT(&is->is_lock);
 			return 0;
 		}
 
 		/*
 		 * set s0's as appropriate.  Use syn-ack packet as it
 		 * contains both pieces of required information.
 		 */
 		/*
 		 * Window scale option is only present in SYN/SYN-ACK packet.
 		 * Compare with ~TH_FIN to mask out T/TCP setups.
 		 */
 		flags = tcp->th_flags & ~(TH_FIN|TH_ECNALL);
 		if (flags == (TH_SYN|TH_ACK)) {
 			is->is_s0[source] = ntohl(tcp->th_ack);
 			is->is_s0[!source] = ntohl(tcp->th_seq) + 1;
 			if ((TCP_OFF(tcp) > (sizeof(tcphdr_t) >> 2))) {
 				if (fr_tcpoptions(fin, tcp, fdata) == -1)
