aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2002-01-10 05:36:36 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2002-01-10 05:36:36 +0000
commit217bab1e7758e8653081eaf38c00603330df02e6 (patch)
tree131063e6631dab881d1abb397cdb756dad42f1a3 /sys/compat
parentee3c29eb792f2ce3e323671488eb4f6cf454fcf1 (diff)
downloadsrc-217bab1e7758e8653081eaf38c00603330df02e6.tar.gz
src-217bab1e7758e8653081eaf38c00603330df02e6.zip
Further fixes related to the interface renaming. Now that we
properly translate the interface name passed to us, make sure we also translate correctly before we return the list of interfaces with the SIOCGIFCONF ioctl. It is common to use the interface names returned by that ioctl in further ioctls, such as SIOCGIFFLAGS. Remove linux_ifname as it is no longer used. Also remove ifname_bsd_to_linux as it cannot be used anymore now that linux_ifname is removed (was deadcode anyway). Reported and tested by: Andrew Atrens <atrens@nortelnetworks.com>
Notes
Notes: svn path=/head/; revision=89182
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_ioctl.c64
1 files changed, 12 insertions, 52 deletions
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index b81c45982572..f5ab820f6db9 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -1733,54 +1733,6 @@ linux_ioctl_console(struct thread *td, struct linux_ioctl_args *args)
#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER)
/*
- * Construct the Linux name for an interface
- */
-
-int
-linux_ifname(struct ifnet *ifp, char *name, size_t size)
-{
- if (IFP_IS_ETH(ifp))
- return snprintf(name, LINUX_IFNAMSIZ,
- "eth%d", ifp->if_index);
- return snprintf(name, LINUX_IFNAMSIZ,
- "%s%d", ifp->if_name, ifp->if_unit);
-}
-
-/*
- * Translate a FreeBSD interface name to a Linux interface name,
- * and return the associated ifnet structure.
- * bsdname and lxname need to be least IFNAMSIZ bytes long, but
- * can point to the same buffer.
- */
-#if 0
-static struct ifnet *
-ifname_bsd_to_linux(const char *bsdname, char *lxname)
-{
- struct ifnet *ifp;
- int len, unit;
- char *ep;
-
- for (len = 0; len < IFNAMSIZ; ++len)
- if (!isalpha(bsdname[len]))
- break;
- if (len == 0 || len == IFNAMSIZ)
- return (NULL);
- unit = (int)strtoul(bsdname + len, &ep, 10);
- if (ep == NULL || ep == bsdname + len || ep >= bsdname + IFNAMSIZ)
- return (NULL);
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
- if (ifp->if_unit == unit && ifp->if_name[len] == '\0' &&
- strncmp(ifp->if_name, bsdname, len) == 0)
- break;
- }
- if (ifp != NULL)
- linux_ifname(ifp, lxname, LINUX_IFNAMSIZ);
-
- return (ifp);
-}
-#endif
-
-/*
* Translate a Linux interface name to a FreeBSD interface name,
* and return the associated ifnet structure
* bsdname and lxname need to be least IFNAMSIZ bytes long, but
@@ -1834,8 +1786,8 @@ linux_ifconf(struct thread *td, struct ifconf *uifc)
struct ifnet *ifp;
struct iovec iov;
struct uio uio;
- int error;
-
+ int error, ethno;
+
error = copyin(uifc, &ifc, sizeof ifc);
if (error != 0)
return (error);
@@ -1851,12 +1803,20 @@ linux_ifconf(struct thread *td, struct ifconf *uifc)
uio.uio_rw = UIO_READ;
uio.uio_td = td;
+ /* Keep track of eth interfaces */
+ ethno = 0;
+
/* return interface names but no addresses. */
TAILQ_FOREACH(ifp, &ifnet, if_link) {
if (uio.uio_resid <= 0)
break;
bzero(&ifr, sizeof ifr);
- linux_ifname(ifp, ifr.ifr_name, LINUX_IFNAMSIZ);
+ if (IFP_IS_ETH(ifp))
+ snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d",
+ ethno++);
+ else
+ snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "%s%d",
+ ifp->if_name, ifp->if_unit);
error = uiomove((caddr_t)&ifr, sizeof ifr, &uio);
if (error != 0)
return (error);
@@ -1864,7 +1824,7 @@ linux_ifconf(struct thread *td, struct ifconf *uifc)
ifc.ifc_len -= uio.uio_resid;
error = copyout(&ifc, uifc, sizeof ifc);
-
+
return (error);
}