diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-10-10 02:33:15 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-10-15 02:10:36 +0200 |
commit | 2970dc257cb09be0514085b9ae4732231bbc91af (patch) | |
tree | e266b5c6290e80b33250b32517f5f9e88fe92eb2 | |
parent | cc65f31250261a1ba777755109c2075dd4b7ba36 (diff) | |
download | passt-2970dc257cb09be0514085b9ae4732231bbc91af.tar passt-2970dc257cb09be0514085b9ae4732231bbc91af.tar.gz passt-2970dc257cb09be0514085b9ae4732231bbc91af.tar.bz2 passt-2970dc257cb09be0514085b9ae4732231bbc91af.tar.lz passt-2970dc257cb09be0514085b9ae4732231bbc91af.tar.xz passt-2970dc257cb09be0514085b9ae4732231bbc91af.tar.zst passt-2970dc257cb09be0514085b9ae4732231bbc91af.zip |
tap: Don't check sequence counts when adding packets to pool
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>
-rw-r--r-- | tap.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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++) { |