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 <alviro.iskandar@xxxxxxxxxxx> Tested-by: Alviro Iskandar Setiawan <alviro.iskandar@xxxxxxxxxxx> (tested on 5.19) tq -- Viro