diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-06 01:10:59 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-24 05:16:39 -0500 |
| commit | 8feb2fb2bb986c533e18037d3c45a5f779421992 (patch) | |
| tree | 7c10e24137e82d54aaa533aeadc21a2d2dae922c /net/core | |
| parent | 195e952d03a797aa953f62ffe24ec58693e17ed8 (diff) | |
switch AF_PACKET and AF_UNIX to skb_copy_datagram_from_iter()
... and kill skb_copy_datagram_iovec()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/datagram.c | 88 |
1 files changed, 2 insertions, 86 deletions
diff --git a/net/core/datagram.c b/net/core/datagram.c index c4d832efebb8..b6e303b0f01f 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
| @@ -480,98 +480,14 @@ short_copy: | |||
| 480 | EXPORT_SYMBOL(skb_copy_datagram_iter); | 480 | EXPORT_SYMBOL(skb_copy_datagram_iter); |
| 481 | 481 | ||
| 482 | /** | 482 | /** |
| 483 | * skb_copy_datagram_from_iovec - Copy a datagram from an iovec. | 483 | * skb_copy_datagram_from_iter - Copy a datagram from an iov_iter. |
| 484 | * @skb: buffer to copy | 484 | * @skb: buffer to copy |
| 485 | * @offset: offset in the buffer to start copying to | 485 | * @offset: offset in the buffer to start copying to |
| 486 | * @from: io vector to copy to | 486 | * @from: the copy source |
| 487 | * @from_offset: offset in the io vector to start copying from | ||
| 488 | * @len: amount of data to copy to buffer from iovec | 487 | * @len: amount of data to copy to buffer from iovec |
| 489 | * | 488 | * |
| 490 | * Returns 0 or -EFAULT. | 489 | * Returns 0 or -EFAULT. |
| 491 | * Note: the iovec is not modified during the copy. | ||
| 492 | */ | 490 | */ |
| 493 | int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset, | ||
| 494 | const struct iovec *from, int from_offset, | ||
| 495 | int len) | ||
| 496 | { | ||
| 497 | int start = skb_headlen(skb); | ||
| 498 | int i, copy = start - offset; | ||
| 499 | struct sk_buff *frag_iter; | ||
| 500 | |||
| 501 | /* Copy header. */ | ||
| 502 | if (copy > 0) { | ||
| 503 | if (copy > len) | ||
| 504 | copy = len; | ||
| 505 | if (memcpy_fromiovecend(skb->data + offset, from, from_offset, | ||
| 506 | copy)) | ||
| 507 | goto fault; | ||
| 508 | if ((len -= copy) == 0) | ||
| 509 | return 0; | ||
| 510 | offset += copy; | ||
| 511 | from_offset += copy; | ||
| 512 | } | ||
| 513 | |||
| 514 | /* Copy paged appendix. Hmm... why does this look so complicated? */ | ||
| 515 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | ||
| 516 | int end; | ||
| 517 | const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
| 518 | |||
| 519 | WARN_ON(start > offset + len); | ||
| 520 | |||
| 521 | end = start + skb_frag_size(frag); | ||
| 522 | if ((copy = end - offset) > 0) { | ||
| 523 | int err; | ||
| 524 | u8 *vaddr; | ||
| 525 | struct page *page = skb_frag_page(frag); | ||
| 526 | |||
| 527 | if (copy > len) | ||
| 528 | copy = len; | ||
| 529 | vaddr = kmap(page); | ||
| 530 | err = memcpy_fromiovecend(vaddr + frag->page_offset + | ||
| 531 | offset - start, | ||
| 532 | from, from_offset, copy); | ||
| 533 | kunmap(page); | ||
| 534 | if (err) | ||
| 535 | goto fault; | ||
| 536 | |||
| 537 | if (!(len -= copy)) | ||
| 538 | return 0; | ||
| 539 | offset += copy; | ||
| 540 | from_offset += copy; | ||
| 541 | } | ||
| 542 | start = end; | ||
| 543 | } | ||
| 544 | |||
| 545 | skb_walk_frags(skb, frag_iter) { | ||
| 546 | int end; | ||
| 547 | |||
| 548 | WARN_ON(start > offset + len); | ||
| 549 | |||
| 550 | end = start + frag_iter->len; | ||
| 551 | if ((copy = end - offset) > 0) { | ||
| 552 | if (copy > len) | ||
| 553 | copy = len; | ||
| 554 | if (skb_copy_datagram_from_iovec(frag_iter, | ||
| 555 | offset - start, | ||
| 556 | from, | ||
| 557 | from_offset, | ||
| 558 | copy)) | ||
| 559 | goto fault; | ||
| 560 | if ((len -= copy) == 0) | ||
| 561 | return 0; | ||
| 562 | offset += copy; | ||
| 563 | from_offset += copy; | ||
| 564 | } | ||
| 565 | start = end; | ||
| 566 | } | ||
| 567 | if (!len) | ||
| 568 | return 0; | ||
| 569 | |||
| 570 | fault: | ||
| 571 | return -EFAULT; | ||
| 572 | } | ||
| 573 | EXPORT_SYMBOL(skb_copy_datagram_from_iovec); | ||
| 574 | |||
| 575 | int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset, | 491 | int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset, |
| 576 | struct iov_iter *from, | 492 | struct iov_iter *from, |
| 577 | int len) | 493 | int len) |
