[RESEND PATCH net-next v3] net/core: fix wrong return value in __splice_segment

Pengtao He posted 1 patch 1 month, 3 weeks ago
There is a newer version of this series
net/core/skbuff.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[RESEND PATCH net-next v3] net/core: fix wrong return value in __splice_segment
Posted by Pengtao He 1 month, 3 weeks ago
Return true immediately when the last segment is processed,
avoid to walking once more in the frags loop.

Signed-off-by: Pengtao He <hept.hept.hept@gmail.com>
---
v3->v2:
Reduce once condition evaluation.
v2->v1:
Correct the commit message and target tree.
v1:
https://lore.kernel.org/netdev/20250723063119.24059-1-hept.hept.hept@gmail.com/
---
 net/core/skbuff.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ee0274417948..23b776cd9879 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3112,7 +3112,9 @@ static bool __splice_segment(struct page *page, unsigned int poff,
 		poff += flen;
 		plen -= flen;
 		*len -= flen;
-	} while (*len && plen);
+		if (!*len)
+			return true;
+	} while (plen);
 
 	return false;
 }
-- 
2.49.0
Re: [RESEND PATCH net-next v3] net/core: fix wrong return value in __splice_segment
Posted by Jakub Kicinski 1 month, 3 weeks ago
On Tue, 12 Aug 2025 07:28:01 +0800 Pengtao He wrote:
> Return true immediately when the last segment is processed,
> avoid to walking once more in the frags loop.

Please explain this change more clearly in the commit message.

Took me a minute to realize you're concerned about the caller
behavior not __splice_segment() itself.
-- 
pw-bot: cr