net: context: keep randomly assigned port for TCP bind() calls
Prior to commit df201a0e ("net: context: Assign a random port number when context is created"), TCP clients were assigned a random port number when the incoming sockaddr parameter's port value was 0. After the above commit, this is now broken as it will bind to port 0. If left this way, every TCP client would need to add a line of code copying the context->local sockaddr_ptr's port value into the src_sockaddr port prior to calling net_context_bin(). Instead, we can reinstate this behavior in net_context_bind(), by making sure we only overwrite the randomly assigned port in the context->local sockaddr if the incoming sockaddr parameter has a port which is != 0. Change-Id: I0f27f031f743d50c351ecf9ab55b5282a20ff292 Signed-off-by:Michael Scott <michael.scott@linaro.org>
Loading
Please sign in to comment