mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-26 14:54:35 +08:00
[net][netdev] Fix netdev link_down status, socket create failed issue
Signed-off-by: chenyong <1521761801@qq.com>
This commit is contained in:
@@ -388,17 +388,14 @@ static int socket_init(int family, int type, int protocol, struct sal_socket **r
|
||||
sock->protocol = protocol;
|
||||
|
||||
/* get socket operations from network interface device */
|
||||
if (netdv_def)
|
||||
if (netdv_def && netdev_is_up(netdv_def))
|
||||
{
|
||||
if (netdev_is_up(netdv_def) && netdev_is_link_up(netdv_def))
|
||||
/* check default network interface device protocol family */
|
||||
pf = (struct sal_proto_family *) netdv_def->sal_user_data;
|
||||
if (pf != RT_NULL && pf->skt_ops && (pf->family == family || pf->sec_family == family))
|
||||
{
|
||||
/* check default network interface device protocol family */
|
||||
pf = (struct sal_proto_family *) netdv_def->sal_user_data;
|
||||
if (pf != RT_NULL && pf->skt_ops && (pf->family == family || pf->sec_family == family))
|
||||
{
|
||||
sock->netdev = netdv_def;
|
||||
falgs = RT_TRUE;
|
||||
}
|
||||
sock->netdev = netdv_def;
|
||||
falgs = RT_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -516,8 +513,6 @@ int sal_accept(int socket, struct sockaddr *addr, socklen_t *addrlen)
|
||||
/* get the socket object by socket descriptor */
|
||||
SAL_SOCKET_OBJ_GET(sock, socket);
|
||||
|
||||
/* check the network interface is commonicable */
|
||||
SAL_NETDEV_IS_COMMONICABLE(sock->netdev);
|
||||
/* check the network interface socket operations */
|
||||
SAL_NETDEV_SOCKETOPS_VALID(sock->netdev, pf, accept);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user