Skip to content

Commit

Permalink
net: context: set context->local for offloaded iface
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wojciechslenska authored and carlescufi committed Oct 4, 2023
1 parent 01bdd84 commit dcf6327
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions subsys/net/ip/net_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit dcf6327

Please sign in to comment.