Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Apr 2017 09:00:48 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316822 - in head/sys: kern netinet netinet6
Message-ID:  <201704140900.v3E90mJU030549@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Fri Apr 14 09:00:48 2017
New Revision: 316822
URL: https://svnweb.freebsd.org/changeset/base/316822

Log:
  Rework r316770 to make it protocol independent and general, like we
  do for streaming sockets.
  
  And do more cleanup in the sbappendaddr_locked_internal() to prevent
  leak information from existing mbuf to the one, that will be possible
  created later by netgraph.
  
  Suggested by:	glebius
  Tested by:	Irina Liakh <spell at itl ua>
  MFC after:	1 week

Modified:
  head/sys/kern/uipc_sockbuf.c
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/kern/uipc_sockbuf.c
==============================================================================
--- head/sys/kern/uipc_sockbuf.c	Fri Apr 14 08:27:42 2017	(r316821)
+++ head/sys/kern/uipc_sockbuf.c	Fri Apr 14 09:00:48 2017	(r316822)
@@ -794,8 +794,20 @@ sbappendaddr_locked_internal(struct sock
 		return (0);
 	m->m_len = asa->sa_len;
 	bcopy(asa, mtod(m, caddr_t), asa->sa_len);
-	if (m0)
+	if (m0) {
 		m_clrprotoflags(m0);
+		m_tag_delete_chain(m0);
+		/*
+		 * Clear some persistent info from pkthdr.
+		 * We don't use m_demote(), because some netgraph consumers
+		 * expect M_PKTHDR presence.
+		 */
+		m0->m_pkthdr.rcvif = NULL;
+		m0->m_pkthdr.flowid = 0;
+		m0->m_pkthdr.csum_flags = 0;
+		m0->m_pkthdr.fibnum = 0;
+		m0->m_pkthdr.rsstype = 0;
+	}
 	if (ctrl_last)
 		ctrl_last->m_next = m0;	/* concatenate data to control */
 	else

Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c	Fri Apr 14 08:27:42 2017	(r316821)
+++ head/sys/netinet/udp_usrreq.c	Fri Apr 14 09:00:48 2017	(r316822)
@@ -372,9 +372,6 @@ udp_append(struct inpcb *inp, struct ip 
 		append_sa = (struct sockaddr *)&udp_in[0];
 	m_adj(n, off);
 
-	/* Clear any h/w csum flags as they are no longer valid. */
-	n->m_pkthdr.csum_flags &= ~(CSUM_DATA_VALID | CSUM_IP_VALID);
-
 	so = inp->inp_socket;
 	SOCKBUF_LOCK(&so->so_rcv);
 	if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) {

Modified: head/sys/netinet6/udp6_usrreq.c
==============================================================================
--- head/sys/netinet6/udp6_usrreq.c	Fri Apr 14 08:27:42 2017	(r316821)
+++ head/sys/netinet6/udp6_usrreq.c	Fri Apr 14 09:00:48 2017	(r316822)
@@ -187,9 +187,6 @@ udp6_append(struct inpcb *inp, struct mb
 	}
 	m_adj(n, off + sizeof(struct udphdr));
 
-	/* Clear any h/w csum flags as they are no longer valid. */
-	n->m_pkthdr.csum_flags &= ~CSUM_DATA_VALID;
-
 	so = inp->inp_socket;
 	SOCKBUF_LOCK(&so->so_rcv);
 	if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)&fromsa[0], n,



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