Author: avatar
Date: Sun Apr  9 15:27:04 2017
New Revision: 316658
URL: https://svnweb.freebsd.org/changeset/base/316658

Log:
  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
  MFC after:    1 month

Modified:
  head/sys/compat/linux/linux_ioctl.c
  head/sys/compat/linux/linux_ioctl.h

Modified: head/sys/compat/linux/linux_ioctl.c
==============================================================================
--- head/sys/compat/linux/linux_ioctl.c Sun Apr  9 15:17:55 2017        
(r316657)
+++ head/sys/compat/linux/linux_ioctl.c Sun Apr  9 15:27:04 2017        
(r316658)
@@ -2167,6 +2167,49 @@ ifname_linux_to_bsd(struct thread *td, c
 }
 
 /*
+ * 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
  */
 
@@ -2393,6 +2436,7 @@ linux_ioctl_socket(struct thread *td, st
        case LINUX_SIOCADDMULTI:
        case LINUX_SIOCATMARK:
        case LINUX_SIOCDELMULTI:
+       case LINUX_SIOCGIFNAME:
        case LINUX_SIOCGIFCONF:
        case LINUX_SIOCGPGRP:
        case LINUX_SIOCSPGRP:
@@ -2478,6 +2522,10 @@ linux_ioctl_socket(struct thread *td, st
 
        /* 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;

Modified: head/sys/compat/linux/linux_ioctl.h
==============================================================================
--- head/sys/compat/linux/linux_ioctl.h Sun Apr  9 15:17:55 2017        
(r316657)
+++ head/sys/compat/linux/linux_ioctl.h Sun Apr  9 15:27:04 2017        
(r316658)
@@ -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
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to