]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[neighbour] Treat delayed transmissions as pending operations coverity_scan master
authorMichael Brown <mcb30@ipxe.org>
Fri, 9 Jan 2026 18:29:53 +0000 (18:29 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sat, 10 Jan 2026 14:43:24 +0000 (14:43 +0000)
Treat each delayed transmission as a pending operation, so that the
"sync" command can be used to ensure that all delayed packets have
been transmitted.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/neighbour.c

index 9d926a4852c16789f9e6e07dc13d5af3a0b11ff4..ac79041e3b5cf7b45870ee2a2015c51ce3bdb6cd 100644 (file)
@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/retry.h>
 #include <ipxe/timer.h>
 #include <ipxe/malloc.h>
+#include <ipxe/pending.h>
 #include <ipxe/neighbour.h>
 #include <config/fault.h>
 
@@ -64,6 +65,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 /** The neighbour cache */
 struct list_head neighbours = LIST_HEAD_INIT ( neighbours );
 
+/** Pending operation for delayed transmissions */
+static struct pending_operation neighbour_delayed;
+
 static void neighbour_expired ( struct retry_timer *timer, int over );
 
 /**
@@ -226,6 +230,9 @@ static void neighbour_tx_queue ( struct neighbour *neighbour ) {
 
                        /* Strip pseudo-header */
                        iob_pull ( iobuf, sizeof ( *delay ) );
+
+                       /* Remove pending operation */
+                       pending_put ( &neighbour_delayed );
                }
 
                /* Transmit deferred packet */
@@ -296,6 +303,8 @@ static void neighbour_destroy ( struct neighbour *neighbour, int rc ) {
                        net_protocol->ntoa ( neighbour->net_dest ),
                        strerror ( rc ) );
                list_del ( &iobuf->list );
+               if ( NEIGHBOUR_DELAY_MS )
+                       pending_put ( &neighbour_delayed );
                netdev_tx_err ( neighbour->netdev, iobuf, rc );
        }
 
@@ -399,6 +408,9 @@ int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
                        delay = iob_push ( iobuf, sizeof ( *delay ) );
                        delay->start = currticks();
 
+                       /* Add pending operation */
+                       pending_get ( &neighbour_delayed );
+
                        /* Process deferred packet queue, if possible */
                        if ( ! neighbour->discovery )
                                neighbour_tx_queue ( neighbour );