Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/common rump is compiled with COMPAT_OSOCK not COM...



details:   https://anonhg.NetBSD.org/src/rev/66842d77e441
branches:  trunk
changeset: 338150:66842d77e441
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 12 20:42:46 2015 +0000

description:
rump is compiled with COMPAT_OSOCK not COMPAT_OIFREQ and the code in if.c
is not handling this case properly. Make this work by checking again if
we need to convert struct ifreq here, and if we do, we do it ourselves.

diffstat:

 sys/compat/common/if_43.c |  40 +++++++++++++++++++++++-----------------
 1 files changed, 23 insertions(+), 17 deletions(-)

diffs (81 lines):

diff -r 3ba8da8a2d4b -r 66842d77e441 sys/compat/common/if_43.c
--- a/sys/compat/common/if_43.c Tue May 12 19:43:50 2015 +0000
+++ b/sys/compat/common/if_43.c Tue May 12 20:42:46 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_43.c,v 1.9 2014/11/09 17:48:07 maxv Exp $   */
+/*     $NetBSD: if_43.c,v 1.10 2015/05/12 20:42:46 christos Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.9 2014/11/09 17:48:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.10 2015/05/12 20:42:46 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -216,12 +216,28 @@
 {
        int error;
        struct ifreq *ifr = (struct ifreq *)data;
+       struct ifreq ifrb;
+       struct oifreq *oifr = NULL;
        struct ifnet *ifp = ifunit(ifr->ifr_name);
        struct sockaddr *sa;
 
        if (ifp == NULL)
                return ENXIO;
 
+       /*
+        * If we have not been converted, make sure that we are.
+        * (because the upper layer handles old socket calls, but
+        * not oifreq calls.
+        */
+       if (cmd == ocmd) {
+               cmd = compat_cvtcmd(ocmd);
+               if (cmd != ocmd) {
+                       oifr = data;
+                       data = ifr = &ifrb;
+                       ifreqo2n(oifr, ifr);
+               }
+       }
+
        switch (ocmd) {
        case OSIOCSIFADDR:
        case OSIOCSIFDSTADDR:
@@ -238,21 +254,6 @@
                        sa->sa_len = 16;
 #endif
                break;
-
-       case OOSIOCGIFADDR:
-               cmd = SIOCGIFADDR;
-               break;
-
-       case OOSIOCGIFDSTADDR:
-               cmd = SIOCGIFDSTADDR;
-               break;
-
-       case OOSIOCGIFBRDADDR:
-               cmd = SIOCGIFBRDADDR;
-               break;
-
-       case OOSIOCGIFNETMASK:
-               cmd = SIOCGIFNETMASK;
        }
 
        error = (*so->so_proto->pr_usrreqs->pr_ioctl)(so, cmd, ifr, ifp);
@@ -264,6 +265,11 @@
        case OOSIOCGIFNETMASK:
                *(u_int16_t *)&ifr->ifr_addr = 
                    ((struct sockaddr *)&ifr->ifr_addr)->sa_family;
+               break;
        }
+
+       if (cmd != ocmd)
+               ifreqn2o(oifr, ifr);
+
        return error;
 }



Home | Main Index | Thread Index | Old Index