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 DE3675A026D for ; Tue, 22 Aug 2023 04:11:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1692670296; bh=zBtj99rywh6isg1d0F7bIR5xUdgesWX8AC1vhRHYpHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hi9kCapusT7aQLmjbpuu4L1V0jGgiY3XYYv1FWkXY5nCk8vfT0hwRDrEVJvp0dJ7z zCfRC1kZscsYIXHMSgA8hwsM4mjT4IdDpNRggAb0RdrXTDa0lDsJM/RcB0HgzaQZQb gf9jrX8cMXVt2ChiNgWKpcLDKaz3utzqYPD+46R0= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RVCWr2qC0z4x2D; Tue, 22 Aug 2023 12:11:36 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 4/9] tcp: Consistent usage of ports in tcp_seq_init() Date: Tue, 22 Aug 2023 12:11:25 +1000 Message-ID: <20230822021130.450542-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230822021130.450542-1-david@gibson.dropbear.id.au> References: <20230822021130.450542-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: YNWJIWWLLHDGCAHWZJMNSOCKEB7CXXVQ X-Message-ID-Hash: YNWJIWWLLHDGCAHWZJMNSOCKEB7CXXVQ 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