From dcf6327d6ad75208b15be47758411a7f9b820afd Mon Sep 17 00:00:00 2001 From: Wojciech Slenska Date: Wed, 4 Oct 2023 13:46:17 +0200 Subject: [PATCH] net: context: set context->local for offloaded iface Currently context->local is not set for offloaded interface. This change move net_offload_bind call after set of context->local. Signed-off-by: Wojciech Slenska --- subsys/net/ip/net_context.c | 38 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index c611f48b3fa292..9de988e54f8d94 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -709,24 +709,19 @@ int net_context_bind(struct net_context *context, const struct sockaddr *addr, return -EADDRNOTAVAIL; } - if (IS_ENABLED(CONFIG_NET_OFFLOAD) && - net_if_is_ip_offloaded(iface)) { - net_context_set_iface(context, iface); - - return net_offload_bind(iface, - context, - addr, - addrlen); - } - k_mutex_lock(&context->lock, K_FOREVER); - ret = 0; - net_context_set_iface(context, iface); net_sin6_ptr(&context->local)->sin6_family = AF_INET6; net_sin6_ptr(&context->local)->sin6_addr = ptr; + + if (IS_ENABLED(CONFIG_NET_OFFLOAD) && net_if_is_ip_offloaded(iface)) { + k_mutex_unlock(&context->lock); + return net_offload_bind(iface, context, addr, addrlen); + } + + ret = 0; if (addr6->sin6_port) { ret = check_used_port(context->proto, addr6->sin6_port, @@ -811,24 +806,19 @@ int net_context_bind(struct net_context *context, const struct sockaddr *addr, return -EADDRNOTAVAIL; } - if (IS_ENABLED(CONFIG_NET_OFFLOAD) && - net_if_is_ip_offloaded(iface)) { - net_context_set_iface(context, iface); - - return net_offload_bind(iface, - context, - addr, - addrlen); - } - k_mutex_lock(&context->lock, K_FOREVER); - ret = 0; - net_context_set_iface(context, iface); net_sin_ptr(&context->local)->sin_family = AF_INET; net_sin_ptr(&context->local)->sin_addr = ptr; + + if (IS_ENABLED(CONFIG_NET_OFFLOAD) && net_if_is_ip_offloaded(iface)) { + k_mutex_unlock(&context->lock); + return net_offload_bind(iface, context, addr, addrlen); + } + + ret = 0; if (addr4->sin_port) { ret = check_used_port(context->proto, addr4->sin_port,