summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2001-12-04 03:55:10 +0000
committermarcel <marcel@FreeBSD.org>2001-12-04 03:55:10 +0000
commitdefebc6748ca524ab5d1222be8c5e4e2ae2c5bd5 (patch)
tree500f12bec4699f58c3a823d3d76eb68222f261d7 /sys/compat
parentbfc21cbe2fe8c46a29b5324e1ca1505d706dc23b (diff)
downloadFreeBSD-src-defebc6748ca524ab5d1222be8c5e4e2ae2c5bd5.zip
FreeBSD-src-defebc6748ca524ab5d1222be8c5e4e2ae2c5bd5.tar.gz
When translating the interface name when "eth?" is given, do not
use the internal index number as the unit number to compare with. The first ethernet interface in Linux is called "eth0", whereas our internal index starts wth 1 and is not unique to ethernet interfaces (lo0 has index 1 for example). Instead, use a function- local index number that starts with 0 and is incremented only for ethernet interfaces. This way the unit number will match the n-th ethernet interface in the system, which is exactly what it means in Linux. Tested by: Glenn Johnson <gjohnson@srrc.ars.usda.gov> MFC after: 3 days
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_ioctl.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index d3eea0d..31cdd6a 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -1793,6 +1793,7 @@ ifname_linux_to_bsd(const char *lxname, char *bsdname)
struct ifnet *ifp;
int len, unit;
char *ep;
+ int is_eth, index;
for (len = 0; len < LINUX_IFNAMSIZ; ++len)
if (!isalpha(lxname[len]))
@@ -1802,13 +1803,18 @@ ifname_linux_to_bsd(const char *lxname, char *bsdname)
unit = (int)strtoul(lxname + len, &ep, 10);
if (ep == NULL || ep == lxname + len || ep >= lxname + LINUX_IFNAMSIZ)
return (NULL);
+ index = 0;
+ is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0;
TAILQ_FOREACH(ifp, &ifnet, if_link) {
- /* allow Linux programs to use FreeBSD names */
+ /*
+ * Allow Linux programs to use FreeBSD names. Don't presume
+ * we never have an interface named "eth", so don't make
+ * the test optional based on is_eth.
+ */
if (ifp->if_unit == unit && ifp->if_name[len] == '\0' &&
strncmp(ifp->if_name, lxname, len) == 0)
break;
- if (ifp->if_index == unit && IFP_IS_ETH(ifp) &&
- strncmp(lxname, "eth", len) == 0)
+ if (is_eth && IFP_IS_ETH(ifp) && unit == index++)
break;
}
if (ifp != NULL)
OpenPOWER on IntegriCloud