summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRosemarie O'Riorden <roriorden@redhat.com>2022-04-26 15:24:31 -0400
committerIlya Maximets <i.maximets@ovn.org>2022-05-04 21:18:08 +0200
commit7e7083cc4628a2884edb264d3bc68c6655be12f8 (patch)
tree852f5cb198186c2117cde80efa58637125c068df /lib
parent8523ee2f8a2d15cb320662dcc3a7ffa9bebe704d (diff)
downloadopenvswitch-7e7083cc4628a2884edb264d3bc68c6655be12f8.tar.gz
dpif-netdev: Replace loop iterating over packet batch with macro.
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 <roriorden@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/dp-packet.h4
-rw-r--r--lib/dpif-netdev.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 7c5da258a..bddaa2b5d 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))) {