net: context: Fix the ICMP error on udp

When receiving a UDP packet, net_conn_input() searches for a
matching connection within `conn_used`.

However, when receiving UDP packets simultaneously from multiple
clients, we may encounter a situation where the connection that was
supposed to be bound cannot be found within `conn_used`, and raise
the ICMP error.

This is because, within recv_udp(), to avoid the failure of
bind_default(), we temporarily remove it from `conn_used` using
net_conn_unregister().

If the context already has a connection handler, it means it's
already registered. In that case, all we have to do is 1) update
the callback registered in the net_context and 2) update the
user_data and remote address and port using net_conn_update().

Fixes #70020

Signed-off-by: Takuya Sasaki <takuya.sasaki@spacecubics.com>
(cherry picked from commit 4f802e11974591f758f84b2653d1b31f9c5e4f93)
1 file changed