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
_______________________________________________
freebsd-amd64@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
To unsubscribe, send any mail to "freebsd-amd64-unsubscr...@freebsd.org"

Reply via email to