[PATCH] lib: Notify once for packets in new fset

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Fri, 25 Mar 2022 08:24:45 +0100

The fset add function was notifying for each packet already stored in
the rx rbuff, which isn't needed.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/lib/dev.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/lib/dev.c b/src/lib/dev.c
index 5f6a3694..d73205e2 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -1459,8 +1459,6 @@ int fset_add(struct flow_set * set,
         struct flow *           flow;
         struct flow_set_entry * fse;
         int                     ret;
-        size_t                  packets;
-        size_t                  i;
 
         if (set == NULL || fd < 0 || fd >= SYS_MAX_FLOWS)
                 return -EINVAL;
@@ -1493,8 +1491,7 @@ int fset_add(struct flow_set * set,
 
         pthread_rwlock_unlock(&set->lock);
 
-        packets = shm_rbuff_queued(ai.flows[fd].rx_rb);
-        for (i = 0; i < packets; i++)
+        if (shm_rbuff_queued(ai.flows[fd].rx_rb))
                 shm_flow_set_notify(ai.fqset, ai.flows[fd].flow_id, FLOW_PKT);
 
         pthread_rwlock_unlock(&ai.lock);
-- 
2.35.1


Other related posts:

  • » [PATCH] lib: Notify once for packets in new fset - Dimitri Staessens