mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
net/procfs: Fix a design REVISIT from the integration the IFINDEX logic and the existing ifconfig/procfs logic.
This commit is contained in:
+19
-13
@@ -521,29 +521,35 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int ifindex = index - DEV_INDEX;
|
int ifindex;
|
||||||
|
|
||||||
/* Correct for the fact that the interface is not zero based */
|
|
||||||
|
|
||||||
ifindex++;
|
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_IFINDEX
|
#ifdef CONFIG_NETDEV_IFINDEX
|
||||||
/* Make sure the ifindex is a valid interface index. If not,
|
/* For the first network device, ifindex will be zero. We have
|
||||||
* skip to the next valid index.
|
* to take some special action to get the correct starting
|
||||||
*
|
* ifindex.
|
||||||
* REVISIT: That actual underlying indices may be sparse. The
|
|
||||||
* way that level1->base.nentries is set-up assumes that
|
|
||||||
* the indexing is continuous and this may cause entries to be
|
|
||||||
* lost in the output.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ifindex = netdev_nextindex(ifindex);
|
if (level1->ifindex == 0)
|
||||||
|
{
|
||||||
|
ifindex = netdev_nextindex(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ifindex = netdev_nextindex(level1->ifindex);
|
||||||
|
}
|
||||||
|
|
||||||
if (ifindex < 0)
|
if (ifindex < 0)
|
||||||
{
|
{
|
||||||
/* There are no more... one must have been unregistered */
|
/* There are no more... one must have been unregistered */
|
||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
level1->ifindex = ifindex + 1;
|
||||||
|
#else
|
||||||
|
/* Get the raw index, accounting for 1 based indexing */
|
||||||
|
|
||||||
|
ifindex = index - DEV_INDEX + 1;
|
||||||
#endif
|
#endif
|
||||||
/* Find the device corresponding to this device index */
|
/* Find the device corresponding to this device index */
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ struct netprocfs_level1_s
|
|||||||
{
|
{
|
||||||
struct procfs_dir_priv_s base; /* Base directory private data */
|
struct procfs_dir_priv_s base; /* Base directory private data */
|
||||||
char name[NAME_MAX + 1]; /* Name of last node visited */
|
char name[NAME_MAX + 1]; /* Name of last node visited */
|
||||||
|
#ifdef CONFIG_NETDEV_IFINDEX
|
||||||
|
uint8_t ifindex; /* Next ifindex to visit */
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Line generating function type */
|
/* Line generating function type */
|
||||||
|
|||||||
Reference in New Issue
Block a user