mirror of
https://passt.top/passt
synced 2025-05-17 23:25:35 +02:00

When we establish a new UDP flow we create connect()ed sockets that will only handle datagrams for this flow. However, there is a race between bind() and connect() where they might get some packets queued for a different flow. Currently we handle this by simply discarding any queued datagrams after the connect. UDP protocols should be able to handle such packet loss, but it's not ideal. We now have the tools we need to handle this better, by redirecting any datagrams received during that race to the appropriate flow. We need to use a deferred handler for this to avoid unexpectedly re-ordering datagrams in some edge cases. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [sbrivio: Update comment to udp_flow_defer()] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
34 lines
1,019 B
C
34 lines
1,019 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright (c) 2021 Red Hat GmbH
|
|
* Author: Stefano Brivio <sbrivio@redhat.com>
|
|
*/
|
|
|
|
#ifndef UDP_INTERNAL_H
|
|
#define UDP_INTERNAL_H
|
|
|
|
#include "tap.h" /* needed by udp_meta_t */
|
|
|
|
/**
|
|
* struct udp_payload_t - UDP header and data for inbound messages
|
|
* @uh: UDP header
|
|
* @data: UDP data
|
|
*/
|
|
struct udp_payload_t {
|
|
struct udphdr uh;
|
|
char data[USHRT_MAX - sizeof(struct udphdr)];
|
|
#ifdef __AVX2__
|
|
} __attribute__ ((packed, aligned(32)));
|
|
#else
|
|
} __attribute__ ((packed, aligned(__alignof__(unsigned int))));
|
|
#endif
|
|
|
|
size_t udp_update_hdr4(struct iphdr *ip4h, struct udp_payload_t *bp,
|
|
const struct flowside *toside, size_t dlen,
|
|
bool no_udp_csum);
|
|
size_t udp_update_hdr6(struct ipv6hdr *ip6h, struct udp_payload_t *bp,
|
|
const struct flowside *toside, size_t dlen,
|
|
bool no_udp_csum);
|
|
void udp_sock_fwd(const struct ctx *c, int s, uint8_t frompif,
|
|
in_port_t port, const struct timespec *now);
|
|
|
|
#endif /* UDP_INTERNAL_H */
|