-#!/bin/sh
+#!/bin/bash
#
-# Copyright (C) 2011 Google Inc.
+# Copyright (C) 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
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