netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH v2 net-next 05/13] net: Walk fragments in __skb_splice_bits
Date: Mon, 7 Mar 2016 14:11:04 -0800	[thread overview]
Message-ID: <1457388672-2600559-6-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1457388672-2600559-1-git-send-email-tom@herbertland.com>

Add walking of fragments in __skb_splice_bits.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/core/skbuff.c | 39 ++++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7af7ec6..0df9f6a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1918,6 +1918,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
 			      struct splice_pipe_desc *spd, struct sock *sk)
 {
 	int seg;
+	struct sk_buff *iter;
 
 	/* map the linear part :
 	 * If skb->head_frag is set, this 'linear' part is backed by a
@@ -1944,6 +1945,19 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
 			return true;
 	}
 
+	skb_walk_frags(skb, iter) {
+		if (*offset >= iter->len) {
+			*offset -= iter->len;
+			continue;
+		}
+		/* __skb_splice_bits() only fails if the output has no room
+		 * left, so no point in going over the frag_list for the error
+		 * case.
+		 */
+		if (__skb_splice_bits(iter, pipe, offset, len, spd, sk))
+			return true;
+	}
+
 	return false;
 }
 
@@ -1970,9 +1984,7 @@ ssize_t skb_socket_splice(struct sock *sk,
 
 /*
  * Map data from the skb to a pipe. Should handle both the linear part,
- * the fragments, and the frag list. It does NOT handle frag lists within
- * the frag list, if such a thing exists. We'd probably need to recurse to
- * handle that cleanly.
+ * the fragments, and the frag list.
  */
 int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
 		    struct pipe_inode_info *pipe, unsigned int tlen,
@@ -1991,29 +2003,10 @@ int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
 		.ops = &nosteal_pipe_buf_ops,
 		.spd_release = sock_spd_release,
 	};
-	struct sk_buff *frag_iter;
 	int ret = 0;
 
-	/*
-	 * __skb_splice_bits() only fails if the output has no room left,
-	 * so no point in going over the frag_list for the error case.
-	 */
-	if (__skb_splice_bits(skb, pipe, &offset, &tlen, &spd, sk))
-		goto done;
-	else if (!tlen)
-		goto done;
+	__skb_splice_bits(skb, pipe, &offset, &tlen, &spd, sk);
 
-	/*
-	 * now see if we have a frag_list to map
-	 */
-	skb_walk_frags(skb, frag_iter) {
-		if (!tlen)
-			break;
-		if (__skb_splice_bits(frag_iter, pipe, &offset, &tlen, &spd, sk))
-			break;
-	}
-
-done:
 	if (spd.nr_pages)
 		ret = splice_cb(sk, pipe, &spd);
 
-- 
2.6.5

  parent reply	other threads:[~2016-03-07 22:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07 22:10 [PATCH v2 net-next 00/13] kcm: Kernel Connection Multiplexor (KCM) Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 01/13] rcu: Add list_next_or_null_rcu Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 02/13] net: Make sock_alloc exportable Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 03/13] net: Allow MSG_EOR in each msghdr of sendmmsg Tom Herbert
2018-04-07  8:40   ` Andreas Schwab
2016-03-07 22:11 ` [PATCH v2 net-next 04/13] net: Add MSG_BATCH flag Tom Herbert
2016-03-07 22:11 ` Tom Herbert [this message]
2016-03-07 22:11 ` [PATCH v2 net-next 06/13] tcp: Add tcp_inq to get available receive bytes on socket Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 07/13] kcm: Kernel Connection Multiplexor module Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 08/13] kcm: Add statistics and proc interfaces Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 09/13] kcm: Splice support Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 10/13] kcm: Sendpage support Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 11/13] kcm: Add memory limit for receive message construction Tom Herbert
2016-03-08  1:28   ` Sowmini Varadhan
2016-03-07 22:11 ` [PATCH v2 net-next 12/13] kcm: Add receive message timeout Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 13/13] kcm: Add description in Documentation Tom Herbert
2016-03-09 21:38 ` [PATCH v2 net-next 00/13] kcm: Kernel Connection Multiplexor (KCM) David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457388672-2600559-6-git-send-email-tom@herbertland.com \
    --to=tom@herbertland.com \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).