Merge pull request #1231 from weaveworks/issues/1229-explicitly-set-docker-bridge-mac
Enforce docker bridge address assignment type on launch Fixes #1229.
This commit is contained in:
commit
ba0ffd225e
1 file changed
+17
@@ -93,6 +93,22 @@ check_docker_version() {
|
|||||||
fi
|
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() {
|
is_cidr() {
|
||||||
echo "$1" | grep -E "^$CIDR_REGEXP$" >/dev/null
|
echo "$1" | grep -E "^$CIDR_REGEXP$" >/dev/null
|
||||||
}
|
}
|
||||||
@@ -976,6 +992,7 @@ case "$COMMAND" in
|
|||||||
;;
|
;;
|
||||||
launch)
|
launch)
|
||||||
check_not_running $CONTAINER_NAME $BASE_IMAGE
|
check_not_running $CONTAINER_NAME $BASE_IMAGE
|
||||||
|
enforce_docker_bridge_addr_assign_type
|
||||||
create_bridge
|
create_bridge
|
||||||
# We set the router name to the bridge mac since that is
|
# We set the router name to the bridge mac since that is
|
||||||
# stable across re-creations of the containers.
|
# stable across re-creations of the containers.
|
||||||
|
|||||||
Reference in new issue
Block a user