mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-30 02:51:33 +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:
parent
c0a400ccbe
commit
2721e7189a
@ -269,8 +269,7 @@ struct netdev *netdev_get_by_family(int family)
|
||||
{
|
||||
netdev = rt_slist_entry(node, struct netdev, list);
|
||||
pf = (struct sal_proto_family *) netdev->sal_user_data;
|
||||
if (pf && pf->skt_ops && pf->family == family &&
|
||||
netdev_is_up(netdev) && netdev_is_link_up(netdev))
|
||||
if (pf && pf->skt_ops && pf->family == family && netdev_is_up(netdev))
|
||||
{
|
||||
rt_hw_interrupt_enable(level);
|
||||
return netdev;
|
||||
@ -281,8 +280,7 @@ struct netdev *netdev_get_by_family(int family)
|
||||
{
|
||||
netdev = rt_slist_entry(node, struct netdev, list);
|
||||
pf = (struct sal_proto_family *) netdev->sal_user_data;
|
||||
if (pf && pf->skt_ops && pf->sec_family == family &&
|
||||
netdev_is_up(netdev) && netdev_is_link_up(netdev))
|
||||
if (pf && pf->skt_ops && pf->sec_family == family && netdev_is_up(netdev))
|
||||
{
|
||||
rt_hw_interrupt_enable(level);
|
||||
return netdev;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user