aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/skbuff.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2013-01-11 09:46:37 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-11 19:48:08 -0500
commit18aafc622abf492809723d9c5a3c5dcea287169e (patch)
tree870c5204b43f76b29bb4ea4468218a70c0d73384 /net/core/skbuff.c
parentfb0174723e578f9023f1237143fb81e75f470f60 (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/skbuff.c')
-rw-r--r--net/core/skbuff.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1e1b9ea0296d..2568c449fe36 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1652,7 +1652,7 @@ static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
1652 1652
1653static struct page *linear_to_page(struct page *page, unsigned int *len, 1653static struct page *linear_to_page(struct page *page, unsigned int *len,
1654 unsigned int *offset, 1654 unsigned int *offset,
1655 struct sk_buff *skb, struct sock *sk) 1655 struct sock *sk)
1656{ 1656{
1657 struct page_frag *pfrag = sk_page_frag(sk); 1657 struct page_frag *pfrag = sk_page_frag(sk);
1658 1658
@@ -1685,14 +1685,14 @@ static bool spd_can_coalesce(const struct splice_pipe_desc *spd,
1685static bool spd_fill_page(struct splice_pipe_desc *spd, 1685static bool spd_fill_page(struct splice_pipe_desc *spd,
1686 struct pipe_inode_info *pipe, struct page *page, 1686 struct pipe_inode_info *pipe, struct page *page,
1687 unsigned int *len, unsigned int offset, 1687 unsigned int *len, unsigned int offset,
1688 struct sk_buff *skb, bool linear, 1688 bool linear,
1689 struct sock *sk) 1689 struct sock *sk)
1690{ 1690{
1691 if (unlikely(spd->nr_pages == MAX_SKB_FRAGS)) 1691 if (unlikely(spd->nr_pages == MAX_SKB_FRAGS))
1692 return true; 1692 return true;
1693 1693
1694 if (linear) { 1694 if (linear) {
1695 page = linear_to_page(page, len, &offset, skb, sk); 1695 page = linear_to_page(page, len, &offset, sk);
1696 if (!page) 1696 if (!page)
1697 return true; 1697 return true;
1698 } 1698 }
@@ -1711,13 +1711,11 @@ static bool spd_fill_page(struct splice_pipe_desc *spd,
1711 1711
1712static bool __splice_segment(struct page *page, unsigned int poff, 1712static bool __splice_segment(struct page *page, unsigned int poff,
1713 unsigned int plen, unsigned int *off, 1713 unsigned int plen, unsigned int *off,
1714 unsigned int *len, struct sk_buff *skb, 1714 unsigned int *len,
1715 struct splice_pipe_desc *spd, bool linear, 1715 struct splice_pipe_desc *spd, bool linear,
1716 struct sock *sk, 1716 struct sock *sk,
1717 struct pipe_inode_info *pipe) 1717 struct pipe_inode_info *pipe)
1718{ 1718{
1719 unsigned int flen;
1720
1721 if (!*len) 1719 if (!*len)
1722 return true; 1720 return true;
1723 1721
@@ -1732,12 +1730,16 @@ static bool __splice_segment(struct page *page, unsigned int poff,
1732 plen -= *off; 1730 plen -= *off;
1733 *off = 0; 1731 *off = 0;
1734 1732
1735 flen = min(*len, plen); 1733 do {
1736 1734 unsigned int flen = min(*len, plen);
1737 if (spd_fill_page(spd, pipe, page, &flen, poff, skb, linear, sk))
1738 return true;
1739 1735
1740 *len -= flen; 1736 if (spd_fill_page(spd, pipe, page, &flen, poff,
1737 linear, sk))
1738 return true;
1739 poff += flen;
1740 plen -= flen;
1741 *len -= flen;
1742 } while (*len && plen);
1741 1743
1742 return false; 1744 return false;
1743} 1745}
@@ -1760,7 +1762,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
1760 if (__splice_segment(virt_to_page(skb->data), 1762 if (__splice_segment(virt_to_page(skb->data),
1761 (unsigned long) skb->data & (PAGE_SIZE - 1), 1763 (unsigned long) skb->data & (PAGE_SIZE - 1),
1762 skb_headlen(skb), 1764 skb_headlen(skb),
1763 offset, len, skb, spd, 1765 offset, len, spd,
1764 skb_head_is_locked(skb), 1766 skb_head_is_locked(skb),
1765 sk, pipe)) 1767 sk, pipe))
1766 return true; 1768 return true;
@@ -1773,7 +1775,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
1773 1775
1774 if (__splice_segment(skb_frag_page(f), 1776 if (__splice_segment(skb_frag_page(f),
1775 f->page_offset, skb_frag_size(f), 1777 f->page_offset, skb_frag_size(f),
1776 offset, len, skb, spd, false, sk, pipe)) 1778 offset, len, spd, false, sk, pipe))
1777 return true; 1779 return true;
1778 } 1780 }
1779 1781