From a14d4d9f8e8166b5fe4c7696bd1705cf555ccfd8 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 28 Jul 2015 17:18:58 +0100 Subject: [PATCH] Enforce docker bridge address assignment type on launch --- weave | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/weave b/weave index 37ee8210..80b49b70 100755 --- a/weave +++ b/weave @@ -93,6 +93,22 @@ check_docker_version() { fi } +enforce_docker_bridge_addr_assign_type() { + if ! ADDR_ASSIGN_TYPE=$(cat /sys/class/net/$DOCKER_BRIDGE/addr_assign_type 2>/dev/null) ; then + echo "Could not determine address assignment type of $DOCKER_BRIDGE" >&2 + return + fi + # From include/uapi/linux/netdevice.h + # #define NET_ADDR_PERM 0 /* address is permanent (default) */ + # #define NET_ADDR_RANDOM 1 /* address is generated randomly */ + # #define NET_ADDR_STOLEN 2 /* address is stolen from other device */ + # #define NET_ADDR_SET 3 /* address is set using dev_set_mac_address() */ + if [ $ADDR_ASSIGN_TYPE != 3 ] ; then + echo "Setting $DOCKER_BRIDGE MAC (mitigate https://github.com/docker/docker/issues/14908)" >&2 + ip link set dev $DOCKER_BRIDGE address $(random_mac) || true + fi +} + is_cidr() { echo "$1" | grep -E "^$CIDR_REGEXP$" >/dev/null } @@ -976,6 +992,7 @@ case "$COMMAND" in ;; launch) check_not_running $CONTAINER_NAME $BASE_IMAGE + enforce_docker_bridge_addr_assign_type create_bridge # We set the router name to the bridge mac since that is # stable across re-creations of the containers.