From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 69DF75A0274 for ; Fri, 25 Nov 2022 08:17:26 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4NJR5C6NFmz4x2c; Fri, 25 Nov 2022 18:17:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1669360639; bh=3H28sWAOAm+GFaYJkCjoKI8H5QmeYvgTdsyqxkm3+To=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n9qV1XTCmH6W7RUNX9mzWIk4azRfVwLlWtWkItIBRlzj8p1PJfLfivIbtzTbGCI76 lrn6Ieuu/48nLftnBJLL7uj044531EwjlA6TjWxrqHz1qJQ8ZAHXnTRuOkaAmXZrwh myTFoHpCVTExCto5xbevlnjtuL2vstAFEFZAEWSk= Date: Fri, 25 Nov 2022 18:06:16 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 02/16] udp: Separate tracking of inbound and outbound packet flows Message-ID: References: <20221124011659.1024901-1-david@gibson.dropbear.id.au> <20221124011659.1024901-3-david@gibson.dropbear.id.au> <20221125024745.2240314e@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="/uq0xqoynbc821Hz" Content-Disposition: inline In-Reply-To: <20221125024745.2240314e@elisabeth> Message-ID-Hash: 57LSZU36GS6DMWN6GMMRFG4NMDTYCXH5 X-Message-ID-Hash: 57LSZU36GS6DMWN6GMMRFG4NMDTYCXH5 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: passt-dev@passt.top X-Mailman-Version: 3.3.3 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: --/uq0xqoynbc821Hz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 25, 2022 at 02:47:45AM +0100, Stefano Brivio wrote: > Just two nits here: >=20 > On Thu, 24 Nov 2022 12:16:45 +1100 > David Gibson wrote: >=20 > > Each entry udp_splice_map[v6][N] keeps information about two essentially > > unrelated packet flows. @ns_conn_sock, @ns_conn_ts and @init_bound_sock > > track a packet flow from port N in the host init namespace to some other > > port in the pasta namespace (the one @ns_conn_sock is connected to). > > @init_conn_sock, @init_conn_ts and @ns_bound_sock track packet flow from > > port N in the pasta namespace to some other port in the host init names= pace > > (the one @init_conn_sock is connected to). > >=20 > > Split udp_splice_map[][] into two separate tables for the two direction= s. > > Each entry in each table is a 'struct udp_splice_flow' with @orig_sock > > (previously the bound socket), @target_sock (previously the connected > > socket) and @ts (the timeout for the target socket). > >=20 > > Signed-off-by: David Gibson > > --- > > udp.c | 111 +++++++++++++++++++++++++++++----------------------------- > > 1 file changed, 56 insertions(+), 55 deletions(-) > >=20 > > diff --git a/udp.c b/udp.c > > index a025a48..4caf73e 100644 > > --- a/udp.c > > +++ b/udp.c > > @@ -47,44 +47,44 @@ > > * >=20 > This comment still references struct udp_splice_port, it should now say > "see struct udp_spliced_flow" instead. Fixed. Although that change is obsoleted later in the series. > > * - forward direction: 127.0.0.1:5000 -> 127.0.0.1:80 in init from = bound > > * socket s, with epoll reference: index =3D 80, splice =3D UDP_TO= _NS > > - * - if udp_splice_map[V4][5000].ns_conn_sock: > > - * - send packet to udp4_splice_map[5000].ns_conn_sock > > + * - if udp_splice_to_ns[V4][5000].target_sock: > > + * - send packet to udp_splice_to_ns[V4][5000].target_sock > > * - otherwise: > > - * - create new socket udp_splice_map[V4][5000].ns_conn_sock > > + * - create new socket udp_splice_to_ns[V4][5000].target_sock > > * - bind in namespace to 127.0.0.1:5000 > > * - connect in namespace to 127.0.0.1:80 (note: this destinatio= n port > > * might be remapped to another port instead) > > * - add to epoll with reference: index =3D 5000, splice: UDP_BA= CK_TO_INIT > > - * - set udp_splice_map[V4][5000].init_bound_sock to s > > - * - update udp_splice_map[V4][5000].ns_conn_ts with current time > > + * - set udp_splice_to_ns[V4][5000].orig_sock to s > > + * - update udp_splice_to_ns[V4][5000].ts with current time > > * > > * - reverse direction: 127.0.0.1:80 -> 127.0.0.1:5000 in namespace = =66rom > > * connected socket s, having epoll reference: index =3D 5000, > > * splice =3D UDP_BACK_TO_INIT > > - * - if udp_splice_map[V4][5000].init_bound_sock: > > - * - send to udp_splice_map[V4][5000].init_bound_sock, with dest= ination > > - * port 5000 > > + * - if udp_splice_to_ns[V4][5000].orig_sock: > > + * - send to udp_splice_to_ns[V4][5000].orig_sock, with destinat= ion port > > + * 5000 > > * - otherwise, discard > > * > > * - from namespace to init: > > * > > * - forward direction: 127.0.0.1:2000 -> 127.0.0.1:22 in namespace = =66rom bound > > * socket s, with epoll reference: index =3D 22, splice =3D UDP_TO= _INIT > > - * - if udp4_splice_map[V4][2000].init_conn_sock: > > - * - send packet to udp4_splice_map[2000].init_conn_sock > > + * - if udp4_splice_to_init[V4][2000].target_sock: > > + * - send packet to udp_splice_to_init[V4][2000].target_sock > > * - otherwise: > > - * - create new socket udp_splice_map[V4][2000].init_conn_sock > > + * - create new socket udp_splice_to_init[V4][2000].target_sock > > * - bind in init to 127.0.0.1:2000 > > * - connect in init to 127.0.0.1:22 (note: this destination port > > * might be remapped to another port instead) > > * - add to epoll with reference: index =3D 2000, splice =3D UDP= _BACK_TO_NS > > - * - set udp_splice_map[V4][2000].ns_bound_sock to s > > - * - update udp_splice_map[V4][2000].init_conn_ts with current time > > + * - set udp_splice_to_init[V4][2000].orig_sock to s > > + * - update udp_splice_to_init[V4][2000].ts with current time > > * > > * - reverse direction: 127.0.0.1:22 -> 127.0.0.1:2000 in init from = connected > > * socket s, having epoll reference: index =3D 2000, splice =3D UD= P_BACK_TO_NS > > - * - if udp_splice_map[V4][2000].ns_bound_sock: > > - * - send to udp_splice_map[V4][2000].ns_bound_sock, with destinat= ion port > > + * - if udp_splice_to_init[V4][2000].orig_sock: > > + * - send to udp_splice_to_init[V4][2000].orig_sock, with destinat= ion port > > * 2000 > > * - otherwise, discard > > */ > > @@ -138,28 +138,26 @@ struct udp_tap_port { > > }; > > =20 > > /** > > - * struct udp_splice_port - Source port tracking for traffic between n= amespaces > > - * @ns_conn_sock: Socket connected in namespace for init source port > > - * @init_conn_sock: Socket connected in init for namespace source port > > - * @ns_conn_ts: Timestamp of activity for socket connected in namespa= ce > > - * @init_conn_ts: Timestamp of activity for socket connceted in init > > - * @ns_bound_sock: Bound socket in namespace for this source port in i= nit > > - * @init_bound_sock: Bound socket in init for this source port in name= space > > + * struct udp_splice_flow - Spliced "connection" > > + * @orig_sock: Originating socket, bound to dest port in source ns of > > + * originating datagram > > + * @target_sock: Target socket, bound to source port of originating > > + * datagram in dest ns, connected to dest port of > > + * originating datagram in dest ns > > + * @ts: Activity timestamp > > */ > > -struct udp_splice_port { > > - int ns_conn_sock; > > - int init_conn_sock; > > - > > - time_t ns_conn_ts; > > - time_t init_conn_ts; > > - > > - int ns_bound_sock; > > - int init_bound_sock; > > +struct udp_splice_flow { > > + int orig_sock; > > + int target_sock; > > + time_t ts; > > }; > > =20 > > /* Port tracking, arrays indexed by packet source port (host order) */ > > static struct udp_tap_port udp_tap_map [IP_VERSIONS][NUM_PORTS]; > > -static struct udp_splice_port udp_splice_map [IP_VERSIONS][NUM_PORTS]; > > + > > +/* Spliced "connections" indexed by originating source port (host orde= r) */ > > +static struct udp_splice_flow udp_splice_to_ns [IP_VERSIONS][NUM_PORT= S]; > > +static struct udp_splice_flow udp_splice_to_init[IP_VERSIONS][NUM_PORT= S]; > > =20 > > enum udp_act_type { > > UDP_ACT_TAP, > > @@ -421,8 +419,17 @@ int udp_splice_connect(const struct ctx *c, int v6= , int bound_sock, > > .r.p.udp.udp =3D { .splice =3D splice, .v6 =3D v6, > > .port =3D src } > > }; > > - struct udp_splice_port *sp =3D &udp_splice_map[v6 ? V6 : V4][src]; > > + struct udp_splice_flow *flow; > > int s; > > + int act; >=20 > ...and this should go before 'int s;'. Fixed. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --/uq0xqoynbc821Hz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmOAaWEACgkQgypY4gEw YSK5Bg/+Kh4FJS6cg1zXrc4sHYo1Sownmy/hf6Pa3Uc91bpWf4BklNZ8wUg3tXao adZ2Acor9SVJCNpL0+iyon45RnRoPTKlK/1tPp1KaUm6QLrs4F47LkbjJvDx80Gh ol9Wntc48L35EVACQCL0nBRWB6ie/RDl2abWvmFmu9L/JkSueobyWZ1NJN1+Z4m/ fe2T6c7XClOayXMBPR84c9DLmSA989w16tBOXhyoNhz2Ooy2pP7phidoYXeMsbO6 z//MDjca/YF+iHYphtXZVKyl7z3bRTknzzD3vYXfCnBGe2HJ6Py545A+3KilmOgE clHNIboApGiXL3CRkn+vBzN6PI7BXirXIZQao0r0vpY73te3GXMQ6j56MGFYMMCu f4eN7fekc34j7OMHqiVAIAHgWRCeikK2FXRnaOojW8ZBt8rNm3ef+ukeVz2mMotx h3vzFM8qhC2N/dyzowmOGCnw5wOjJPGtKgWoQtZuLgFHBgHdtlyPhl3umT+TTxmt fMM8BdTIkCcRqoZqHz4btKqgyd/9aTRia5cJMPFCqOTyXUSLxf/X60iOedCPuH4m 0MDrfwPbDTZt/0Re9aqi9tUYHNe2YjpIalawJIFCdZgvw3YxN9plj+8V1Va4FphK 9NmDYAfw/bfPoGqxu5R2jTxQyA38ZNrbJVHF2AtnYXx0vsxZVBA= =vMa9 -----END PGP SIGNATURE----- --/uq0xqoynbc821Hz--