summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_sockbuf.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2009-06-22 21:46:40 +0000
committerandre <andre@FreeBSD.org>2009-06-22 21:46:40 +0000
commit00948f56d32c33988293fc924f042b151169e1d3 (patch)
tree36744a2ba99fe3255f7790a9b19942f6961b82b2 /sys/kern/uipc_sockbuf.c
parenta7cd46d35bbfe8ceabd7a9ed915c1cf409482d76 (diff)
downloadFreeBSD-src-00948f56d32c33988293fc924f042b151169e1d3.zip
FreeBSD-src-00948f56d32c33988293fc924f042b151169e1d3.tar.gz
In sbappendstream_locked() demote all incoming packet mbufs (and
chains) to pure data mbufs using m_demote(). This removes the packet header and all m_tag information as they are not meaningful anymore on a stream socket where mbufs are linked through m->m_next. Strictly speaking a packet header can be only ever valid on the first mbuf in an m_next chain. sbcompress() was doing this already when the mbuf chain layout lent itself to it (e.g. header splitting or merge-append), just not consistently. This frees resources at socket buffer append time instead of at sbdrop_internal() time after data has been read from the socket. For MAC the per packet information has done its duty and during socket buffer appending the policy of the socket itself takes over. With the append the packet boundaries disappear naturally and with it any context that was based on it. None of the residual information from mbuf headers in the socket buffer on stream sockets was looked at.
Diffstat (limited to 'sys/kern/uipc_sockbuf.c')
-rw-r--r--sys/kern/uipc_sockbuf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 2d86d74..2060a2e 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -528,6 +528,9 @@ sbappendstream_locked(struct sockbuf *sb, struct mbuf *m)
SBLASTMBUFCHK(sb);
+ /* Remove all packet headers and mbuf tags to get a pure data chain. */
+ m_demote(m, 1);
+
sbcompress(sb, m, sb->sb_mbtail);
sb->sb_lastrecord = sb->sb_mb;
OpenPOWER on IntegriCloud