Module Name:    src
Committed By:   christos
Date:           Tue May 12 20:42:46 UTC 2015

Modified Files:
        src/sys/compat/common: if_43.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/compat/common/if_43.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/if_43.c
diff -u src/sys/compat/common/if_43.c:1.9 src/sys/compat/common/if_43.c:1.10
--- src/sys/compat/common/if_43.c:1.9	Sun Nov  9 12:48:07 2014
+++ src/sys/compat/common/if_43.c	Tue May 12 16:42:46 2015
@@ -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 @@ compat_ifioctl(struct socket *so, u_long
 {
 	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 @@ compat_ifioctl(struct socket *so, u_long
 			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 @@ compat_ifioctl(struct socket *so, u_long
 	case OOSIOCGIFNETMASK:
 		*(u_int16_t *)&ifr->ifr_addr = 
 		    ((struct sockaddr *)&ifr->ifr_addr)->sa_family;
+		break;
 	}
+
+	if (cmd != ocmd)
+		ifreqn2o(oifr, ifr);
+
 	return error;
 }

Reply via email to