On Sat, 2008-06-14 at 19:20 +1000, Rusty Russell wrote:
> On Friday 13 June 2008 23:05:00 Mark McLoughlin wrote:
> > Allow assigning a MAC address to the network interface with
> > e.g.
> >
> >   --tunnet=bridge:eth0:00:FF:95:6B:DA:3D
> >
> > or:
> >
> >   --tunnet=192.168.121.1:00:FF:95:6B:DA:3D
> >
> > which is pretty unintelligable, but ...
> 
> Agreed... ugly but clear.
> 
> Not sure about tossing around the ifr just to hold the interface name
> across configure_device and get_mac though.  If we put it in a nice var,
> we can have a cleaner interface and a better verbose() message.
> 
> Oh, and I'm trying to hang with the cool kids and use bool :)

Yep, all looks better. Works fine too.

> +static int get_tun_device(char tapif[IFNAMSIZ])
> +{
> +     struct ifreq ifr;
> +     int netfd;
> +
> +     /* Start with this zeroed.  Messy but sure. */
> +     memset(&ifr, 0, sizeof(ifr));
> +
> +     /* We open the /dev/net/tun device and tell it we want a tap device.  A
> +      * tap device is like a tun device, only somehow different.  To tell
> +      * the truth, I completely blundered my way through this code, but it
> +      * works now! */
> +     netfd = open_or_die("/dev/net/tun", O_RDWR);
> +     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
> +     strcpy(ifr.ifr_name, "tap%d");

You can drop this line with no effect, btw - tun/tap defaults to "tap%d"
for IFF_TAP

> +     if (ioctl(netfd, TUNSETIFF, &ifr) != 0)
> +             err(1, "configuring /dev/net/tun");

...

> -static void setup_tun_net(const char *arg)
> +static void setup_tun_net(char *arg)

Bah ... and the hoops I jumped through to avoid that ... :-)

Cheers,
Mark.

_______________________________________________
Lguest mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/lguest

Reply via email to