diff options
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r-- | net/core/skbuff.c | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 3ab989b0de42..a9a2ae3e2213 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -1649,7 +1649,7 @@ static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i) | |||
1649 | 1649 | ||
1650 | static struct page *linear_to_page(struct page *page, unsigned int *len, | 1650 | static struct page *linear_to_page(struct page *page, unsigned int *len, |
1651 | unsigned int *offset, | 1651 | unsigned int *offset, |
1652 | struct sk_buff *skb, struct sock *sk) | 1652 | struct sock *sk) |
1653 | { | 1653 | { |
1654 | struct page_frag *pfrag = sk_page_frag(sk); | 1654 | struct page_frag *pfrag = sk_page_frag(sk); |
1655 | 1655 | ||
@@ -1682,14 +1682,14 @@ static bool spd_can_coalesce(const struct splice_pipe_desc *spd, | |||
1682 | static bool spd_fill_page(struct splice_pipe_desc *spd, | 1682 | static bool spd_fill_page(struct splice_pipe_desc *spd, |
1683 | struct pipe_inode_info *pipe, struct page *page, | 1683 | struct pipe_inode_info *pipe, struct page *page, |
1684 | unsigned int *len, unsigned int offset, | 1684 | unsigned int *len, unsigned int offset, |
1685 | struct sk_buff *skb, bool linear, | 1685 | bool linear, |
1686 | struct sock *sk) | 1686 | struct sock *sk) |
1687 | { | 1687 | { |
1688 | if (unlikely(spd->nr_pages == MAX_SKB_FRAGS)) | 1688 | if (unlikely(spd->nr_pages == MAX_SKB_FRAGS)) |
1689 | return true; | 1689 | return true; |
1690 | 1690 | ||
1691 | if (linear) { | 1691 | if (linear) { |
1692 | page = linear_to_page(page, len, &offset, skb, sk); | 1692 | page = linear_to_page(page, len, &offset, sk); |
1693 | if (!page) | 1693 | if (!page) |
1694 | return true; | 1694 | return true; |
1695 | } | 1695 | } |
@@ -1706,23 +1706,9 @@ static bool spd_fill_page(struct splice_pipe_desc *spd, | |||
1706 | return false; | 1706 | return false; |
1707 | } | 1707 | } |
1708 | 1708 | ||
1709 | static inline void __segment_seek(struct page **page, unsigned int *poff, | ||
1710 | unsigned int *plen, unsigned int off) | ||
1711 | { | ||
1712 | unsigned long n; | ||
1713 | |||
1714 | *poff += off; | ||
1715 | n = *poff / PAGE_SIZE; | ||
1716 | if (n) | ||
1717 | *page = nth_page(*page, n); | ||
1718 | |||
1719 | *poff = *poff % PAGE_SIZE; | ||
1720 | *plen -= off; | ||
1721 | } | ||
1722 | |||
1723 | static bool __splice_segment(struct page *page, unsigned int poff, | 1709 | static bool __splice_segment(struct page *page, unsigned int poff, |
1724 | unsigned int plen, unsigned int *off, | 1710 | unsigned int plen, unsigned int *off, |
1725 | unsigned int *len, struct sk_buff *skb, | 1711 | unsigned int *len, |
1726 | struct splice_pipe_desc *spd, bool linear, | 1712 | struct splice_pipe_desc *spd, bool linear, |
1727 | struct sock *sk, | 1713 | struct sock *sk, |
1728 | struct pipe_inode_info *pipe) | 1714 | struct pipe_inode_info *pipe) |
@@ -1737,23 +1723,19 @@ static bool __splice_segment(struct page *page, unsigned int poff, | |||
1737 | } | 1723 | } |
1738 | 1724 | ||
1739 | /* ignore any bits we already processed */ | 1725 | /* ignore any bits we already processed */ |
1740 | if (*off) { | 1726 | poff += *off; |
1741 | __segment_seek(&page, &poff, &plen, *off); | 1727 | plen -= *off; |
1742 | *off = 0; | 1728 | *off = 0; |
1743 | } | ||
1744 | 1729 | ||
1745 | do { | 1730 | do { |
1746 | unsigned int flen = min(*len, plen); | 1731 | unsigned int flen = min(*len, plen); |
1747 | 1732 | ||
1748 | /* the linear region may spread across several pages */ | 1733 | if (spd_fill_page(spd, pipe, page, &flen, poff, |
1749 | flen = min_t(unsigned int, flen, PAGE_SIZE - poff); | 1734 | linear, sk)) |
1750 | |||
1751 | if (spd_fill_page(spd, pipe, page, &flen, poff, skb, linear, sk)) | ||
1752 | return true; | 1735 | return true; |
1753 | 1736 | poff += flen; | |
1754 | __segment_seek(&page, &poff, &plen, flen); | 1737 | plen -= flen; |
1755 | *len -= flen; | 1738 | *len -= flen; |
1756 | |||
1757 | } while (*len && plen); | 1739 | } while (*len && plen); |
1758 | 1740 | ||
1759 | return false; | 1741 | return false; |
@@ -1777,7 +1759,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, | |||
1777 | if (__splice_segment(virt_to_page(skb->data), | 1759 | if (__splice_segment(virt_to_page(skb->data), |
1778 | (unsigned long) skb->data & (PAGE_SIZE - 1), | 1760 | (unsigned long) skb->data & (PAGE_SIZE - 1), |
1779 | skb_headlen(skb), | 1761 | skb_headlen(skb), |
1780 | offset, len, skb, spd, | 1762 | offset, len, spd, |
1781 | skb_head_is_locked(skb), | 1763 | skb_head_is_locked(skb), |
1782 | sk, pipe)) | 1764 | sk, pipe)) |
1783 | return true; | 1765 | return true; |
@@ -1790,7 +1772,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, | |||
1790 | 1772 | ||
1791 | if (__splice_segment(skb_frag_page(f), | 1773 | if (__splice_segment(skb_frag_page(f), |
1792 | f->page_offset, skb_frag_size(f), | 1774 | f->page_offset, skb_frag_size(f), |
1793 | offset, len, skb, spd, false, sk, pipe)) | 1775 | offset, len, spd, false, sk, pipe)) |
1794 | return true; | 1776 | return true; |
1795 | } | 1777 | } |
1796 | 1778 | ||