mirror of
https://passt.top/passt
synced 2025-05-31 05:15:43 +02:00
flow: Common address information for initiating side
Handling of each protocol needs some degree of tracking of the addresses and ports at the end of each connection or flow. Sometimes that's explicit (as in the guest visible addresses for TCP connections), sometimes implicit (the bound and connected addresses of sockets). To allow more consistent handling across protocols we want to uniformly track the address and port at each end of the connection. Furthermore, because we allow port remapping, and we sometimes need to apply NAT, the addresses and ports can be different as seen by the guest/namespace and as by the host. Introduce 'struct flowside' to keep track of address and port information related to one side of a flow. Store two of these in the common fields of a flow to track that information for both sides. For now we only populate the initiating side, requiring that information be completed when a flows enter INI. Later patches will populate the target side. For now this leaves some information redundantly recorded in both generic and type specific fields. We'll fix that in later patches. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
ba74b1fea1
commit
8012f5ff55
6 changed files with 127 additions and 11 deletions
6
tcp.c
6
tcp.c
|
@ -1666,7 +1666,7 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af,
|
|||
if (!(flow = flow_alloc()))
|
||||
return;
|
||||
|
||||
flow_initiate(flow, PIF_TAP);
|
||||
flow_initiate_af(flow, PIF_TAP, af, saddr, srcport, daddr, dstport);
|
||||
|
||||
flow_target(flow, PIF_HOST);
|
||||
conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp);
|
||||
|
@ -2351,7 +2351,9 @@ void tcp_listen_handler(struct ctx *c, union epoll_ref ref,
|
|||
if (s < 0)
|
||||
goto cancel;
|
||||
|
||||
flow_initiate(flow, ref.tcp_listen.pif);
|
||||
/* FIXME: When listening port has a specific bound address, record that
|
||||
* as the forwarding address */
|
||||
flow_initiate_sa(flow, ref.tcp_listen.pif, &sa, ref.tcp_listen.port);
|
||||
|
||||
if (sa.sa_family == AF_INET) {
|
||||
const struct in_addr *addr = &sa.sa4.sin_addr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue