diff --git a/components/net/netdev/include/netdev.h b/components/net/netdev/include/netdev.h index 05761bade6b..925b038e186 100644 --- a/components/net/netdev/include/netdev.h +++ b/components/net/netdev/include/netdev.h @@ -159,6 +159,7 @@ struct netdev *netdev_get_by_family(int family); int netdev_family_get(struct netdev *netdev); #endif /* RT_USING_SAL */ #if defined(SAL_USING_AF_NETLINK) +struct msg_buf; int netdev_getnetdev(struct msg_buf *msg, int (*cb)(struct msg_buf *m_buf, struct netdev *nd, int nd_num, int index, int ipvx)); #endif diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c index 5a4056b97a7..13cb89dc398 100644 --- a/components/net/netdev/src/netdev.c +++ b/components/net/netdev/src/netdev.c @@ -449,16 +449,15 @@ int netdev_getnetdev(struct msg_buf *msg, int (*cb)(struct msg_buf *m_buf, struc nd_num = rt_slist_len(&cur_nd_list->list) + 1; rt_spin_unlock(&_spinlock); - err = cb(msg, cur_nd_list, nd_num, nd.ifindex, ROUTE_IPV4_TRUE); + err = cb(msg, cur_nd_list, nd_num, cur_nd_list->ifindex, ROUTE_IPV4_TRUE); if (err < 0) return err; - rt_spin_lock(&_spinlock); rt_slist_for_each_entry(nd_node, &(cur_nd_list->list), list) { rt_spin_unlock(&_spinlock); - err = cb(msg, nd_node, nd_num, nd.ifindex, ROUTE_IPV4_TRUE); + err = cb(msg, nd_node, nd_num, nd_node->ifindex, ROUTE_IPV4_TRUE); if (err < 0) { return err;