diff options
author | Eric Dumazet <edumazet@google.com> | 2013-01-11 09:46:37 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-20 23:19:36 -0500 |
commit | bc9540c637c3d8712ccbf9dcf28621f380ed5e64 (patch) | |
tree | 6d5d870889eace5924999667c47b0464bb1a3b0c /net/core | |
parent | 82bda6195615891181115f579a480aa5001ce7e9 (diff) |
net: splice: fix __splice_segment()
commit 9ca1b22d6d2 (net: splice: avoid high order page splitting)
forgot that skb->head could need a copy into several page frags.
This could be the case for loopback traffic mostly.
Also remove now useless skb argument from linear_to_page()
and __splice_segment() prototypes.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/skbuff.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index f5dfdf7727c4..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 | } |
@@ -1708,13 +1708,11 @@ static bool spd_fill_page(struct splice_pipe_desc *spd, | |||
1708 | 1708 | ||
1709 | static bool __splice_segment(struct page *page, unsigned int poff, | 1709 | static bool __splice_segment(struct page *page, unsigned int poff, |
1710 | unsigned int plen, unsigned int *off, | 1710 | unsigned int plen, unsigned int *off, |
1711 | unsigned int *len, struct sk_buff *skb, | 1711 | unsigned int *len, |
1712 | struct splice_pipe_desc *spd, bool linear, | 1712 | struct splice_pipe_desc *spd, bool linear, |
1713 | struct sock *sk, | 1713 | struct sock *sk, |
1714 | struct pipe_inode_info *pipe) | 1714 | struct pipe_inode_info *pipe) |
1715 | { | 1715 | { |
1716 | unsigned int flen; | ||
1717 | |||
1718 | if (!*len) | 1716 | if (!*len) |
1719 | return true; | 1717 | return true; |
1720 | 1718 | ||
@@ -1729,12 +1727,16 @@ static bool __splice_segment(struct page *page, unsigned int poff, | |||
1729 | plen -= *off; | 1727 | plen -= *off; |
1730 | *off = 0; | 1728 | *off = 0; |
1731 | 1729 | ||
1732 | flen = min(*len, plen); | 1730 | do { |
1733 | 1731 | unsigned int flen = min(*len, plen); | |
1734 | if (spd_fill_page(spd, pipe, page, &flen, poff, skb, linear, sk)) | ||
1735 | return true; | ||
1736 | 1732 | ||
1737 | *len -= flen; | 1733 | if (spd_fill_page(spd, pipe, page, &flen, poff, |
1734 | linear, sk)) | ||
1735 | return true; | ||
1736 | poff += flen; | ||
1737 | plen -= flen; | ||
1738 | *len -= flen; | ||
1739 | } while (*len && plen); | ||
1738 | 1740 | ||
1739 | return false; | 1741 | return false; |
1740 | } | 1742 | } |
@@ -1757,7 +1759,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, | |||
1757 | if (__splice_segment(virt_to_page(skb->data), | 1759 | if (__splice_segment(virt_to_page(skb->data), |
1758 | (unsigned long) skb->data & (PAGE_SIZE - 1), | 1760 | (unsigned long) skb->data & (PAGE_SIZE - 1), |
1759 | skb_headlen(skb), | 1761 | skb_headlen(skb), |
1760 | offset, len, skb, spd, | 1762 | offset, len, spd, |
1761 | skb_head_is_locked(skb), | 1763 | skb_head_is_locked(skb), |
1762 | sk, pipe)) | 1764 | sk, pipe)) |
1763 | return true; | 1765 | return true; |
@@ -1770,7 +1772,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, | |||
1770 | 1772 | ||
1771 | if (__splice_segment(skb_frag_page(f), | 1773 | if (__splice_segment(skb_frag_page(f), |
1772 | f->page_offset, skb_frag_size(f), | 1774 | f->page_offset, skb_frag_size(f), |
1773 | offset, len, skb, spd, false, sk, pipe)) | 1775 | offset, len, spd, false, sk, pipe)) |
1774 | return true; | 1776 | return true; |
1775 | } | 1777 | } |
1776 | 1778 | ||