mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
Set MAC address on TUN device for Xenner compatability
This commit is contained in:
parent
46b427a310
commit
9699e372c2
@ -1,3 +1,8 @@
|
||||
Wed Feb 27 20:21:35 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/bridge.c, src/bridge.h, src/qemu_conf.c: Set mac address
|
||||
on TUN device to work with Xenner
|
||||
|
||||
Wed Feb 27 20:12:35 CET 2008 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Make qemud/'s rpcgen rules work.
|
||||
|
14
src/bridge.c
14
src/bridge.c
@ -42,6 +42,7 @@
|
||||
#include <linux/sockios.h> /* SIOCBRADDBR etc. */
|
||||
#include <linux/if_bridge.h> /* SYSFS_BRIDGE_ATTR */
|
||||
#include <linux/if_tun.h> /* IFF_TUN, IFF_NO_PI */
|
||||
#include <net/if_arp.h> /* ARPHRD_ETHER */
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -312,6 +313,7 @@ brDeleteInterface(brControl *ctl ATTRIBUTE_UNUSED,
|
||||
int
|
||||
brAddTap(brControl *ctl,
|
||||
const char *bridge,
|
||||
unsigned char *macaddr,
|
||||
char *ifname,
|
||||
int maxlen,
|
||||
int *tapfd)
|
||||
@ -355,6 +357,18 @@ brAddTap(brControl *ctl,
|
||||
}
|
||||
|
||||
if (ioctl(fd, TUNSETIFF, &try) == 0) {
|
||||
struct ifreq addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
memcpy(addr.ifr_hwaddr.sa_data, macaddr, 6);
|
||||
addr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
|
||||
|
||||
/* Device actually starts in 'UP' state, but it
|
||||
* needs to be down to set the MAC addr
|
||||
*/
|
||||
if ((errno = brSetInterfaceUp(ctl, try.ifr_name, 0)))
|
||||
goto error;
|
||||
if (ioctl(fd, SIOCSIFHWADDR, &addr) != 0)
|
||||
goto error;
|
||||
if ((errno = brAddInterface(ctl, bridge, try.ifr_name)))
|
||||
goto error;
|
||||
if ((errno = brSetInterfaceUp(ctl, try.ifr_name, 1)))
|
||||
|
@ -62,6 +62,7 @@ int brDeleteInterface (brControl *ctl,
|
||||
|
||||
int brAddTap (brControl *ctl,
|
||||
const char *bridge,
|
||||
unsigned char *mac,
|
||||
char *ifname,
|
||||
int maxlen,
|
||||
int *tapfd);
|
||||
|
@ -1530,6 +1530,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
|
||||
}
|
||||
|
||||
if ((err = brAddTap(driver->brctl, brname,
|
||||
net->mac,
|
||||
ifname, BR_IFNAME_MAXLEN, &tapfd))) {
|
||||
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
"Failed to add tap interface '%s' to bridge '%s' : %s",
|
||||
|
Loading…
Reference in New Issue
Block a user