From be3f52f304767a719d4b0dc07c81a1aaea8432b0 Mon Sep 17 00:00:00 2001
From: Simon Deziel <simon.deziel@gmail.com>
Date: Fri, 11 May 2012 12:00:24 -0400
Subject: [PATCH] Force tap's MAC prefix to "fe"

Setting a high prefix discourages the bridge from adopting the tap's
MAC. Xen is not affected by this since the MAC is forced to
"fe:ff:ff:ff:ff:ff".

This addresses issue #217.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 tools/kvm-ifup.in | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/kvm-ifup.in b/tools/kvm-ifup.in
index 2e8e0c23c..a5e8c1b85 100644
--- a/tools/kvm-ifup.in
+++ b/tools/kvm-ifup.in
@@ -33,14 +33,20 @@ if [ -x "@SYSCONFDIR@/ganeti/kvm-vif-bridge" ]; then
 	exec @SYSCONFDIR@/ganeti/kvm-vif-bridge
 fi
 
-ip link set $INTERFACE up
-
 if [ "$MODE" = "bridged" ]; then
+	# Fix the autogenerated MAC to have the first octet set to "fe"
+	# to discourage the bridge from using the TAP dev's MAC
+	FIXED_MAC=$(ip link show $INTERFACE | awk '{if ($1 == "link/ether") printf("fe%s",substr($2,3,15))}')
+	ip link set $INTERFACE address $FIXED_MAC
+
+	ip link set $INTERFACE up
 	ip link set $INTERFACE mtu $(</sys/class/net/${BRIDGE}/mtu)
 
 	# Connect the interface to the bridge
 	brctl addif $BRIDGE $INTERFACE
 else
+	ip link set $INTERFACE up
+
 	if [ -z "$IP" ]; then
 		echo "Routed NIC but no IP address specified"
 		exit 1
-- 
GitLab