}
if (virNetDevTapCreateInBridgePort(network->def->bridge,
&macTapIfName, network->def->mac,
- 0, false, NULL, NULL) < 0) {
+ false, 0, false, NULL, NULL) < 0) {
VIR_FREE(macTapIfName);
goto err0;
}
int tapfd = -1;
int vnet_hdr = 0;
bool template_ifname = false;
- unsigned char tapmac[VIR_MAC_BUFLEN];
int actualType = virDomainNetGetActualType(net);
if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
net->model && STREQ(net->model, "virtio"))
vnet_hdr = 1;
- memcpy(tapmac, net->mac, VIR_MAC_BUFLEN);
- tapmac[0] = 0xFE; /* Discourage bridge from using TAP dev MAC */
- err = virNetDevTapCreateInBridgePort(brname, &net->ifname, tapmac,
+ err = virNetDevTapCreateInBridgePort(brname, &net->ifname, net->mac, true,
vnet_hdr, true, &tapfd,
virDomainNetGetActualVirtPortProfile(net));
virDomainAuditNetDevice(def, net, "/dev/net/tun", tapfd >= 0);
const char *bridge)
{
bool template_ifname = false;
- unsigned char tapmac[VIR_MAC_BUFLEN];
if (!net->ifname ||
STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
template_ifname = true;
}
- memcpy(tapmac, net->mac, VIR_MAC_BUFLEN);
- tapmac[0] = 0xFE; /* Discourage bridge from using TAP dev MAC */
- if (virNetDevTapCreateInBridgePort(bridge, &net->ifname, tapmac,
+ if (virNetDevTapCreateInBridgePort(bridge, &net->ifname, net->mac, true,
0, true, NULL,
virDomainNetGetActualVirtPortProfile(net)) < 0) {
if (template_ifname)
#include <config.h>
+#include "virmacaddr.h"
#include "virnetdevtap.h"
#include "virnetdev.h"
#include "virnetdevbridge.h"
* @brname: the bridge name
* @ifname: the interface name (or name template)
* @macaddr: desired MAC address (VIR_MAC_BUFLEN long)
+ * @discourage: whether bridge should be discouraged from using macaddr
* @vnet_hdr: whether to try enabling IFF_VNET_HDR
* @tapfd: file descriptor return value for the new tap device
* @virtPortProfile: bridge/port specific configuration
int virNetDevTapCreateInBridgePort(const char *brname,
char **ifname,
const unsigned char *macaddr,
+ bool discourage,
int vnet_hdr,
bool up,
int *tapfd,
virNetDevVPortProfilePtr virtPortProfile)
{
+ unsigned char tapmac[VIR_MAC_BUFLEN];
+
if (virNetDevTapCreate(ifname, vnet_hdr, tapfd) < 0)
return -1;
* seeing the kernel allocate random MAC for the TAP
* device before we set our static MAC.
*/
- if (virNetDevSetMAC(*ifname, macaddr) < 0)
+ memcpy(tapmac, macaddr, VIR_MAC_BUFLEN);
+ if (discourage)
+ tapmac[0] = 0xFE; /* Discourage bridge from using TAP dev MAC */
+
+ if (virNetDevSetMAC(*ifname, tapmac) < 0)
goto error;
/* We need to set the interface MTU before adding it
int virNetDevTapCreateInBridgePort(const char *brname,
char **ifname,
const unsigned char *macaddr,
+ bool discourage,
int vnet_hdr,
bool up,
int *tapfd,