Merge pull request #2628 from HubertXie/master

实现多网卡自动切换功能
This commit is contained in:
Bernard Xiong 2019-05-01 20:25:31 +08:00 committed by GitHub
commit c2244a5c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -269,7 +269,7 @@ struct netdev *netdev_get_by_family(int family)
{ {
netdev = rt_slist_entry(node, struct netdev, list); netdev = rt_slist_entry(node, struct netdev, list);
pf = (struct sal_proto_family *) netdev->sal_user_data; pf = (struct sal_proto_family *) netdev->sal_user_data;
if (pf && pf->skt_ops && pf->family == family && netdev_is_up(netdev)) if (pf && pf->skt_ops && pf->family == family && netdev_is_up(netdev) && netdev_is_link_up(netdev))
{ {
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
return netdev; return netdev;

View File

@ -394,7 +394,7 @@ static int socket_init(int family, int type, int protocol, struct sal_socket **r
return -3; return -3;
} }
if (netdev_is_up(netdv_def)) if (netdev_is_up(netdv_def) && netdev_is_link_up(netdv_def))
{ {
/* check default network interface device protocol family */ /* check default network interface device protocol family */
pf = (struct sal_proto_family *) netdv_def->sal_user_data; pf = (struct sal_proto_family *) netdv_def->sal_user_data;