Date: Wed, 3 Nov 2010 12:21:10 +0300 From: Sergey Kandaurov <pluknet@gmail.com> To: Konstantin Belousov <kib@freebsd.org>, amd64@freebsd.org Subject: splitting if.c:ifhwioctl() onto native and compat32 functions Message-ID: <AANLkTinnP3SkJmQDHCENC8O%2BDfmu0NvNAX9B15MgHHZu@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi. I came to $subj conclusion after some playing with converting several IOCTLs from ifhwioctl() to COMPAT_FREEBSD32. If not break ifhwioctl then: - compat32 ioctl handlers would pollute the code and make it unreadable - some native and compat32 IOCTLs (f.e. SIOCGIFGENERIC32) both depend on structure with same size but different field layout, which much complicates the handling of such ioctls. I'd like to know your comments about the next prepreq. change. The main intention modulo misc changes is to find a way to place native and compat32 ioctls handling into its own functions. ifhwioctl32() body omitted intentionally. @@ -2475,17 +2961,20 @@ ifioctl(struct socket *so, u_long cmd, caddr_t dat ifp = ifunit_ref(ifr->ifr_name); if (ifp == NULL) return (ENXIO); + +#ifdef COMPAT_FREEBSD32 + if ((td->td_proc->p_sysent->sv_flags & SV_ILP32) != 0) + error = ifhwioctl32(cmd, ifp, data, td); + else +#endif + error = ifhwioctl(cmd, ifp, data, td); + if (error != ENOIOCTL) + goto done; - error = ifhwioctl(cmd, ifp, data, td); - if (error != ENOIOCTL) { - if_rele(ifp); - return (error); - } - oif_flags = ifp->if_flags; if (so->so_proto == NULL) { - if_rele(ifp); - return (EOPNOTSUPP); + error = EOPNOTSUPP; + goto done; } #ifndef COMPAT_43 error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, @@ -2558,6 +3047,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t dat } #endif } +done: if_rele(ifp); return (error); } -- wbr, pluknet
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinnP3SkJmQDHCENC8O%2BDfmu0NvNAX9B15MgHHZu>