Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 May 2014 20:27:57 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r266192 - stable/9/sys/netinet
Message-ID:  <201405152027.s4FKRvGI088188@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Thu May 15 20:27:57 2014
New Revision: 266192
URL: http://svnweb.freebsd.org/changeset/base/266192

Log:
  MFC r265691, r265713:
  
  For some UDP packets (for example with 200 byte payload) and IP options,
  the IP header and the UDP header are not in the same mbuf.
  Add code to in_delayed_cksum() to deal with this case.
  
  Use KASSERTs as suggested by glebius@

Modified:
  stable/9/sys/netinet/ip_output.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/ip_output.c
==============================================================================
--- stable/9/sys/netinet/ip_output.c	Thu May 15 20:24:51 2014	(r266191)
+++ stable/9/sys/netinet/ip_output.c	Thu May 15 20:27:57 2014	(r266192)
@@ -867,17 +867,13 @@ in_delayed_cksum(struct mbuf *m)
 		csum = 0xffff;
 	offset += m->m_pkthdr.csum_data;	/* checksum offset */
 
-	if (offset + sizeof(u_short) > m->m_len) {
-		printf("delayed m_pullup, m->len: %d  off: %d  p: %d\n",
-		    m->m_len, offset, ip->ip_p);
-		/*
-		 * XXX
-		 * this shouldn't happen, but if it does, the
-		 * correct behavior may be to insert the checksum
-		 * in the appropriate next mbuf in the chain.
-		 */
-		return;
+	/* find the mbuf in the chain where the checksum starts*/
+	while ((m != NULL) && (offset >= m->m_len)) {
+		offset -= m->m_len;
+		m = m->m_next;
 	}
+	KASSERT(m != NULL, ("in_delayed_cksum: checksum outside mbuf chain."));
+	KASSERT(offset + sizeof(u_short) <= m->m_len, ("in_delayed_cksum: checksum split between mbufs."));
 	*(u_short *)(m->m_data + offset) = csum;
 }
 



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