The function dp_netdev_pmd_flush_output_on_port() iterates over the
p->output_pkts batch directly, when it should be using the special
iterator macro, DP_PACKET_BATCH_FOR_EACH.

However, this wasn't possible because the macro could not accept
&p->output_pkts.

The addition of parentheses when BATCH is dereferenced allows the macro
to expand properly. Parenthesizing arguments in macros is good practice
to be able to handle whichever expressions are passed in.

Signed-off-by: Rosemarie O'Riorden <rorior...@redhat.com>
---
 lib/dp-packet.h   | 4 ++--
 lib/dpif-netdev.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index ee0805ae6..ee357a45a 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -824,7 +824,7 @@ dp_packet_batch_is_full(const struct dp_packet_batch *batch)
 
 #define DP_PACKET_BATCH_FOR_EACH(IDX, PACKET, BATCH)                \
     for (size_t IDX = 0; IDX < dp_packet_batch_size(BATCH); IDX++)  \
-        if (PACKET = BATCH->packets[IDX], true)
+        if (PACKET = (BATCH)->packets[IDX], true)
 
 /* Use this macro for cases where some packets in the 'BATCH' may be
  * dropped after going through each packet in the 'BATCH'.
@@ -839,7 +839,7 @@ dp_packet_batch_is_full(const struct dp_packet_batch *batch)
  * the iterator.  */
 #define DP_PACKET_BATCH_REFILL_FOR_EACH(IDX, SIZE, PACKET, BATCH)       \
     for (dp_packet_batch_refill_init(BATCH), IDX=0; IDX < SIZE; IDX++)  \
-         if (PACKET = BATCH->packets[IDX], true)
+         if (PACKET = (BATCH)->packets[IDX], true)
 
 static inline void
 dp_packet_batch_clone(struct dp_packet_batch *dst,
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 676434308..61929049c 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -5210,8 +5210,8 @@ dp_netdev_pmd_flush_output_on_port(struct 
dp_netdev_pmd_thread *pmd,
         int n_txq = netdev_n_txq(p->port->netdev);
 
         /* Re-batch per txq based on packet hash. */
-        for (i = 0; i < output_cnt; i++) {
-            struct dp_packet *packet = p->output_pkts.packets[i];
+        struct dp_packet *packet;
+        DP_PACKET_BATCH_FOR_EACH (j, packet, &p->output_pkts) {
             uint32_t hash;
 
             if (OVS_LIKELY(dp_packet_rss_valid(packet))) {
-- 
2.35.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to