From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by gnuweeb.org (Postfix) with ESMTPSA id 84B5B80C49 for ; Fri, 2 Sep 2022 06:36:03 +0000 (UTC) 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-f51.google.com with SMTP id p16so1906356lfd.6 for ; Thu, 01 Sep 2022 23:36:03 -0700 (PDT) X-Gm-Message-State: ACgBeo0BB7PEKx827I0NjgW22z4TH9OD0Kas9IAJOiIr7Ea9I+X1tXXp 1liqcj1uFUYPrXVdXlbwYu+b5nNdlcgaidkJC+U= 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" List-Id: 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