From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 50E2A5A0271 for ; Tue, 22 Aug 2023 07:30:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1692682203; bh=zBtj99rywh6isg1d0F7bIR5xUdgesWX8AC1vhRHYpHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U4SMnIELsV5pAtVM6OB301o6w69PJOIo90549MgC30mYUoRjrQSfyiniUsjKPnQw/ nsjW4s3UQfxEm2/wSu1yJPzbELw0ShsxLqF03kpPnlFvwhAOS3nUB54sqRapvvgxJs lb+qBIqDyz9Y+ylFABaCA3MkcWoxLU80gV5HPmuU= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RVHwq3qdFz4wy9; Tue, 22 Aug 2023 15:30:03 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v4 4/9] tcp: Consistent usage of ports in tcp_seq_init() Date: Tue, 22 Aug 2023 15:29:55 +1000 Message-ID: <20230822053000.1118063-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230822053000.1118063-1-david@gibson.dropbear.id.au> References: <20230822053000.1118063-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: UI2PPCTXYVJCKVFUHANMJ2GVNUFJFU55 X-Message-ID-Hash: UI2PPCTXYVJCKVFUHANMJ2GVNUFJFU55 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: In tcp_seq_init() the meaning of "src" and "dst" isn't really clear since it's used for connections in both directions. However, these values are just feeding a hash, so as long as we're consistent and include all the information we want, it doesn't really matter. Oddly, for the "src" side we supply the (tap side) forwarding address but the (tap side) endpoint port. This again doesn't really matter, but it's confusing. So swap this with dstport, so "src" is always forwarding and "dst" is always endpoint. Signed-off-by: David Gibson --- tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index 74bf744..56634c9 100644 --- a/tcp.c +++ b/tcp.c @@ -1857,8 +1857,8 @@ static void tcp_seq_init(const struct ctx *c, struct tcp_tap_conn *conn, in_port_t dstport; } __attribute__((__packed__)) in = { .src = conn->faddr, - .srcport = conn->eport, - .dstport = conn->fport, + .srcport = conn->fport, + .dstport = conn->eport, }; uint32_t ns, seq = 0; -- 2.41.0