From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from imap.gmail.com [173.194.76.109] by localhost with POP3 (fetchmail-6.3.26) for (single-drop); Tue, 21 May 2024 07:57:41 +0200 (CEST) Received: by 2002:a05:6a10:9148:b0:55f:c3c0:ed08 with SMTP id n8csp851906pxb; Mon, 20 May 2024 22:57:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWoGOq6mg71aERB1Uvtqw5pWm5sLN5DniDHCW8uAV63C9YqSkUjIlKVrgcX6/D8A/gt+nMwT7u3C8wGYiIPVTOMGUI5UPM9Tog= X-Google-Smtp-Source: AGHT+IFbe/FzIElhOV5rMl+slSfI927ig3HnZBTXzLVVZLvOnQJAXafLTFDeTX7xUAxbKaOQGiZS X-Received: by 2002:a25:81c3:0:b0:df1:d08f:4742 with SMTP id 3f1490d57ef6-df1d08f4ea7mr17967950276.19.1716271044845; Mon, 20 May 2024 22:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716271044; cv=none; d=google.com; s=arc-20160816; b=i/kGujVZm8xzk6eeXxhU9ZHSA6WGmuOZ6QVWUsIABewRCeMf+Iwndw7C4CBeQbH/eO qcYnPM4YOw3ljzI3YQZZTPKduJNU49hhoca76tTVW/i4BvF1+y57Rvnu8YbjIQoPN3jt mL03AUcrfmi0uqmY7iDzsJC05n1aRRYhhA+pAJSUpUja2ZiMSe3xM3mvAlfKXqzXWIsX 7VnF5JmsVS18WznLhrhEDBSZpJcxJor3vPrmRrX7ry3Y1vvLHDkrPMQz6x3e8ViEAagF N+1iELYfZCN0LWXH6vCmDlIfQQ6Xa+kIhbb4+fbOgvSMtMQfsvr387EKsyzJQxt8ljZL rTCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:delivered-to; bh=zv81KJ6hCj+qg51W4T61jFrhJrAe5+iI7Sdadb+pCro=; fh=OvZxoe0l5OQEr5hiks2YsWDyoZfSCuw/Wl/AnSjLRjU=; b=czdQi2WVvP7mOmu/okRvPBTpufH+8p1pIhc0vt/3Yihy5WgvwZ9ydWFFCpuB/CtpqN K/sg1Dv3uTLPEVq4bRD1DwiegXyr3nYQm8AMWEewmowZPvQ7D33JZ/3DEQVCqUyuRvjg YBve3AU+7gAI6Oil7bmzDZ5829owiPyvmy/3wS3Gb36pWNhhAji8Lvz5Wye0ZMYJwrFB 2wnrwxZ2WV8ZhODT/XLWXSj2QUvIom6J1pjN8MoJ+463WVRFdHyo/FI+BEtwmNLKNRH4 wD4454I7pyGCIZW7LGvM0Xs7bkqFhUOrZTt4goIPo2yCR6B9Ud+tudDIpXkLPdcft629 H6uw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dgibson@gandalf.ozlabs.org designates 150.107.74.76 as permitted sender) smtp.mailfrom=dgibson@gandalf.ozlabs.org Return-Path: Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com. [170.10.128.131]) by mx.google.com with ESMTPS id d75a77b69052e-43e06b6fee4si116356541cf.519.2024.05.20.22.57.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 22:57:24 -0700 (PDT) Received-SPF: pass (google.com: domain of dgibson@gandalf.ozlabs.org designates 150.107.74.76 as permitted sender) client-ip=150.107.74.76; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dgibson@gandalf.ozlabs.org designates 150.107.74.76 as permitted sender) smtp.mailfrom=dgibson@gandalf.ozlabs.org Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-119-X2DhTavlPguC2HWdOBUhfg-1; Tue, 21 May 2024 01:57:23 -0400 X-MC-Unique: X2DhTavlPguC2HWdOBUhfg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3115A1955F38 for ; Tue, 21 May 2024 05:57:21 +0000 (UTC) Received: by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) id 222203001D24; Tue, 21 May 2024 05:57:21 +0000 (UTC) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.58]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1FD653001D1F for ; Tue, 21 May 2024 05:57:21 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [170.10.128.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C19CB1955F2B for ; Tue, 21 May 2024 05:57:20 +0000 (UTC) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-ZchslxfrO9WkApEAns0H8g-1; Tue, 21 May 2024 01:57:17 -0400 X-MC-Unique: ZchslxfrO9WkApEAns0H8g-1 Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Vk3c56pGqz4x20; Tue, 21 May 2024 15:57:09 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Cc: David Gibson Subject: [PATCH 6/6] tcp: Remove interim 'tapside' field from connection Date: Tue, 21 May 2024 15:57:08 +1000 Message-ID: <20240521055708.1150050-7-david@gibson.dropbear.id.au> In-Reply-To: <20240521055708.1150050-1-david@gibson.dropbear.id.au> References: <20240521055708.1150050-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition;Similar Internal Domain=false;Similar Monitored External Domain=false;Custom External Domain=false;Mimecast External Domain=false;Newly Observed Domain=false;Internal User Name=false;Custom Display Name List=false;Reply-to Address Mismatch=false;Targeted Threat Dictionary=false;Mimecast Threat Dictionary=false;Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gibson.dropbear.id.au Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="US-ASCII"; x-default=true List-Id: We recently introduced this field to keep track of which side of a TCP flow is the guest/tap facing one. Now that we generically record which pif each side of each flow is connected to, we can easily derive that, and no longer need to keep track of it explicitly. Signed-off-by: David Gibson --- tcp.c | 12 ++++++------ tcp_conn.h | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tcp.c b/tcp.c index dad425cb..25fcf020 100644 --- a/tcp.c +++ b/tcp.c @@ -368,6 +368,8 @@ #define OPT_SACK=095 #define OPT_TS=09=098 =20 +#define TAPSIDE(conn_)=09((conn_)->f.pif[1] =3D=3D PIF_TAP) + #define CONN_V4(conn)=09=09(!!inany_v4(&(conn)->faddr)) #define CONN_V6(conn)=09=09(!CONN_V4(conn)) #define CONN_IS_CLOSING(conn)=09=09=09=09=09=09\ @@ -577,7 +579,7 @@ static int tcp_epoll_ctl(const struct ctx *c, struct tc= p_tap_conn *conn) { =09int m =3D conn->in_epoll ? EPOLL_CTL_MOD : EPOLL_CTL_ADD; =09union epoll_ref ref =3D { .type =3D EPOLL_TYPE_TCP, .fd =3D conn->sock, -=09=09=09=09.flowside =3D FLOW_SIDX(conn, !conn->tapside), }; +=09=09 .flowside =3D FLOW_SIDX(conn, !TAPSIDE(conn)), }; =09struct epoll_event ev =3D { .data.u64 =3D ref.u64 }; =20 =09if (conn->events =3D=3D CLOSED) { @@ -1130,8 +1132,8 @@ static uint64_t tcp_conn_hash(const struct ctx *c, static inline unsigned tcp_hash_probe(const struct ctx *c, =09=09=09=09 const struct tcp_tap_conn *conn) { -=09flow_sidx_t sidx =3D FLOW_SIDX(conn, conn->tapside); =09unsigned b =3D tcp_conn_hash(c, conn) % TCP_HASH_TABLE_SIZE; +=09flow_sidx_t sidx =3D FLOW_SIDX(conn, TAPSIDE(conn)); =20 =09/* Linear probing */ =09while (!flow_sidx_eq(tc_hash[b], FLOW_SIDX_NONE) && @@ -1150,7 +1152,7 @@ static void tcp_hash_insert(const struct ctx *c, stru= ct tcp_tap_conn *conn) { =09unsigned b =3D tcp_hash_probe(c, conn); =20 -=09tc_hash[b] =3D FLOW_SIDX(conn, conn->tapside); +=09tc_hash[b] =3D FLOW_SIDX(conn, TAPSIDE(conn)); =09flow_dbg(conn, "hash table insert: sock %i, bucket: %u", conn->sock, b)= ; } =20 @@ -2004,7 +2006,6 @@ static void tcp_conn_from_tap(struct ctx *c, sa_famil= y_t af, =20 =09flow_target(flow, PIF_HOST); =09conn =3D FLOW_SET_TYPE(flow, FLOW_TCP, tcp); -=09conn->tapside =3D INISIDE; =09conn->sock =3D s; =09conn->timer =3D -1; =09conn_event(c, conn, TAP_SYN_RCVD); @@ -2721,7 +2722,6 @@ static void tcp_tap_conn_from_sock(struct ctx *c, in_= port_t dstport, =09flow_target(flow, PIF_TAP); =09conn =3D FLOW_SET_TYPE(flow, FLOW_TCP, tcp); =20 -=09conn->tapside =3D TGTSIDE; =09conn->sock =3D s; =09conn->timer =3D -1; =09conn->ws_to_tap =3D conn->ws_from_tap =3D 0; @@ -2880,7 +2880,7 @@ void tcp_sock_handler(struct ctx *c, union epoll_ref = ref, uint32_t events) =09struct tcp_tap_conn *conn =3D CONN(ref.flowside.flow); =20 =09ASSERT(conn->f.type =3D=3D FLOW_TCP); -=09ASSERT(ref.flowside.side =3D=3D !conn->tapside); +=09ASSERT(conn->f.pif[ref.flowside.side] !=3D PIF_TAP); =20 =09if (conn->events =3D=3D CLOSED) =09=09return; diff --git a/tcp_conn.h b/tcp_conn.h index e8c51c34..5f8c8fb6 100644 --- a/tcp_conn.h +++ b/tcp_conn.h @@ -13,7 +13,6 @@ * struct tcp_tap_conn - Descriptor for a TCP connection (not spliced) * @f:=09=09=09Generic flow information * @in_epoll:=09=09Is the connection in the epoll set? - * @tapside:=09=09Which side of the flow faces the tap/guest interface * @tap_mss:=09=09MSS advertised by tap/guest, rounded to 2 ^ TCP_MSS_BITS * @sock:=09=09Socket descriptor number * @events:=09=09Connection events, implying connection states @@ -40,7 +39,6 @@ struct tcp_tap_conn { =09struct flow_common f; =20 =09bool=09=09in_epoll=09:1; -=09unsigned=09tapside=09=09:1; =20 #define TCP_RETRANS_BITS=09=093 =09unsigned int=09retrans=09=09:TCP_RETRANS_BITS; --=20 2.45.1