Date: Fri, 16 Nov 2001 17:49:04 +0000 From: Ian Dowse <iedowse@maths.tcd.ie> To: Dag-Erling Smorgrav <des@ofug.org> Cc: Ian Dowse <iedowse@maths.tcd.ie>, Takanori Saneto <sanewo@ba2.so-net.ne.jp>, emulation@FreeBSD.ORG Subject: Re: Linuxulator MFC and VMware Message-ID: <200111161749.aa32146@salmon.maths.tcd.ie> In-Reply-To: Your message of "16 Nov 2001 18:10:08 %2B0100." <xzpofm2od5b.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <xzpofm2od5b.fsf@flood.ping.uio.no>, Dag-Erling Smorgrav writes: > >Corrected patch attached (and uploaded to the usual place). Ok, I tried a -stable version of that. It got past the LINUX_SIOCGIFADDR ioctl, but failed on the LINUX_SIOCGIFFLAGS call. I added SIOCGIFFLAGS conversion to linux_ioctl_special and the code that calls it, and vmware got past setting up the network interface but died with a vmware panic as soon as the guest OS tried to use the network. I then fixed two cases where the ioctl handlers should have been returning ENOIOCTL (one was blindly calling ioctl() with no translation and the other returned ENOTTY). Now it works. Below is the full patch I used (against -stable). Ian Index: linux_ioctl.c =================================================================== RCS file: /home/iedowse/CVS/src/sys/compat/linux/linux_ioctl.c,v retrieving revision 1.55.2.5 diff -u -r1.55.2.5 linux_ioctl.c --- linux_ioctl.c 2001/11/05 19:08:22 1.55.2.5 +++ linux_ioctl.c 2001/11/16 17:43:11 @@ -66,6 +66,7 @@ static linux_ioctl_function_t linux_ioctl_sound; static linux_ioctl_function_t linux_ioctl_termio; static linux_ioctl_function_t linux_ioctl_private; +static linux_ioctl_function_t linux_ioctl_special; static struct linux_ioctl_handler cdrom_handler = { linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX }; @@ -1348,9 +1349,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 @@ -1508,7 +1511,8 @@ { char lifname[LINUX_IFNAMSIZ], ifname[IFNAMSIZ]; struct ifnet *ifp; - int error; + struct file *fp; + int error, type; KASSERT(LINUX_IFNAMSIZ == IFNAMSIZ, (__FUNCTION__ "(): LINUX_IFNAMSIZ != IFNAMSIZ")); @@ -1516,6 +1520,22 @@ ifp = NULL; error = 0; + if (args->fd >= p->p_fd->fd_nfiles || + (fp = p->p_fd->fd_ofiles[args->fd]) == NULL) + return (EBADF); + type = fp->f_type; + + if (type != DTYPE_SOCKET) { + /* not a socket - probably a tap / vmnet device */ + switch (args->cmd) { + case LINUX_SIOCGIFADDR: + case LINUX_SIOCSIFADDR: + case LINUX_SIOCGIFFLAGS: + return (linux_ioctl_special(p, args)); + default: + return (ENOIOCTL); + } + } switch (args->cmd & 0xffff) { case LINUX_FIOGETOWN: @@ -1535,6 +1555,7 @@ case LINUX_SIOCGIFFLAGS: case LINUX_SIOCGIFADDR: + case LINUX_SIOCSIFADDR: case LINUX_SIOCGIFDSTADDR: case LINUX_SIOCGIFBRDADDR: case LINUX_SIOCGIFNETMASK: @@ -1619,6 +1640,12 @@ error = ioctl(p, (struct ioctl_args *)args); break; + case LINUX_SIOCSIFADDR: + /* XXX probably doesn't work, included for completeness */ + args->cmd = SIOCSIFADDR; + error = ioctl(p, (struct ioctl_args *)args); + break; + case LINUX_SIOCGIFDSTADDR: args->cmd = OSIOCGIFDSTADDR; error = ioctl(p, (struct ioctl_args *)args); @@ -1700,7 +1727,36 @@ } if (type == DTYPE_SOCKET) return (linux_ioctl_socket(p, args)); - return (ioctl(p, (struct ioctl_args *)args)); + return (ENOIOCTL); +} + +/* + * Special ioctl handler + */ + +static int +linux_ioctl_special(struct proc *p, struct linux_ioctl_args *args) +{ + int error; + + switch (args->cmd) { + case LINUX_SIOCGIFADDR: + args->cmd = SIOCGIFADDR; + error = ioctl(p, (struct ioctl_args *)args); + break; + case LINUX_SIOCSIFADDR: + args->cmd = SIOCSIFADDR; + error = ioctl(p, (struct ioctl_args *)args); + break; + case LINUX_SIOCGIFFLAGS: + args->cmd = SIOCGIFFLAGS; + error = ioctl(p, (struct ioctl_args *)args); + break; + default: + error = ENOIOCTL; + } + + return (error); } /* Index: linux_ioctl.h =================================================================== RCS file: /home/iedowse/CVS/src/sys/compat/linux/linux_ioctl.h,v retrieving revision 1.4.2.2 diff -u -r1.4.2.2 linux_ioctl.h --- linux_ioctl.h 2001/11/05 19:08:22 1.4.2.2 +++ linux_ioctl.h 2001/11/16 17:24:21 @@ -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? <200111161749.aa32146>