From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AF41C54EE9 for ; Fri, 2 Sep 2022 06:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbiIBGgI (ORCPT ); Fri, 2 Sep 2022 02:36:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234495AbiIBGgH (ORCPT ); Fri, 2 Sep 2022 02:36:07 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37919F0CE for ; Thu, 1 Sep 2022 23:36:03 -0700 (PDT) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by gnuweeb.org (Postfix) with ESMTPSA id 9113680C57 for ; Fri, 2 Sep 2022 06:36:03 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662100563; bh=aWbe5crpfkIxJYQapTBkP164Wg8Td1gWINz/T4GUD8c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YC4hn32AbmRVfsAFvtaM6pZVMg1gKMrKd941RYXSiK5vVvjBtC+/ZNXXbxqaYATaW Rz31yIXmwufWK41CmBvVeN5NhXmfCgXZF+Qg64jf2DXMuxs+v29leGGsnvEGhuBxy5 uN2drwck7eoya4MHLnoqWxyZbeQOZdnATJfv0QKCK9Xz93XyVLjdxocZwyoiJbJ6GV Pd9I80fVDWSjUsIXmefHVHoXBQraQPeL0dvnfquXQx6j0Ia+mLLpOsUpHy5lSXlHVb ZpAXwrC6zhZCdkxzsNBQg1ik8xrmcE4nHqH7OOAXsiZGA0B40UtmFefUY9DzIhOWXA h+55IMetUgNEQ== Received: by mail-lf1-f47.google.com with SMTP id bq23so1898845lfb.7 for ; Thu, 01 Sep 2022 23:36:03 -0700 (PDT) X-Gm-Message-State: ACgBeo3wiI7CtFlG9OH5KlhU67g5aAFuVVvtPWY9Eaj+Air1yl1ghTrI tiEZRY2708Xu0bG1xq3GQdr5MZIE/RzzlQ3Nuow= X-Google-Smtp-Source: AA6agR4lHRArY/nzp1MgQ3KzVK2mXBKxFhUX4zktOpL3xKubujRCmw8K58Swcvagw9RGOCDs7o674orOEVwp5+qXF/s= X-Received: by 2002:a05:6512:3501:b0:48b:205f:91a2 with SMTP id h1-20020a056512350100b0048b205f91a2mr11591170lfs.83.1662100561715; Thu, 01 Sep 2022 23:36:01 -0700 (PDT) MIME-Version: 1.0 References: <20220902011548.2506938-1-ammar.faizi@intel.com> In-Reply-To: <20220902011548.2506938-1-ammar.faizi@intel.com> From: Alviro Iskandar Setiawan Date: Fri, 2 Sep 2022 13:35:50 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RESEND PATCH liburing v1 00/12] Introducing t_bind_ephemeral_port() function To: Ammar Faizi Cc: Jens Axboe , Dylan Yudaken , Facebook Kernel Team , Pavel Begunkov , io-uring Mailing List , "GNU/Weeb Mailing List" , Kanna Scarlet , Muhammad Rizki Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On Fri, Sep 2, 2022 at 8:18 AM Ammar Faizi wrote: > ## Solution: > Setting @addr->sin_port to zero on a bind() syscall lets the kernel > choose a port number that is not in use. The caller then can know the > port number to be bound by invoking a getsockname() syscall after > bind() succeeds. > > Wrap this procedure in a new function called t_bind_ephemeral_port(). > The selected port will be returned into @addr->sin_port, the caller > can use it later to connect() or whatever they need. with variable placement fix, for all patches: Reviewed-by: Alviro Iskandar Setiawan Tested-by: Alviro Iskandar Setiawan (tested on 5.19) tq -- Viro