e0647ad80c
When forwarding a datagram to a socket, we need to find a socket with a suitable local address to send it. Currently we keep track of such sockets in an array indexed by local port, but this can't properly handle cases where we have multiple local addresses in active use. For "spliced" (socket to socket) cases, improve this by instead opening a socket specifically for the target side of the flow. We connect() as well as bind()ing that socket, so that it will only receive the flow's reply packets, not anything else. We direct datagrams sent via that socket using the addresses from the flow table, effectively replacing bespoke addressing logic with the unified logic in fwd.c When we create the flow, we also take a duplicate of the originating socket, and use that to deliver reply datagrams back to the origin, again using addresses from the flow table entry. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
27 lines
604 B
C
27 lines
604 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright Red Hat
|
|
* Author: David Gibson <david@gibson.dropbear.id.au>
|
|
*
|
|
* UDP flow tracking data structures
|
|
*/
|
|
#ifndef UDP_FLOW_H
|
|
#define UDP_FLOW_H
|
|
|
|
/**
|
|
* struct udp - Descriptor for a flow of UDP packets
|
|
* @f: Generic flow information
|
|
* @ts: Activity timestamp
|
|
* @s: Socket fd (or -1) for each side of the flow
|
|
*/
|
|
struct udp_flow {
|
|
/* Must be first element */
|
|
struct flow_common f;
|
|
|
|
time_t ts;
|
|
int s[SIDES];
|
|
};
|
|
|
|
bool udp_flow_timer(const struct ctx *c, struct udp_flow *uflow,
|
|
const struct timespec *now);
|
|
|
|
#endif /* UDP_FLOW_H */
|