tech-net archive

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

Re: tap interface address

On Mon, Aug 11, 2008 at 02:23:50PM +0100, Iain Hibbert wrote:
> Hi,
> Am trying to open a tap(4) device and get the interface address, but
> SIOCGIFADDR does not work (though it seems that it should, looking at the
> if_tap.c code and ether_ioctl()) No error is produced but nothing is

I... doubt that.  tap_dev_ioctl() returns ENOTTY (as it should).  I'll
try though, there might be a bug.

> and I worked out how to change the physical address using SIOCSIFPHYADDR

That won't work either if you do it on the fd returned by /dev/tap.

> but I wanted to see what the address actually was as reported by ifconfig
> (I got lost in the twisty passages there, not sure how it gets it)
> the tap(4) manpage mentions a sysctl node but that seems overcomplicated

The sysctl is for human, or static boot configuration, because ifconfig
doesn't (didn't?  I can't remember the status of that) support changing
the Ethernet address of an interface.

Iain, the way one is supposed to manipulate an interface is through a
socket.  So you have to open a socket first (AF_INET is fine to do the
SIOCSIFPHYADDR call, and you can use it later to set an ipv4 address on
the interface and so on), and then do the ioctl calls on it.

I don't think I should blindly let ioctls go to tap_ioctl from the
character device, but I guess I could at least allow my kludgy
SIOCSIFPHYADDR.  Though usually if you're playing with a tap interface
you'll need a socket at some point.

Quentin Garnier - -
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

Attachment: pgpKzZ6623_9W.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index