chunk.c (ecd740c6f2f092b90b95fa35f757973589eaaca2) chunk.c (e0eb093e794452791b0f932a0120f410f614ad82)
1/* SCTP kernel implementation
2 * (C) Copyright IBM Corp. 2003, 2004
3 *
4 * This file is part of the SCTP kernel implementation
5 *
6 * This file contains the code relating the chunk abstraction.
7 *
8 * This SCTP implementation is free software;

--- 150 unchanged lines hidden (view full) ---

159 * down any such message into smaller chunks. Opportunistically, fragment
160 * the chunks down to the current MTU constraints. We may get refragmented
161 * later if the PMTU changes, but it is _much better_ to fragment immediately
162 * with a reasonable guess than always doing our fragmentation on the
163 * soft-interrupt.
164 */
165struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
166 struct sctp_sndrcvinfo *sinfo,
1/* SCTP kernel implementation
2 * (C) Copyright IBM Corp. 2003, 2004
3 *
4 * This file is part of the SCTP kernel implementation
5 *
6 * This file contains the code relating the chunk abstraction.
7 *
8 * This SCTP implementation is free software;

--- 150 unchanged lines hidden (view full) ---

159 * down any such message into smaller chunks. Opportunistically, fragment
160 * the chunks down to the current MTU constraints. We may get refragmented
161 * later if the PMTU changes, but it is _much better_ to fragment immediately
162 * with a reasonable guess than always doing our fragmentation on the
163 * soft-interrupt.
164 */
165struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
166 struct sctp_sndrcvinfo *sinfo,
167 struct msghdr *msgh, int msg_len)
167 struct iov_iter *from)
168{
169 int max, whole, i, offset, over, err;
170 int len, first_len;
171 int max_data;
172 struct sctp_chunk *chunk;
173 struct sctp_datamsg *msg;
174 struct list_head *pos, *temp;
168{
169 int max, whole, i, offset, over, err;
170 int len, first_len;
171 int max_data;
172 struct sctp_chunk *chunk;
173 struct sctp_datamsg *msg;
174 struct list_head *pos, *temp;
175 size_t msg_len = iov_iter_count(from);
175 __u8 frag;
176
177 msg = sctp_datamsg_new(GFP_KERNEL);
178 if (!msg)
179 return ERR_PTR(-ENOMEM);
180
181 /* Note: Calculate this outside of the loop, so that all fragments
182 * have the same expiration.

--- 91 unchanged lines hidden (view full) ---

274
275 chunk = sctp_make_datafrag_empty(asoc, sinfo, len, frag, 0);
276
277 if (!chunk) {
278 err = -ENOMEM;
279 goto errout;
280 }
281
176 __u8 frag;
177
178 msg = sctp_datamsg_new(GFP_KERNEL);
179 if (!msg)
180 return ERR_PTR(-ENOMEM);
181
182 /* Note: Calculate this outside of the loop, so that all fragments
183 * have the same expiration.

--- 91 unchanged lines hidden (view full) ---

275
276 chunk = sctp_make_datafrag_empty(asoc, sinfo, len, frag, 0);
277
278 if (!chunk) {
279 err = -ENOMEM;
280 goto errout;
281 }
282
282 err = sctp_user_addto_chunk(chunk, offset, len, msgh->msg_iov);
283 err = sctp_user_addto_chunk(chunk, len, from);
283 if (err < 0)
284 goto errout_chunk_free;
285
284 if (err < 0)
285 goto errout_chunk_free;
286
286 offset += len;
287
288 /* Put the chunk->skb back into the form expected by send. */
289 __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr
290 - (__u8 *)chunk->skb->data);
291
292 sctp_datamsg_assign(msg, chunk);
293 list_add_tail(&chunk->frag_list, &msg->chunks);
294
295 /* The first chunk, the first chunk was likely short

--- 16 unchanged lines hidden (view full) ---

312
313 chunk = sctp_make_datafrag_empty(asoc, sinfo, over, frag, 0);
314
315 if (!chunk) {
316 err = -ENOMEM;
317 goto errout;
318 }
319
287 /* Put the chunk->skb back into the form expected by send. */
288 __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr
289 - (__u8 *)chunk->skb->data);
290
291 sctp_datamsg_assign(msg, chunk);
292 list_add_tail(&chunk->frag_list, &msg->chunks);
293
294 /* The first chunk, the first chunk was likely short

--- 16 unchanged lines hidden (view full) ---

311
312 chunk = sctp_make_datafrag_empty(asoc, sinfo, over, frag, 0);
313
314 if (!chunk) {
315 err = -ENOMEM;
316 goto errout;
317 }
318
320 err = sctp_user_addto_chunk(chunk, offset, over, msgh->msg_iov);
319 err = sctp_user_addto_chunk(chunk, over, from);
321
322 /* Put the chunk->skb back into the form expected by send. */
323 __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr
324 - (__u8 *)chunk->skb->data);
325 if (err < 0)
326 goto errout_chunk_free;
327
328 sctp_datamsg_assign(msg, chunk);

--- 38 unchanged lines hidden ---
320
321 /* Put the chunk->skb back into the form expected by send. */
322 __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr
323 - (__u8 *)chunk->skb->data);
324 if (err < 0)
325 goto errout_chunk_free;
326
327 sctp_datamsg_assign(msg, chunk);

--- 38 unchanged lines hidden ---