net/: Remove all references to CONFIG_NET_USER_DEVFMT. That feature is now unconditionally enabled. This was done because (1) the feature does not require very much additional memory, and (2) it causes confusion in the configuration due to the additional complexity. And network drivers that fail to zero the device structure interface name field (d_ifname) because calling netdev_register() will, however, get a nasty surprise.

This commit is contained in:
Gregory Nutt 2018-08-14 08:01:52 -06:00
parent b6151ce997
commit 4a724b1f3c
3 changed files with 32 additions and 13 deletions

View File

@ -1381,6 +1381,11 @@ int net_vfcntl(int sockfd, int cmd, va_list ap);
* Register a network device driver and assign a name to it so that it can
* be found in subsequent network ioctl operations on the device.
*
* A custom, device-specific interface name format string may be selected
* by putting that format string into the device structure's d_ifname[]
* array before calling netdev_register(). Otherwise, the d_ifname[] must
* be zeroed on entry.
*
* Input Parameters:
* dev - The device driver structure to be registered.
* lltype - Link level protocol used by the driver (Ethernet, SLIP, TUN, ...

View File

@ -102,13 +102,6 @@ endmenu # Driver buffer configuration
menu "Link layer support"
config NET_USER_DEVFMT
bool "User provided devfmt"
default n
depends on EXPERIMENTAL
---help---
netdev_register will get devfmt form d_ifname if it is initialized.
config NET_ETHERNET
bool "Ethernet support"
default y

View File

@ -232,6 +232,11 @@ static int get_ifindex(void)
* Register a network device driver and assign a name to it so that it can
* be found in subsequent network ioctl operations on the device.
*
* A custom, device-specific interface name format string may be selected
* by putting that format string into the device structure's d_ifname[]
* array before calling netdev_register(). Otherwise, the d_ifname[] must
* be zeroed on entry.
*
* Input Parameters:
* dev - The device driver structure to be registered.
* lltype - Link level protocol used by the driver (Ethernet, SLIP, TUN, ...
@ -248,10 +253,8 @@ static int get_ifindex(void)
int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
{
FAR const char *devfmt;
#ifdef CONFIG_NET_USER_DEVFMT
FAR const char devfmt_str[IFNAMSIZ];
#endif
FAR const char *devfmt;
int devnum;
#ifdef CONFIG_NETDEV_IFINDEX
int ifindex;
@ -374,13 +377,31 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
devnum = find_devnum(devfmt);
}
#ifdef CONFIG_NET_USER_DEVFMT
if (*dev->d_ifname)
/* Check if the caller has provided a user device-specific interface
* name format string (in d_ifname).
*/
if (dev->d_ifname[0] != '\0')
{
/* Copy the string in a temporary buffer. How do we know that the
* string is valid and not just uninitialized memory? We don't.
* Let's at least make certain that the format string is NUL
* terminated.
*/
dev->d_ifname[IFNAMSIZ - 1] = '\0';
strncpy(devfmt_str, dev->d_ifname, IFNAMSIZ);
/* Then use the content of the temporary buffer as the format
* string.
*/
devfmt = devfmt_str;
}
#endif
/* Complete the device name by including the device number (if
* included in the format).
*/
snprintf(dev->d_ifname, IFNAMSIZ, devfmt, devnum);