* [PATCH] tap: Don't check sequence counts when adding packets to pool
@ 2022-10-10 8:20 Stefano Brivio
0 siblings, 0 replies; only message in thread
From: Stefano Brivio @ 2022-10-10 8:20 UTC (permalink / raw)
To: passt-dev
This is a minor optimisation possibility I spotted while trying to
debug a hang in tap4_handler(): if we run out of space for packet
sequences, it's fine to add packets to an existing per-sequence pool.
We should check the count of packet sequences only once we realise
that we actually need a new packet sequence.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
tap.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tap.c b/tap.c
index 78de42c..77e513c 100644
--- a/tap.c
+++ b/tap.c
@@ -410,6 +410,9 @@ resume:
if (seq && L4_MATCH(iph, uh, seq) && seq->p.count < TAP_SEQS)
goto append;
+ if (seq_count == TAP_SEQS)
+ break; /* Resume after flushing if i < in->count */
+
for (seq = tap4_l4 + seq_count - 1; seq >= tap4_l4; seq--) {
if (L4_MATCH(iph, uh, seq)) {
if (seq->p.count >= TAP_SEQS)
@@ -429,9 +432,6 @@ resume:
append:
packet_add((struct pool *)&seq->p, l4_len, l4h);
-
- if (seq_count == TAP_SEQS)
- break; /* Resume after flushing if i < count */
}
for (j = 0, seq = tap4_l4; j < seq_count; j++, seq++) {
@@ -572,6 +572,9 @@ resume:
seq->p.count < TAP_SEQS)
goto append;
+ if (seq_count == TAP_SEQS)
+ break; /* Resume after flushing if i < in->count */
+
for (seq = tap6_l4 + seq_count - 1; seq >= tap6_l4; seq--) {
if (L4_MATCH(ip6h, proto, uh, seq)) {
if (seq->p.count >= TAP_SEQS)
@@ -591,9 +594,6 @@ resume:
append:
packet_add((struct pool *)&seq->p, l4_len, l4h);
-
- if (seq_count == TAP_SEQS)
- break; /* Resume after flushing if i < count */
}
for (j = 0, seq = tap6_l4; j < seq_count; j++, seq++) {
--
@@ -410,6 +410,9 @@ resume:
if (seq && L4_MATCH(iph, uh, seq) && seq->p.count < TAP_SEQS)
goto append;
+ if (seq_count == TAP_SEQS)
+ break; /* Resume after flushing if i < in->count */
+
for (seq = tap4_l4 + seq_count - 1; seq >= tap4_l4; seq--) {
if (L4_MATCH(iph, uh, seq)) {
if (seq->p.count >= TAP_SEQS)
@@ -429,9 +432,6 @@ resume:
append:
packet_add((struct pool *)&seq->p, l4_len, l4h);
-
- if (seq_count == TAP_SEQS)
- break; /* Resume after flushing if i < count */
}
for (j = 0, seq = tap4_l4; j < seq_count; j++, seq++) {
@@ -572,6 +572,9 @@ resume:
seq->p.count < TAP_SEQS)
goto append;
+ if (seq_count == TAP_SEQS)
+ break; /* Resume after flushing if i < in->count */
+
for (seq = tap6_l4 + seq_count - 1; seq >= tap6_l4; seq--) {
if (L4_MATCH(ip6h, proto, uh, seq)) {
if (seq->p.count >= TAP_SEQS)
@@ -591,9 +594,6 @@ resume:
append:
packet_add((struct pool *)&seq->p, l4_len, l4h);
-
- if (seq_count == TAP_SEQS)
- break; /* Resume after flushing if i < count */
}
for (j = 0, seq = tap6_l4; j < seq_count; j++, seq++) {
--
2.35.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-10 8:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 8:20 [PATCH] tap: Don't check sequence counts when adding packets to pool Stefano Brivio
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).