From 7b56117dae0f19c176d852ec7ee1f01937a994c7 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 8 Sep 2023 11:49:47 +1000 Subject: udp, tap: Correctly advance through packets in udp_tap_handler() In both tap4_handler() and tap6_handler(), once we've sorted incoming l3 packets into "sequences", we then step through all the packets in each DUP sequence calling udp_tap_handler(). Or so it appears. In fact, udp_tap_handler() doesn't take an index and always starts with packet 0 of the sequence, even if called repeatedly. It appears to be written with the idea that the struct pool is a queue, from which it consumes packets as it processes them, but that's not how the pool data structure works. Correct this by adding an index parameter to udp_tap_handler() and altering the loops in tap.c to step through the pool properly. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- udp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'udp.h') diff --git a/udp.h b/udp.h index f553de2..0ee0695 100644 --- a/udp.h +++ b/udp.h @@ -11,7 +11,7 @@ void udp_sock_handler(struct ctx *c, union epoll_ref ref, uint32_t events, const struct timespec *now); int udp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, - const struct pool *p, const struct timespec *now); + const struct pool *p, int idx, const struct timespec *now); int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, const void *addr, const char *ifname, in_port_t port); int udp_init(struct ctx *c); -- cgit v1.2.3