diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2025-04-15 17:16:21 +1000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2025-04-15 19:45:19 +0200 |
| commit | 04984578b00f7507a05544b7a5490b03ab2d5135 (patch) | |
| tree | 75b033e6d108ffe44ff7b2aeefa84a88770a59e6 /contrib/qemu/git: | |
| parent | 3f995586b35494b08631081fbf609ff932110849 (diff) | |
| download | passt-04984578b00f7507a05544b7a5490b03ab2d5135.tar passt-04984578b00f7507a05544b7a5490b03ab2d5135.tar.gz passt-04984578b00f7507a05544b7a5490b03ab2d5135.tar.bz2 passt-04984578b00f7507a05544b7a5490b03ab2d5135.tar.lz passt-04984578b00f7507a05544b7a5490b03ab2d5135.tar.xz passt-04984578b00f7507a05544b7a5490b03ab2d5135.tar.zst passt-04984578b00f7507a05544b7a5490b03ab2d5135.zip | |
udp: Deal with errors as we go in udp_sock_fwd()
When we get an epoll event on a listening socket, we first deal with any
errors (udp_sock_errs()), then with any received packets (udp_sock_fwd()).
However, it's theoretically possible that new errors could get flagged on
the socket after we call udp_sock_errs(), in which case we could get errors
returned in in udp_sock_fwd() -> udp_peek_addr() -> recvmsg().
In fact, we do deal with this correctly, although the path is somewhat
non-obvious. The recvmsg() error will cause us to bail out of
udp_sock_fwd(), but the EPOLLERR event will now be flagged, so we'll come
back here next epoll loop and call udp_sock_errs().
Except.. we call udp_sock_fwd() from udp_flush_flow() as well as from
epoll events. This is to deal with any packets that arrived between bind()
and connect(), and so might not be associated with the socket's intended
flow. This expects udp_sock_fwd() to flush _all_ queued datagrams, so that
anything received later must be for the correct flow.
At the moment, udp_sock_errs() might fail to flush all datagrams if errors
occur. In particular this can happen in practice for locally reported
errors which occur immediately after connect() (e.g. connecting to a local
port with nothing listening).
We can deal with the problem case, and also make the flow a little more
natural for the common case by having udp_sock_fwd() call udp_sock_errs()
to handle errors as the occur, rather than trying to deal with all errors
in advance.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'contrib/qemu/git:')
0 files changed, 0 insertions, 0 deletions
