NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/39424: SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32



>Number:         39424
>Category:       kern
>Synopsis:       SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat 
>netbsd32
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 28 12:25:00 +0000 2008
>Originator:     Nicolas Joly
>Release:        NetBSD 4.99.72
>Organization:
Biological Software and Databanks.
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 4.99.72 NetBSD 4.99.72 (LANFEUST) #13: 
Thu Aug 28 14:05:46 CEST 2008 
njoly%lanfeust.sis.pasteur.fr@localhost:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST
 amd64
Architecture: x86_64
Machine: amd64
>Description:
I discovered that SIOCGIFFLAGS ioctl(2) from NetBSD 4.0, does not work on
-current under compat netbsd32., using the following testcase :

njoly@lanfeust [netbsd/ioctl]> cat siocgifflags.c

#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%x\n", ifr.ifr_name, (ifr.ifr_flags & 0xffff));

  res = close(fd);
  if (res == -1)
    err(1, "close failed");

  return 0; }

When compiled on a 4.0 machine, it fails to give a correct value.

njoly@lanfeust [netbsd/ioctl]> file siocgifflags 
siocgifflags: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for 
NetBSD 4.0, dynamically linked (uses shared libs), not stripped
njoly@lanfeust [netbsd/ioctl]> ./siocgifflags 
lo0: 0xdb54
njoly@lanfeust [netbsd/ioctl]> ifconfig lo0 | grep flags
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33648

In the mean time, a -current binary works ...

njoly@lanfeust [~]> file siocgifflags 
siocgifflags: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for 
NetBSD 4.99.64, dynamically linked (uses shared libs), not stripped
njoly@lanfeust [~]> ./siocgifflags 
lo0: 0x8049
njoly@lanfeust [~]> ifconfig lo0 | grep flags
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33648

>How-To-Repeat:
Run the provided testcase, compiled on a 4.0 machine, under compat netbsd32.
>Fix:
n/a



Home | Main Index | Thread Index | Old Index