From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 7829F5A026A; Wed, 22 Feb 2023 13:16:00 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] tcp: Disable optimisations for tcp_hash() Date: Wed, 22 Feb 2023 13:16:00 +0100 Message-Id: <20230222121600.3802188-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 5HOOMO67E24OVPZZTSQA7TVWDJSUGUGP X-Message-ID-Hash: 5HOOMO67E24OVPZZTSQA7TVWDJSUGUGP X-MailFrom: sbrivio@passt.top 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 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: I'm not sure if we're breaking some aliasing rule here, but with gcc 12.2.1 on x86_64 and -flto, the siphash_20b() call in tcp_hash() doesn't see the connection address -- it gets all zeroes instead. Fix this temporarily by disabling optimisations for this tcp_hash(). Signed-off-by: Stefano Brivio --- tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tcp.c b/tcp.c index 81468d9..803c2c4 100644 --- a/tcp.c +++ b/tcp.c @@ -1185,6 +1185,9 @@ static int tcp_hash_match(const struct tcp_tap_conn *conn, #if TCP_HASH_NOINLINE __attribute__((__noinline__)) /* See comment in Makefile */ #endif +__attribute__((optimize("O0"))) /* TODO: with -O2 and -flto on gcc 12.2, + * siphash_20b() doesn't see 'addr', why? + */ static unsigned int tcp_hash(const struct ctx *c, const union inany_addr *addr, in_port_t tap_port, in_port_t sock_port) { -- 2.39.1