summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravatar <avatar@FreeBSD.org>2017-05-15 22:51:22 +0000
committeravatar <avatar@FreeBSD.org>2017-05-15 22:51:22 +0000
commit925f3bde502f9c9f6a093d833e419c3d9afee4b3 (patch)
tree4bec20b87d812a2cd1890d410038ba5848309bca
parent83379d6a8d78669552953e860ff82b47ee49d390 (diff)
downloadFreeBSD-src-925f3bde502f9c9f6a093d833e419c3d9afee4b3.zip
FreeBSD-src-925f3bde502f9c9f6a093d833e419c3d9afee4b3.tar.gz
MFC 316658:
Adding SIOCGIFNAME support in Linuxulator. This should silence the console warning associated with linux-opera: linux: pid 23492 (opera): ioctl fd=5, cmd=0x8910 ('\M^I',16) is not implemented linux: pid 23492 (opera): ioctl fd=28, cmd=0x8910 ('\M^I',16) is not implemented ... Reviewed by: kib, marcel, dchagin Tested with: linux-opera-12.16_3
-rw-r--r--sys/compat/linux/linux_ioctl.c48
-rw-r--r--sys/compat/linux/linux_ioctl.h1
2 files changed, 49 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 867cdd2..b77db6c 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -2173,6 +2173,49 @@ ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
}
/*
+ * Implement the SIOCGIFNAME ioctl
+ */
+
+static int
+linux_ioctl_ifname(struct thread *td, struct l_ifreq *uifr)
+{
+ struct l_ifreq ifr;
+ struct ifnet *ifp;
+ int error, ethno, index;
+
+ error = copyin(uifr, &ifr, sizeof(ifr));
+ if (error != 0)
+ return (error);
+
+ CURVNET_SET(TD_TO_VNET(curthread));
+ IFNET_RLOCK();
+ index = 1; /* ifr.ifr_ifindex starts from 1 */
+ ethno = 0;
+ error = ENODEV;
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
+ if (ifr.ifr_ifindex == index) {
+ if (IFP_IS_ETH(ifp))
+ snprintf(ifr.ifr_name, LINUX_IFNAMSIZ,
+ "eth%d", ethno);
+ else
+ strlcpy(ifr.ifr_name, ifp->if_xname,
+ LINUX_IFNAMSIZ);
+ error = 0;
+ break;
+ }
+ if (IFP_IS_ETH(ifp))
+ ethno++;
+ index++;
+ }
+ IFNET_RUNLOCK();
+ if (error == 0)
+ error = copyout(&ifr, uifr, sizeof(ifr));
+ CURVNET_RESTORE();
+
+ return (error);
+}
+
+/*
* Implement the SIOCGIFCONF ioctl
*/
@@ -2399,6 +2442,7 @@ linux_ioctl_socket(struct thread *td, struct linux_ioctl_args *args)
case LINUX_SIOCADDMULTI:
case LINUX_SIOCATMARK:
case LINUX_SIOCDELMULTI:
+ case LINUX_SIOCGIFNAME:
case LINUX_SIOCGIFCONF:
case LINUX_SIOCGPGRP:
case LINUX_SIOCSPGRP:
@@ -2484,6 +2528,10 @@ linux_ioctl_socket(struct thread *td, struct linux_ioctl_args *args)
/* LINUX_SIOCGSTAMP */
+ case LINUX_SIOCGIFNAME:
+ error = linux_ioctl_ifname(td, (struct l_ifreq *)args->arg);
+ break;
+
case LINUX_SIOCGIFCONF:
error = linux_ifconf(td, (struct ifconf *)args->arg);
break;
diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h
index 630e5fb..dc0b946 100644
--- a/sys/compat/linux/linux_ioctl.h
+++ b/sys/compat/linux/linux_ioctl.h
@@ -226,6 +226,7 @@
#define LINUX_SIOCGPGRP 0x8904
#define LINUX_SIOCATMARK 0x8905
#define LINUX_SIOCGSTAMP 0x8906
+#define LINUX_SIOCGIFNAME 0x8910
#define LINUX_SIOCGIFCONF 0x8912
#define LINUX_SIOCGIFFLAGS 0x8913
#define LINUX_SIOCGIFADDR 0x8915
OpenPOWER on IntegriCloud