Nmap Development mailing list archives

Re: Nmap 5.10BETA1: Failed to determine the MAC address of bge0!: Invalid argument (22)


From: David Fifield <david () bamsoftware com>
Date: Fri, 26 Feb 2010 11:53:12 -0700

On Fri, Dec 04, 2009 at 03:08:58PM +0600, Yevgeniy Litvinenko wrote:
I've built nmap on OpenSolaris x86 build 127.

When I try to run nmap as root I get an error:
# nmap 10.1.1.1                                             

Starting Nmap 5.10BETA1 ( http://nmap.org ) at 2009-12-04 14:43 ALMT
Failed to determine the MAC address of bge0!: Invalid argument (22)


When I run nmap without root privileges it works:
$ nmap -PN -p1-100 -sV --version-all 10.1.1.1                                                       

Starting Nmap 5.10BETA1 ( http://nmap.org ) at 2009-12-04 14:44 ALMT
Nmap scan report for 10.1.1.1
Host is up (0.50s latency).
Not shown: 97 closed ports
PORT   STATE    SERVICE    VERSION
22/tcp open     ssh        OpenSSH 4.0 (protocol 2.0)
25/tcp filtered smtp
42/tcp filtered nameserver

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.13 seconds


truss utility gives:


11146:   1.6062 so_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP, 0x00000000, SOV_XPG4_2) = 4
11146:   1.6063 ioctl(4, SIOCGIFCONF, 0x08043358)               = 0
11146:   1.6063 ioctl(4, SIOCGIFNETMASK, 0x08043308)            = 0
11146:   1.6064 ioctl(4, SIOCGIFFLAGS, 0x08043308)              = 0
11146:   1.6064 ioctl(4, SIOCGIFNETMASK, 0x08043308)            = 0
11146:   1.6064 ioctl(4, SIOCGIFFLAGS, 0x08043308)              = 0
11146:   1.6065 ioctl(4, _IOWRN('i', 185, 4), 0x08043308)       Err#22 EINVAL
11146:   1.6065 fstat64(2, 0x08042300)                          = 0
Failed to determine the MAC address of 11146:    1.6065 write(2, " F a i l e d   t o   d e".., 39)      = 39
bge011146:       1.6066 write(2, " b g e 0", 4)                         = 4
!11146:  1.6066 write(2, " !", 1)                               = 1
: 11146:         1.6067 write(2, " :  ", 2)                             = 2
Invalid argument11146:   1.6067 write(2, " I n v a l i d   a r g u".., 16)      = 16
 (2211146:       1.6067 write(2, "   ( 2 2", 4)                         = 4
)
11146:   1.6068 write(2, " )\n", 2)                             = 2
11146:   1.6194 _exit(1)

***********************************************************
excerp from tcpip.cc
...
#ifdef SIOCGIFHWADDR
      memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin)));
      rc = ioctl(sd, SIOCGIFHWADDR, &tmpifr);
      if (rc < 0 && errno != EADDRNOTAVAIL)
        pfatal("Failed to determine the MAC address of %s!", tmpifr.ifr_name);
      else if (rc >= 0)
        memcpy(devs[count].mac, &tmpifr.ifr_addr.sa_data, 6);
#else
....

In the file /usr/include/sys/sockio.h:
...
#define SIOCGIFHWADDR _IOWR('i', 185, int) /* PF_PACKET */
...

In the file /usr/include/sys/ioccom.h

#ifdef  __cplusplus
extern "C" {
#endif
...
#define _IOWRN(x, y, t)                                                 \
            ((int)((uint32_t)(IOC_INOUT|(((t)&IOCPARM_MASK)<<16)| \
            (x<<8)|y)))

#ifdef  __cplusplus
}
#endif
...

I've found a report

http://bugs.winehq.org/show_bug.cgi?id=20714
http://arc.opensolaris.org/caselog/PSARC/2009/232/pfp-psarc.txt

that says though SIOCGIFHWADDR is defined, it doesn't work in the way we
use it. Try doing these two things separately and see if they work:

1) Change AF_INET to PF_PACKET here in getinterfaces_siocgifconf:
  /* Dummy socket for ioctl */
  sd = socket(AF_INET, SOCK_DGRAM, 0);
2) Get rid of the SIOCGIFHWADDR code and use the "Let's just let libdnet
handle it ..." block.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: