[net][netdev] Fix netdev link_down status, socket create failed issue

Signed-off-by: chenyong <1521761801@qq.com>
This commit is contained in:
chenyong
2019-04-27 17:24:58 +08:00
parent c0a400ccbe
commit 2721e7189a
2 changed files with 8 additions and 15 deletions
+6 -11
View File
@@ -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);