aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2023-08-09 11:23:42 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-08-13 17:24:56 +0200
commitb2bea0047db4ffdca04ab4f8b395903dc808fe9f (patch)
treef0c93bd84841ede50cd47fa7725389d2f64f09c8
parent02b30e7871410e54d1adfa7deb4943493d0a020e (diff)
downloadpasst-b2bea0047db4ffdca04ab4f8b395903dc808fe9f.tar
passt-b2bea0047db4ffdca04ab4f8b395903dc808fe9f.tar.gz
passt-b2bea0047db4ffdca04ab4f8b395903dc808fe9f.tar.bz2
passt-b2bea0047db4ffdca04ab4f8b395903dc808fe9f.tar.lz
passt-b2bea0047db4ffdca04ab4f8b395903dc808fe9f.tar.xz
passt-b2bea0047db4ffdca04ab4f8b395903dc808fe9f.tar.zst
passt-b2bea0047db4ffdca04ab4f8b395903dc808fe9f.zip
tap: fix seq->p.count limit
The number of items in pool_l4_t is defined to UIO_MAXIOV, not TAP_SEQS. TAP_SEQS is the number of the sequences. Fix the value used to compare seq->p.count with. Fixes: 37c228ada88b ("tap, tcp, udp, icmp: Cut down on some oversized buffers") Signed-off-by: Laurent Vivier <lvivier@redhat.com> [sbrivio: s/messages/sequences/ in commit message, extend initialisation of packets in pool to UIO_MAXIOV items] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tap.c b/tap.c
index e034f94..7261370 100644
--- a/tap.c
+++ b/tap.c
@@ -678,7 +678,7 @@ resume:
seq->daddr.s_addr = iph->daddr; \
} while (0)
- if (seq && L4_MATCH(iph, uh, seq) && seq->p.count < TAP_SEQS)
+ if (seq && L4_MATCH(iph, uh, seq) && seq->p.count < UIO_MAXIOV)
goto append;
if (seq_count == TAP_SEQS)
@@ -686,7 +686,7 @@ resume:
for (seq = tap4_l4 + seq_count - 1; seq >= tap4_l4; seq--) {
if (L4_MATCH(iph, uh, seq)) {
- if (seq->p.count >= TAP_SEQS)
+ if (seq->p.count >= UIO_MAXIOV)
seq = NULL;
break;
}
@@ -840,7 +840,7 @@ resume:
} while (0)
if (seq && L4_MATCH(ip6h, proto, uh, seq) &&
- seq->p.count < TAP_SEQS)
+ seq->p.count < UIO_MAXIOV)
goto append;
if (seq_count == TAP_SEQS)
@@ -848,7 +848,7 @@ resume:
for (seq = tap6_l4 + seq_count - 1; seq >= tap6_l4; seq--) {
if (L4_MATCH(ip6h, proto, uh, seq)) {
- if (seq->p.count >= TAP_SEQS)
+ if (seq->p.count >= UIO_MAXIOV)
seq = NULL;
break;
}
@@ -1232,8 +1232,8 @@ void tap_sock_init(struct ctx *c)
pool_tap6_storage = PACKET_INIT(pool_tap6, TAP_MSGS, pkt_buf, sz);
for (i = 0; i < TAP_SEQS; i++) {
- tap4_l4[i].p = PACKET_INIT(pool_l4, TAP_SEQS, pkt_buf, sz);
- tap6_l4[i].p = PACKET_INIT(pool_l4, TAP_SEQS, pkt_buf, sz);
+ tap4_l4[i].p = PACKET_INIT(pool_l4, UIO_MAXIOV, pkt_buf, sz);
+ tap6_l4[i].p = PACKET_INIT(pool_l4, UIO_MAXIOV, pkt_buf, sz);
}
if (c->fd_tap != -1) {