Wire up enforce_docker_bridge_addr_assign_type
This commit is contained in:
1 parent
8051f51d46
commit
a8eb7966b6
3 files changed
+9
-27
No files matched your search
@@ -43,3 +43,10 @@ func createBridge(args []string) error {
|
||||
fmt.Println(bridgeType.String())
|
||||
return err
|
||||
}
|
||||
|
||||
func enforceAddrAssign(args []string) error {
|
||||
if len(args) != 1 {
|
||||
cmdUsage("enforce-bridge-addr-assign-type", "<bridge-name>")
|
||||
}
|
||||
return weavenet.EnforceAddrAssignType(args[0])
|
||||
}
|
||||
@@ -19,6 +19,7 @@ func init() {
|
||||
"docker-tls-args": dockerTLSArgs,
|
||||
"create-bridge": createBridge,
|
||||
"detect-bridge-type": detectBridgeType,
|
||||
"enforce-addr-assign": enforceAddrAssign,
|
||||
"create-datapath": createDatapath,
|
||||
"delete-datapath": deleteDatapath,
|
||||
"add-datapath-interface": addDatapathInterface,
|
||||
|
||||
@@ -379,20 +379,6 @@ arp_update() {
|
||||
! command_exists arping || $3 arping -U -q -I $1 -c 1 ${2%/*}
|
||||
}
|
||||
|
||||
# Generate a MAC value from a stdin containing six space separated
|
||||
# 2-digit hexadecimal numbers.
|
||||
mac_from_hex() {
|
||||
# In the first byte of the MAC, the 'multicast' bit should be
|
||||
# clear and 'locally administered' bit should be set. All other
|
||||
# bits should be random.
|
||||
read a b c d e f && printf "%02x:$b:$c:$d:$e:$f" $((0x$a & ~1 | 2))
|
||||
}
|
||||
|
||||
# Generate a random MAC value
|
||||
random_mac() {
|
||||
od -txC -An -N6 /dev/urandom | mac_from_hex
|
||||
}
|
||||
|
||||
######################################################################
|
||||
# weave and docker specific helpers
|
||||
######################################################################
|
||||
@@ -419,19 +405,7 @@ EOF
|
||||
}
|
||||
|
||||
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
|
||||
util_op enforce-addr-assign "$DOCKER_BRIDGE" || true
|
||||
}
|
||||
|
||||
# Detect the current bridge/datapath state. When invoked, the values of
|
||||
|
||||
Reference in new issue
Block a user