Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143237053
D35297.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D35297.diff
View Options
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1118,6 +1118,9 @@
/*
* PF_UNIX/SOCK_DGRAM send
+ *
+ * Allocate a record consisting of 3 mbufs in the sequence of
+ * from -> control -> data and append it to the socket buffer.
*/
static int
uipc_sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio,
@@ -1126,11 +1129,14 @@
struct unpcb *unp, *unp2;
const struct sockaddr *from;
struct socket *so2;
- int error;
+ struct sockbuf *sb;
+ struct mbuf *f, *clast;
+ int cc, error;
MPASS((uio != NULL && m == NULL) || (m != NULL && uio == NULL));
error = 0;
+ f = NULL;
if (__predict_false(flags & MSG_OOB)) {
error = EOPNOTSUPP;
@@ -1146,6 +1152,7 @@
error = EFAULT;
goto out;
}
+ f = m_get(M_WAITOK, MT_SONAME);
if (c != NULL && (error = unp_internalize(&c, td)))
goto out;
} else {
@@ -1159,6 +1166,10 @@
error = EMSGSIZE;
goto out;
}
+ if ((f = m_get(M_NOWAIT, MT_SONAME)) == NULL) {
+ error = ENOBUFS;
+ goto out;
+ }
/* Condition the foreign mbuf to our standards. */
m_clrprotoflags(m);
m_tag_delete_chain(m, NULL);
@@ -1225,11 +1236,38 @@
from = (struct sockaddr *)unp->unp_addr;
else
from = &sun_noname;
+ f->m_len = from->sa_len;
+ MPASS(from->sa_len <= MLEN);
+ bcopy(from, mtod(f, void *), from->sa_len);
+ cc = f->m_len + m->m_pkthdr.len;
+ if (c != NULL)
+ cc += m_length(c, &clast);
so2 = unp2->unp_socket;
- SOCKBUF_LOCK(&so2->so_rcv);
- if (sbappendaddr_locked(&so2->so_rcv, from, m, c)) {
+ sb = &so2->so_rcv;
+ SOCKBUF_LOCK(sb);
+ if (cc <= sbspace(sb)) {
+ /* Concatenate: from -> control -> data. */
+ if (c != NULL) {
+ f->m_next = c;
+ clast->m_next = m;
+ } else
+ f->m_next = m;
+ m = f;
+ /* Reusing f as iterator. */
+ for (f = m; f->m_next != NULL; f = f->m_next)
+ sballoc(sb, f);
+ sballoc(sb, f);
+ sb->sb_mbtail = f;
+ /* SBLINKRECORD */
+ if (sb->sb_lastrecord != NULL)
+ sb->sb_lastrecord->m_nextpkt = m;
+ else
+ sb->sb_mb = m;
+ sb->sb_lastrecord = m;
+ SBLASTMBUFCHK(sb);
+ SBLASTRECORDCHK(sb);
sorwakeup_locked(so2);
- m = c = NULL;
+ f = m = c = NULL;
} else {
soroverflow_locked(so2);
error = (so->so_state & SS_NBIO) ? EAGAIN : ENOBUFS;
@@ -1248,6 +1286,8 @@
if (c)
unp_scan(c, unp_freerights);
out:
+ if (f)
+ m_free(f);
if (c)
m_freem(c);
if (m)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 28, 9:25 PM (6 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28066246
Default Alt Text
D35297.diff (2 KB)
Attached To
Mode
D35297: unix/dgram: inline sbappendaddr_locked() into uipc_sosend_dgram()
Attached
Detach File
Event Timeline
Log In to Comment