MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sbappendaddr_locked_internal

Function sbappendaddr_locked_internal

freebsd/kern/uipc_sockbuf.c:1143–1187  ·  view source on GitHub ↗

Helper routine that appends data, control, and address to a sockbuf. */

Source from the content-addressed store, hash-verified

1141
1142/* Helper routine that appends data, control, and address to a sockbuf. */
1143static int
1144sbappendaddr_locked_internal(struct sockbuf *sb, const struct sockaddr *asa,
1145 struct mbuf *m0, struct mbuf *control, struct mbuf *ctrl_last)
1146{
1147 struct mbuf *m, *n, *nlast;
1148#if MSIZE <= 256
1149 if (asa->sa_len > MLEN)
1150 return (0);
1151#endif
1152 m = m_get(M_NOWAIT, MT_SONAME);
1153 if (m == NULL)
1154 return (0);
1155 m->m_len = asa->sa_len;
1156 bcopy(asa, mtod(m, caddr_t), asa->sa_len);
1157 if (m0) {
1158 m_clrprotoflags(m0);
1159 m_tag_delete_chain(m0, NULL);
1160 /*
1161 * Clear some persistent info from pkthdr.
1162 * We don't use m_demote(), because some netgraph consumers
1163 * expect M_PKTHDR presence.
1164 */
1165 m0->m_pkthdr.rcvif = NULL;
1166 m0->m_pkthdr.flowid = 0;
1167 m0->m_pkthdr.csum_flags = 0;
1168 m0->m_pkthdr.fibnum = 0;
1169 m0->m_pkthdr.rsstype = 0;
1170 }
1171 if (ctrl_last)
1172 ctrl_last->m_next = m0; /* concatenate data to control */
1173 else
1174 control = m0;
1175 m->m_next = control;
1176 for (n = m; n->m_next != NULL; n = n->m_next)
1177 sballoc(sb, n);
1178 sballoc(sb, n);
1179 nlast = n;
1180 SBLINKRECORD(sb, m);
1181
1182 sb->sb_mbtail = nlast;
1183 SBLASTMBUFCHK(sb);
1184
1185 SBLASTRECORDCHK(sb);
1186 return (1);
1187}
1188
1189/*
1190 * Append address and data, and optionally, control (ancillary) data to the

Callers 2

sbappendaddr_lockedFunction · 0.85

Calls 4

m_tag_delete_chainFunction · 0.85
sballocFunction · 0.85
m_getFunction · 0.50
m_clrprotoflagsFunction · 0.50

Tested by

no test coverage detected