From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id A06E85A02DD for ; Tue, 14 May 2024 03:03:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1715648621; bh=DdY5Wqffy+Xnw5iu90ut+4aHfTnPW8FoE4zNOv32sKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4x/g52iPm+nl9iW7vfq1IuEWpxpw1krI4qvPLOFrJod3z9mXPoh23cybCNBB8ctZ 1CrtICzwHxFHnh+uGY4HzzCbxBn936cHnrDxpZpW2Jwl1C1oHqAneYjxgaPb2012S3 cFmdaEchgICUG0gQDIo8ToA5R9aV1EKwb+qBSELCwtF6jePHnOsqYemrBt9ajy6QMP f34z9Q+X4ptTG2yIxTUGHmF/9TLQL0+OBbkxxAlDC2kdP2AV+o2XpIoRmzqluPeAmO f0I4BtcEFO+Ybr3cYi35CDKbESER4RAjW9NAsSVFQeQ2gOHwtA+9JqQuPdl3G5nTWb s2it1La/bAgLA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VddQj70kQz4wyl; Tue, 14 May 2024 11:03:41 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v5 05/19] flow: Common data structures for tracking flow addresses Date: Tue, 14 May 2024 11:03:23 +1000 Message-ID: <20240514010337.1104606-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514010337.1104606-1-david@gibson.dropbear.id.au> References: <20240514010337.1104606-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 3ZN2JAHIRKHRDJSP7ZZVRG56XMV3CTPH X-Message-ID-Hash: 3ZN2JAHIRKHRDJSP7ZZVRG56XMV3CTPH X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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