Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
qemu-bridge-helper: force usage of a very high MAC address for the br…
Browse files Browse the repository at this point in the history
…idge

Linux uses the lowest enslaved MAC address as the MAC address of
the bridge.  Set MAC address to a high value so that it does not
affect the MAC address of the bridge.

Changing the MAC address of the bridge could cause a few seconds
of network downtime.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1363971468-21154-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
bonzini authored and Anthony Liguori committed Mar 28, 2013
1 parent 2900af5 commit 226ecab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions qemu-bridge-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,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);
Expand Down

0 comments on commit 226ecab

Please sign in to comment.