On Sat, Dec 05, 2009 at 10:22:23PM +0000, Christos Zoulas wrote: > In article <5470.1260044119%splode.eterna.com.au@localhost>, > matthew green <mrg%eterna.com.au@localhost> wrote: > > > > On Dec 5, 8:41am, mrg%eterna.com.au@localhost (matthew green) wrote: > > -- Subject: re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work > > unde > > > > | > > | my guess is that this commit is the problem: > > | > > | > > http://mail-index.netbsd.org/source-changes/2007/05/29/msg186117.html > > | > > | it changed the size of struct ifreq, pushing the ifru_flags flags > > further > > | into memory by sizeof(struct sockaddr_storage). > > | > > | christos? the comment says it should be backwrds compatible. > > > > Yes, the code is supposed to be backwards compatible by checking the > >type/size > > of the ioctl and emulating it. > > > >i don't see any references to "oifreq" in sys/compat/netbsd32. > > > >can you have a look at this please? > > Sure, can njoly provide an example binary for me to test? Here it is. Attached sample code and corresponding NetBSD/i386 4.0.1 binary which exhibit the problem on a -current amd64 machine. njoly@nicodeme [netbsd/ioctls]> ifconfig lo0 | grep flags lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33648 njoly@nicodeme [netbsd/ioctls]> file siocgifflags siocgifflags: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 4.0, not stripped njoly@nicodeme [netbsd/ioctls]> ./siocgifflags lo0 0x52c4 njoly@nicodeme [netbsd/ioctls]> file siocgifflags siocgifflags: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 5.99.22, not stripped njoly@nicodeme [netbsd/ioctls]> ./siocgifflags lo0 0x8049 Thanks for looking into it. -- Nicolas Joly Biological Software and Databanks. Institut Pasteur, Paris.
#include <arpa/inet.h> #include <net/if.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/types.h> #include <err.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { int res, fd; struct ifreq ifr; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd == -1) err(1, "socket failed"); sprintf(ifr.ifr_name, "lo0"); res = ioctl(fd, SIOCGIFFLAGS, &ifr); if (res == -1) err(1, "ioctl failed"); printf("%s 0x%hx\n", ifr.ifr_name, ifr.ifr_flags); res = close(fd); if (res == -1) err(1, "close failed"); return 0; }
Attachment:
siocgifflags
Description: Binary data