Re: SIOCGIFNAME +sparc64?

David S. Miller (davem@redhat.com)
Tue, 8 Jun 1999 21:59:20 -0700


Date: Tue, 8 Jun 1999 22:07:34 +0800 (PHT)
From: Gerard Paul Java <gerardj@cebu.mozcom.com>

I tried to do a SIOGIFNAME ioctl() call on a (PF_PACKET, SOCK_RAW)
socket. I need to retrieve the interface name from the interface
index returned in the sll_ifindex field after a recvfrom() on the
socket. On my Intel machine, it works perfectly. On the sparc64,
it fails with an Invalid argument error.

This fixes it, against 2.2.10-pre3 but should apply cleanly to 2.2.9
as well.

--- arch/sparc64/kernel/ioctl32.c.~1~ Wed May 12 12:59:38 1999
+++ arch/sparc64/kernel/ioctl32.c Tue Jun 8 21:57:53 1999
@@ -1,4 +1,4 @@
-/* $Id: ioctl32.c,v 1.62 1999/05/01 09:17:44 davem Exp $
+/* $Id: ioctl32.c,v 1.62.2.1 1999/06/09 04:53:03 davem Exp $
* ioctl32.c: Conversion between 32bit and 64bit native ioctls.
*
* Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
@@ -37,6 +37,7 @@
#include <linux/fb.h>
#include <linux/ext2_fs.h>
#include <linux/videodev.h>
+#include <linux/netdevice.h>

#include <scsi/scsi.h>
/* Ugly hack. */
@@ -417,6 +418,23 @@
__kernel_caddr_t32 ifcbuf;
};

+static int dev_ifname32(unsigned int fd, unsigned long arg)
+{
+ struct device *dev;
+ struct ifreq32 ifr32;
+ int err;
+
+ if (copy_from_user(&ifr32, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
+ return -EFAULT;
+
+ dev = dev_get_by_index(ifr32.ifr_ifindex);
+ if (!dev)
+ return -ENODEV;
+
+ err = copy_to_user((struct ifreq32 *)arg, &ifr32, sizeof(struct ifreq32));
+ return (err ? -EFAULT : 0);
+}
+
static inline int dev_ifconf(unsigned int fd, unsigned long arg)
{
struct ifconf32 ifc32;
@@ -1687,6 +1705,10 @@
goto out;
}
switch (cmd) {
+ case SIOCGIFNAME:
+ error = dev_ifname32(fd, arg);
+ goto out;
+
case SIOCGIFCONF:
error = dev_ifconf(fd, arg);
goto out;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/