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 8E4285A027A for ; Thu, 30 Nov 2023 03:02:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1701309746; bh=IYrJipxz0v8VD/YE+SAWZGL7x9tyybuT2ijMybdb7xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=njqOW9hetq0tg/EtFMd9YWNZTgMV2uKGIvW7BwZiRpcMQxy2PC6TFtXxeoFog6Zo9 7agaJOJCG1k9aKy2GT80WobFPsD7c0etIhHrYX/4qTVkF7JZX8A1j2n6I5VHemr4gA y/gfwAXaCq9bmhki5Ml9bD9mHtkx+rHB7J+BLi2E= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Sgfb61blGz4xW7; Thu, 30 Nov 2023 13:02:26 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v3 09/16] tcp: Remove unneccessary bounds check in tcp_timer_handler() Date: Thu, 30 Nov 2023 13:02:15 +1100 Message-ID: <20231130020222.4056647-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231130020222.4056647-1-david@gibson.dropbear.id.au> References: <20231130020222.4056647-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: UE57VGZNG5SVPMVORSWLZRDNCXPDRWIN X-Message-ID-Hash: UE57VGZNG5SVPMVORSWLZRDNCXPDRWIN 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_timer_handler() we use conn_at_idx() to interpret the flow index from the epoll reference. However, this will never be NULL - we always put a valid index into the epoll_ref. Simplify slightly based on this. Signed-off-by: David Gibson --- tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index f427047..512baf3 100644 --- a/tcp.c +++ b/tcp.c @@ -2759,10 +2759,10 @@ void tcp_listen_handler(struct ctx *c, union epoll_ref ref, */ void tcp_timer_handler(struct ctx *c, union epoll_ref ref) { - struct tcp_tap_conn *conn = conn_at_idx(ref.tcp.index); struct itimerspec check_armed = { { 0 }, { 0 } }; + struct tcp_tap_conn *conn = CONN(ref.tcp.index); - if (c->no_tcp || !conn) + if (c->no_tcp) return; /* We don't reset timers on ~ACK_FROM_TAP_DUE, ~ACK_TO_TAP_DUE. If the -- 2.43.0