Message-ID: Date: Wed, 6 Dec 2023 15:28:13 +0100 MIME-Version: 1.0 References: Content-Language: en-GB From: Arne Schwabe In-Reply-To: Subject: Re: [Openvpn-devel] [PATCH] fix(ssl): init peer_id when init tls_multi List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit To: yatta , openvpn-devel@lists.sourceforge.net Cc: pushan <62173185+pushan01@...2243...> Am 19.10.23 um 19:12 schrieb yatta: > From: pushan <62173185+pushan01@...2243...> > > When openvpn run in UDP server mode, if ssl connections reach the max clients, the next connection would be failed in `multi_create_instance` and the half connection will be close in `multi_close_instance`, which may lead array `m->instances[0]` covered unexpectedly and make the first connection interrupt, this patch fix this problem by init `peer_id` with `MAX_PEER_ID` in `tils_multi_init`. A bit more explanaition on this: When we create an instance in multi_create_instance we call inherit_context_child(&mi->context, &m->top); which in turn calls the tls_multi_init that is patched here. When I encounter an error during the creation in multi_create_instance we call multi_close_instance in the goto err branch. That multi_close_instance clears the instance from the dict if the peer_id is not MAX_PEER_ID. We probably should refactor this to be a bit cleaner in the future. Acked-By: Arne Schwabe