Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDPSocket::sendto does not work with ipv6 and local-link interface addresss #11442

Closed
slavaDev503 opened this issue Sep 9, 2019 · 5 comments
Closed

Comments

@slavaDev503
Copy link

@slavaDev503 slavaDev503 commented Sep 9, 2019

Description

UDP socket can`t send data to ipv6 destination address. The project with mbed os 5.13.0 work properly. But if I update mbed os to 5.13.1 or higher I have an error.

I research this problem and get code which work wrong (commit b272c5f):

 struct netif *netif_ = netif_get_by_index(s->conn->pcb.ip->netif_idx);
    if (!netif_) {
        netif_ = &default_interface->netif;
    }
    if (netif_) {
        if ((addr.version == NSAPI_IPv4 && !get_ipv4_addr(netif_)) ||
                (addr.version == NSAPI_IPv6 && !get_ipv6_addr(netif_))) {
            return NSAPI_ERROR_PARAMETER;
        }
    }

Function get_ipv6_addr iterate over all available ipv6 addresses and skip local-link address which is set during network initialization (EMACInterface::connect()->LWIP::Interface::bringup() -> netif_create_ip6_linklocal_address()). Because there is no one other ipv6 address in interface function return NULL. After that return NSAPI_ERROR_PARAMETER occur and socket sendto return error -3003.

target STM32F446ZE on nucleo board
toolchain GCC_ARM 6 2017-q2-update
mbed cli

Issue request type

[ ] Question
[ ] Enhancement
[x] Bug
@ciarmcom

This comment has been minimized.

Copy link
Member

@ciarmcom ciarmcom commented Sep 9, 2019

@ciarmcom ciarmcom added the mirrored label Sep 9, 2019
@0xc0170

This comment has been minimized.

Copy link
Member

@0xc0170 0xc0170 commented Sep 12, 2019

@tymoteuszblochmobica

This comment has been minimized.

Copy link
Contributor

@tymoteuszblochmobica tymoteuszblochmobica commented Sep 30, 2019

If adress is link local LWIP returns NULL.
const ip_addr_t *LWIP::get_ipv6_addr(const struct netif *netif)
{
#if LWIP_IPV6
if (!netif_is_up(netif)) {
return NULL;
}

for (int i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
    if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
            !ip6_addr_islinklocal(netif_ip6_addr(netif, i))) {
        return netif_ip_addr6(netif, i);
    }
}

#endif
return NULL;
}

@kjbracey-arm Does ip6_addr_islinklocal have special purpose in this function or can it be removed?

@michalpasztamobica

This comment has been minimized.

Copy link
Contributor

@michalpasztamobica michalpasztamobica commented Nov 20, 2019

@slavaDev503 , the fix is merged, please check if this works fine for you?

@0xc0170

This comment has been minimized.

Copy link
Member

@0xc0170 0xc0170 commented Nov 20, 2019

As we believe this was fixed, we will close. In case there is still an issue, please reopen or create a new bug report if are seeing different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.