Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Dec 1998 23:08:14 +1100 (EST)
From:      Darren Reed <darrenr@reed.wattle.id.au>
To:        kev@lab321.ru (Eugeny Kuzakov)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: 2.2.8&ipfilter 3.2.10 panics
Message-ID:  <199812061208.XAA10143@avalon.reed.wattle.id.au>
In-Reply-To: <Pine.BSF.4.02.9812061619200.5034-100000@lab321.ru> from "Eugeny Kuzakov" at Dec 6, 98 04:20:06 pm

next in thread | previous in thread | raw e-mail | index | archive | help
In some email I received from Eugeny Kuzakov, sie wrote:
> 
> On Sun, 6 Dec 1998, Darren Reed wrote:
> 
> > There's a patch recently posted to the IP Filter mailling list which uses
> > in_cksum() inside of fr_tcpsum() and solves this problem.
> Can anyone say me mailing list archive location or this patch ?
> 10tx.

The web page version is `messy'...and I can't update the ftp site right
now so see below.

darren

Index: fil.c
===================================================================
RCS file: /devel/CVS/IP-Filter/fil.c,v
retrieving revision 2.0.2.41.2.27
retrieving revision 2.0.2.41.2.29
diff -c fil.c.orig fil.c
*** /tmp/T00GMcpW	Sun Dec  6 23:06:48 1998
--- /tmp/T10Iie8o	Sun Dec  6 23:06:48 1998
***************
*** 7,13 ****
   */
  #if !defined(lint)
  static const char sccsid[] = "@(#)fil.c	1.36 6/5/96 (C) 1993-1996 Darren Reed";
! static const char rcsid[] = "@(#)$Id: fil.c,v 2.0.2.41.2.27 1998/11/22 01:50:15 darrenr Exp $";
  #endif
  
  #include <sys/errno.h>
--- 7,13 ----
   */
  #if !defined(lint)
  static const char sccsid[] = "@(#)fil.c	1.36 6/5/96 (C) 1993-1996 Darren Reed";
! static const char rcsid[] = "@(#)$Id: fil.c,v 2.0.2.41.2.29 1998/11/28 02:25:25 darrenr Exp $";
  #endif
  
  #include <sys/errno.h>
***************
*** 949,955 ****
--- 949,1028 ----
  ip_t *ip;
  tcphdr_t *tcp;
  int len;
+ #if SOLARIS || defined(KERNEL) && ((defined(BSD) || defined(sun)))
+ # if SOLARIS
  {
+ 	struct ip ipd, *ipp = &ipd;
+ 	mblk_t mb, *mp = &mb;
+ 	struct datab db, *dp = &db;
+ 	u_short sum;
+ 	int hlen;
+ 
+ 	bzero((char *)dp, sizeof(*dp));
+ 	bzero((char *)mp, sizeof(*mp));
+ 	dp->db_type = M_DATA;
+ 	dp->db_base = (u_char *)ipp;
+ 	mp->b_rptr = dp->db_base;
+ 	mp->b_wptr = dp->db_base + sizeof(*ipp);
+ 	mp->b_datap = dp;
+ 
+ 	hlen = ip->ip_hl << 2;
+ 
+ 	ipp->ip_src = ip->ip_src;
+ 	ipp->ip_dst = ip->ip_dst;
+ 	ipp->ip_p = ip->ip_p;
+ 	ipp->ip_len = htons(ip->ip_len);
+ 	m->b_rptr += hlen;
+ #ifdef	_KERNEL
+ 	sum = IP_CSUM(mp, len, 0);
+ #else
+ 	sum = 0;
+ #endif
+ 	m->b_rptr -= hlen;
+ 	return sum;
+ }
+ # else
+ #  if (defined(BSD) || defined(sun))
+ {
+ 	struct ip *ipp;
+ 	struct mbuf mb, *mp = &mb;
+ 	u_short sum;
+ 	int hlen;
+ 
+ 	bzero((char *)mp, sizeof(*mp));
+ 	hlen = ip->ip_hl << 2;
+ 	mp->m_next = m;
+ 	mp->m_len = hlen;
+ 	mp->m_type = MT_DATA;
+ #   if BSD >= 199306
+ 	mp->m_data = mp->m_dat;
+ #   else
+ 	mp->m_off = MMINOFF;
+ #   endif
+ 	ipp = mtod(mp, struct ip *);
+ 	ipp->ip_src = ip->ip_src;
+ 	ipp->ip_dst = ip->ip_dst;
+ 	ipp->ip_p = ip->ip_p;
+ 	ipp->ip_len = htons(ip->ip_len);
+ 	m->m_len -= hlen;
+ #   if BSD >= 199306
+ 	m->m_data += hlen;
+ #   else
+ 	m->m_off += hlen;
+ #   endif
+ 	sum = in_cksum(mp, len);
+ 	m->m_len += hlen;
+ #   if BSD >= 199306
+ 	m->m_data -= hlen;
+ #   else
+ 	m->m_off -= hlen;
+ #   endif
+ 	return sum;
+ }
+ #  endif /* BSD || sun */
+ # endif /* SOLARIS */
+ #else /* KERNEL */
+ {
  	union {
  		u_char	c[2];
  		u_short	s;
***************
*** 956,962 ****
  	} bytes;
  	u_32_t sum;
  	u_short	*sp, slen;
! # if SOLARIS || defined(__sgi)
  	int add, hlen;
  # endif
  
--- 1029,1035 ----
  	} bytes;
  	u_32_t sum;
  	u_short	*sp, slen;
! # if defined(__sgi)
  	int add, hlen;
  # endif
  
***************
*** 985,1015 ****
  	sp += 2;	/* Skip over checksum */
  	sum += *sp++;	/* urp */
  
! #if SOLARIS
  	/*
- 	 * In case we had to copy the IP & TCP header out of mblks,
- 	 * skip over the mblk bits which are the header
- 	 */
- 	if ((caddr_t)ip != (caddr_t)m->b_rptr) {
- 		hlen = (caddr_t)sp - (caddr_t)ip;
- 		while (hlen) {
- 			add = MIN(hlen, m->b_wptr - m->b_rptr);
- 			sp = (u_short *)((caddr_t)m->b_rptr + add);
- 			hlen -= add;
- 			if ((caddr_t)sp >= (caddr_t)m->b_wptr) {
- 				m = m->b_cont;
- 				if (!hlen) {
- 					if (!m)
- 						break;
- 					sp = (u_short *)m->b_rptr;
- 				}
- 				PANIC((!m),("fr_tcpsum(1): not enough data"));
- 			}
- 		}
- 	}
- #endif
- #ifdef	__sgi
- 	/*
  	 * In case we had to copy the IP & TCP header out of mbufs,
  	 * skip over the mbuf bits which are the header
  	 */
--- 1058,1065 ----
  	sp += 2;	/* Skip over checksum */
  	sum += *sp++;	/* urp */
  
! # ifdef	__sgi
  	/*
  	 * In case we had to copy the IP & TCP header out of mbufs,
  	 * skip over the mbuf bits which are the header
  	 */
***************
*** 1030,1056 ****
  			}
  		}
  	}
! #endif
  
  	if (!(len -= sizeof(*tcp)))
  		goto nodata;
  	while (len > 1) {
- #if SOLARIS
- 		if ((caddr_t)sp >= (caddr_t)m->b_wptr) {
- 			m = m->b_cont;
- 			PANIC((!m),("fr_tcpsum(2): not enough data"));
- 			sp = (u_short *)m->b_rptr;
- 		}
- 		if ((caddr_t)(sp + 1) > (caddr_t)m->b_wptr) {
- 			bytes.c[0] = *(u_char *)sp;
- 			m = m->b_cont;
- 			PANIC((!m),("fr_tcpsum(3): not enough data"));
- 			sp = (u_short *)m->b_rptr;
- 			bytes.c[1] = *(u_char *)sp;
- 			sum += bytes.s;
- 			sp = (u_short *)((u_char *)sp + 1);
- 		}
- #else
  		if (((caddr_t)sp - mtod(m, caddr_t)) >= m->m_len) {
  			m = m->m_next;
  			PANIC((!m),("fr_tcpsum(2): not enough data"));
--- 1080,1090 ----
  			}
  		}
  	}
! # endif
  
  	if (!(len -= sizeof(*tcp)))
  		goto nodata;
  	while (len > 1) {
  		if (((caddr_t)sp - mtod(m, caddr_t)) >= m->m_len) {
  			m = m->m_next;
  			PANIC((!m),("fr_tcpsum(2): not enough data"));
***************
*** 1065,1071 ****
  			sum += bytes.s;
  			sp = (u_short *)((u_char *)sp + 1);
  		}
- #endif /* SOLARIS */
  		if ((u_long)sp & 1) {
  			bcopy((char *)sp++, (char *)&bytes.s, sizeof(bytes.s));
  			sum += bytes.s;
--- 1099,1104 ----
***************
*** 1081,1086 ****
--- 1114,1120 ----
  	sum = (u_short)(~sum & 0xffff);
  	return sum;
  }
+ #endif /* KERNEL */
  
  
  #if defined(_KERNEL) && ( ((BSD < 199306) && !SOLARIS) || defined(__sgi) )
***************
*** 1117,1123 ****
   * SUCH DAMAGE.
   *
   *	@(#)uipc_mbuf.c	8.2 (Berkeley) 1/4/94
!  * $Id: fil.c,v 2.0.2.41.2.27 1998/11/22 01:50:15 darrenr Exp $
   */
  /*
   * Copy data from an mbuf chain starting "off" bytes from the beginning,
--- 1151,1157 ----
   * SUCH DAMAGE.
   *
   *	@(#)uipc_mbuf.c	8.2 (Berkeley) 1/4/94
!  * $Id: fil.c,v 2.0.2.41.2.29 1998/11/28 02:25:25 darrenr Exp $
   */
  /*
   * Copy data from an mbuf chain starting "off" bytes from the beginning,

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812061208.XAA10143>