This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 2fccbc0435a net/utils: pack only the new data in net_iob_concat().
2fccbc0435a is described below

commit 2fccbc0435a820a3f6a1030183ac17a27a6cb6be
Author: raiden00pl <[email protected]>
AuthorDate: Fri Nov 20 11:32:22 2026 +0100

    net/utils: pack only the new data in net_iob_concat().
    
    net_iob_concat() packed the whole chain for each received packet.  After
    a read, the first readahead buffer has an offset, so iob_pack() moved all
    queued data, and the cost of each packet grew with the queue.
    
    Pack from the last buffer of iob1, so that the data queued before it is
    not moved again.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: raiden00pl <[email protected]>
---
 net/utils/net_iob_concat.c | 27 ++++++++++++++++++++++++---
 net/utils/utils.h          |  3 ++-
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/net/utils/net_iob_concat.c b/net/utils/net_iob_concat.c
index 6786d32019b..e969ce3271f 100644
--- a/net/utils/net_iob_concat.c
+++ b/net/utils/net_iob_concat.c
@@ -41,7 +41,8 @@
  *
  * Description:
  *   Concatenate iob_s chain iob2 to iob1, if CONFIG_NET_RECV_PACK is
- *   endabled, pack all data in the I/O buffer chain.
+ *   enabled, pack the chain from the last buffer of iob1.  If iob1 is
+ *   empty or its last buffer has no data, pack the whole chain.
  *
  * Returned Value:
  *   The number of bytes actually buffered is returned.  This will be either
@@ -51,12 +52,24 @@
 
 uint16_t net_iob_concat(FAR struct iob_s **iob1, FAR struct iob_s **iob2)
 {
+#ifdef CONFIG_NET_RECV_PACK
+  FAR struct iob_s *tail = NULL;
+#endif
+
   if (*iob1 == NULL)
     {
       *iob1 = *iob2;
     }
   else
     {
+#ifdef CONFIG_NET_RECV_PACK
+      tail = *iob1;
+      while (tail->io_flink != NULL)
+        {
+          tail = tail->io_flink;
+        }
+#endif
+
       iob_concat(*iob1, *iob2);
     }
 
@@ -64,10 +77,18 @@ uint16_t net_iob_concat(FAR struct iob_s **iob1, FAR struct 
iob_s **iob2)
 
 #ifdef CONFIG_NET_RECV_PACK
   /* Merge an iob chain into a continuous space, thereby reducing iob
-   * consumption.
+   * consumption.  Pack from the last buffer of iob1, so that the data
+   * queued before it is not moved again.
    */
 
-  *iob1 = iob_pack(*iob1);
+  if (tail != NULL && tail->io_len > 0)
+    {
+      iob_pack(tail);
+    }
+  else
+    {
+      *iob1 = iob_pack(*iob1);
+    }
 #endif
 
   return (*iob1)->io_pktlen;
diff --git a/net/utils/utils.h b/net/utils/utils.h
index 94e8cada27a..bec54cfd562 100644
--- a/net/utils/utils.h
+++ b/net/utils/utils.h
@@ -465,7 +465,8 @@ FAR void *net_ipv6_payload(FAR struct ipv6_hdr_s *ipv6, FAR 
uint8_t *proto);
  *
  * Description:
  *   Concatenate iob_s chain iob2 to iob1, if CONFIG_NET_RECV_PACK is
- *   endabled, pack all data in the I/O buffer chain.
+ *   enabled, pack the chain from the last buffer of iob1.  If iob1 is
+ *   empty or its last buffer has no data, pack the whole chain.
  *
  * Returned Value:
  *   The number of bytes actually buffered is returned.  This will be either

Reply via email to