X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qemu-bridge-helper.c;h=5396fbfbb6ca5d4415bd3165dc68bb4f5004a7a0;hb=a5f7b1a63ced35cc18fe8fa9e1679219fad9abde;hp=287bfd5e38c11f6ccef868efd71b7d0c64ecc220;hpb=27dd7730582be85c7d4f680f5f71146629809c86;p=mirror_qemu.git diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index 287bfd5e38..5396fbfbb6 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -13,19 +13,9 @@ * */ -#include "config-host.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include "qemu/osdep.h" + + #include #include #include @@ -229,7 +219,7 @@ int main(int argc, char **argv) unsigned long ifargs[4]; #endif int ifindex; - int fd, ctlfd, unixfd = -1; + int fd = -1, ctlfd = -1, unixfd = -1; int use_vnet = 0; int mtu; const char *bridge = NULL; @@ -367,6 +357,24 @@ int main(int argc, char **argv) goto cleanup; } + /* Linux uses the lowest enslaved MAC address as the MAC address of + * the bridge. Set MAC address to a high value so that it doesn't + * affect the MAC address of the bridge. + */ + if (ioctl(ctlfd, SIOCGIFHWADDR, &ifr) < 0) { + fprintf(stderr, "failed to get MAC address of device `%s': %s\n", + iface, strerror(errno)); + ret = EXIT_FAILURE; + goto cleanup; + } + ifr.ifr_hwaddr.sa_data[0] = 0xFE; + if (ioctl(ctlfd, SIOCSIFHWADDR, &ifr) < 0) { + fprintf(stderr, "failed to set MAC address of device `%s': %s\n", + iface, strerror(errno)); + ret = EXIT_FAILURE; + goto cleanup; + } + /* add the interface to the bridge */ prep_ifreq(&ifr, bridge); ifindex = if_nametoindex(iface); @@ -418,7 +426,12 @@ int main(int argc, char **argv) /* profit! */ cleanup: - + if (fd >= 0) { + close(fd); + } + if (ctlfd >= 0) { + close(ctlfd); + } while ((acl_rule = QSIMPLEQ_FIRST(&acl_list)) != NULL) { QSIMPLEQ_REMOVE_HEAD(&acl_list, entry); g_free(acl_rule);