Date: 07 Nov 2001 16:58:41 +0100 From: Dag-Erling Smorgrav <des@ofug.org> To: "K.Sumitani" <ksumitani@mui.biglobe.ne.jp> Cc: Marcel Moolenaar <marcel@cup.hp.com>, emulation@FreeBSD.ORG Subject: Re: Linuxulator MFC and VMware Message-ID: <xzpy9li7etq.fsf@flood.ping.uio.no> In-Reply-To: <xzp3d3q8vsj.fsf@flood.ping.uio.no> References: <20011107234409.XACFC0A8274C.C78F0C8A@mail.biglobe.ne.jp> <xzp3d3q8vsj.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-= Dag-Erling Smorgrav <des@ofug.org> writes: > I'll have a patch ready later tonight. Attached. This is a hack; it's linux_ioctl()'s responsibility to check that the fd is a socket before calling linux_ioctl_socket(), and there should be a separate function for non-socket GIFADDR/SIFADDR/PRIVATE ioctls. I'll see if I can come up with something better when I'm back from Brighton; in the meantime, use either Marcel's patch or this one if they work and don't break anything else (I think Marcel's patch breaks ifconfig). DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=linux_ioctl.diff Index: sys/compat/linux/linux_ioctl.c =================================================================== RCS file: /home/ncvs/src/sys/compat/linux/linux_ioctl.c,v retrieving revision 1.71 diff -u -r1.71 linux_ioctl.c --- sys/compat/linux/linux_ioctl.c 20 Oct 2001 00:01:26 -0000 1.71 +++ sys/compat/linux/linux_ioctl.c 7 Nov 2001 15:50:15 -0000 @@ -1348,9 +1348,11 @@ return (ENOIOCTL); } -#define IFP_IS_ETH(ifp) ((ifp->if_flags & \ - (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST)) == \ - IFF_BROADCAST) +/* + * Criteria for interface name translation + */ + +#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER) /* * Construct the Linux name for an interface @@ -1541,7 +1543,9 @@ { char lifname[LINUX_IFNAMSIZ], ifname[IFNAMSIZ]; struct ifnet *ifp; - int error; + struct filedesc *fdp; + struct file *fp; + int error, type; KASSERT(LINUX_IFNAMSIZ == IFNAMSIZ, (__FUNCTION__ "(): LINUX_IFNAMSIZ != IFNAMSIZ")); @@ -1549,6 +1553,17 @@ ifp = NULL; error = 0; + mtx_lock(&Giant); + fdp = td->td_proc->p_fd; + if (args->fd >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[args->fd]) == NULL) { + mtx_unlock(&Giant); + return (EBADF); + } else { + type = fp->f_type; + } + mtx_unlock(&Giant); + switch (args->cmd & 0xffff) { case LINUX_FIOGETOWN: @@ -1560,14 +1575,11 @@ case LINUX_SIOCGPGRP: case LINUX_SIOCSPGRP: /* these ioctls don't take an interface name */ -#ifdef DEBUG - printf(__FUNCTION__ "(): ioctl %d\n", - args->cmd & 0xffff); -#endif break; case LINUX_SIOCGIFFLAGS: case LINUX_SIOCGIFADDR: + case LINUX_SIOCSIFADDR: case LINUX_SIOCGIFDSTADDR: case LINUX_SIOCGIFBRDADDR: case LINUX_SIOCGIFNETMASK: @@ -1579,14 +1591,14 @@ case LINUX_SIOCSIFHWADDR: case LINUX_SIOCDEVPRIVATE: case LINUX_SIOCDEVPRIVATE+1: + if (type != DTYPE_SOCKET) + /* not a socket - no translation */ + break; + /* copy in the interface name and translate it. */ error = copyin((char *)args->arg, lifname, LINUX_IFNAMSIZ); if (error != 0) return (error); -#ifdef DEBUG - printf(__FUNCTION__ "(): ioctl %d on %.*s\n", - args->cmd & 0xffff, LINUX_IFNAMSIZ, lifname); -#endif ifp = ifname_linux_to_bsd(lifname, ifname); if (ifp == NULL) return (EINVAL); @@ -1652,6 +1664,12 @@ error = ioctl(td, (struct ioctl_args *)args); break; + case LINUX_SIOCSIFADDR: + /* XXX probably doesn't work, included for completeness */ + args->cmd = SIOCSIFADDR; + error = ioctl(td, (struct ioctl_args *)args); + break; + case LINUX_SIOCGIFDSTADDR: args->cmd = OSIOCGIFDSTADDR; error = ioctl(td, (struct ioctl_args *)args); @@ -1722,9 +1740,6 @@ /* restore the original interface name */ copyout(lifname, (char *)args->arg, LINUX_IFNAMSIZ); -#ifdef DEBUG - printf(__FUNCTION__ "(): returning %d\n", error); -#endif return (error); } Index: sys/compat/linux/linux_ioctl.h =================================================================== RCS file: /home/ncvs/src/sys/compat/linux/linux_ioctl.h,v retrieving revision 1.7 diff -u -r1.7 linux_ioctl.h --- sys/compat/linux/linux_ioctl.h 20 Oct 2001 00:01:26 -0000 1.7 +++ sys/compat/linux/linux_ioctl.h 7 Nov 2001 15:43:32 -0000 @@ -133,6 +133,7 @@ #define LINUX_SIOCGIFCONF 0x8912 #define LINUX_SIOCGIFFLAGS 0x8913 #define LINUX_SIOCGIFADDR 0x8915 +#define LINUX_SIOCSIFADDR 0x8916 #define LINUX_SIOCGIFDSTADDR 0x8917 #define LINUX_SIOCGIFBRDADDR 0x8919 #define LINUX_SIOCGIFNETMASK 0x891b --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpy9li7etq.fsf>