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 just introduce the structure itself, later patches will actually populate and use it. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- flow.h | 16 ++++++++++++++++ passt.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/flow.h b/flow.h index 9871e3b..437579b 100644 --- a/flow.h +++ b/flow.h @@ -133,8 +133,23 @@ extern const uint8_t flow_proto[]; #define INISIDE 0 /* Initiating side */ #define FWDSIDE 1 /* Forwarded side */ +/** + * struct flowside - Address information for one side of a flow + * @eaddr: Endpoint address (remote address from passt's PoV) + * @faddr: Forwarding address (local address from passt's PoV) + * @eport: Endpoint port + * @fport: Forwarding port + */ +struct flowside { + union inany_addr faddr; + union inany_addr eaddr; + in_port_t fport; + in_port_t eport; +}; + /** * struct flow_common - Common fields for packet flows + * @side[]: Information for each side of the flow * @state: State of the flow table entry * @type: Type of packet flow * @pif[]: Interface for each side of the flow @@ -143,6 +158,7 @@ struct flow_common { uint8_t state; uint8_t type; uint8_t pif[SIDES]; + struct flowside side[SIDES]; }; #define FLOW_INDEX_BITS 17 /* 128k - 1 */ diff --git a/passt.h b/passt.h index bc58d64..3db0b8e 100644 --- a/passt.h +++ b/passt.h @@ -17,6 +17,9 @@ union epoll_ref; #include "pif.h" #include "packet.h" +#include "siphash.h" +#include "ip.h" +#include "inany.h" #include "flow.h" #include "icmp.h" #include "fwd.h" -- 2.45.0