diff options
| author | Bernard Xiong <[email protected]> | 2019-04-28 07:44:43 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-04-28 07:44:43 +0800 |
| commit | b57e075867ec075f520863757906ced4d181357e (patch) | |
| tree | 21abaa91d5b0549ec6496412ad928810a27c1f5f /components/net/sal_socket/src | |
| parent | 77973d8d34f0fb13cb1aecdc5c9a31394bdb0272 (diff) | |
| parent | c9bea68240cbc0fb9bc5823c928021333a603026 (diff) | |
Merge pull request #2626 from Lawlieta/develop
[net][netdev] Fix netdev link_down status, socket create failed issue
Diffstat (limited to 'components/net/sal_socket/src')
| -rw-r--r-- | components/net/sal_socket/src/sal_socket.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c index f4d5549aad..68e1375849 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -370,7 +370,7 @@ static int socket_init(int family, int type, int protocol, struct sal_socket **r struct sal_proto_family *pf; struct netdev *netdv_def = netdev_default; struct netdev *netdev = RT_NULL; - rt_bool_t falgs = RT_FALSE; + rt_bool_t flag = RT_FALSE; if (family < 0 || family > AF_MAX) { @@ -388,26 +388,24 @@ 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 (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)) - { - sock->netdev = netdv_def; - falgs = RT_TRUE; - } - } - } - else + if (netdv_def == RT_NULL) { LOG_E("not find default network interface device for socket create."); return -3; } + + if (netdev_is_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)) + { + sock->netdev = netdv_def; + flag = RT_TRUE; + } + } - if (falgs == RT_FALSE) + if (flag == RT_FALSE) { /* get network interface device by protocol family */ netdev = netdev_get_by_family(family); @@ -516,8 +514,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); |
