From f58f85930383c4543396fbdb4c422d26f5284fda Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 21 Jan 2014 15:58:45 -0500 Subject: [PATCH] Only configure DHCP for real interfaces Updates the generate-interfaces-file.sh script in the dhcp-all-interfaces element so that we only add interfaces that have real MAC addresses. The generate-interfaces-file.sh script is run early enough in the boot process (before OVS is initialized) that this isn't usually a problem unless you execute it manually by hand after booting. Then you'll end up with network/DHCP configs for all of your OVS bridges, etc. This patch avoids configuring all of the virtual interfaces which have generated MAC addresses. Change-Id: I7a705084aa5b11305ac0ec5ca37fd2e87a2ae8b7 Closes-bug: 1239479 --- elements/dhcp-all-interfaces/README.md | 4 ++-- .../install.d/generate-interfaces-file.sh | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/elements/dhcp-all-interfaces/README.md b/elements/dhcp-all-interfaces/README.md index efc5b4c09..6857f942a 100644 --- a/elements/dhcp-all-interfaces/README.md +++ b/elements/dhcp-all-interfaces/README.md @@ -3,8 +3,8 @@ Autodetect network interfaces during boot and configure them for DHCP The rationale for this is that we are likely to require multiple network interfaces for use cases such as baremetal and there is no way to know ahead of time which one is which, so we will simply run a -DHCP client on all interfaces (except lo) that are visible on the first -boot. +DHCP client on all interfaces with real MAC addresses (except lo) that +are visible on the first boot. The script /usr/local/sbin/generate-interfaces-file.sh will be called early in each boot and will scan available network interfaces and diff --git a/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh b/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh index aac871820..6177b9115 100755 --- a/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh +++ b/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh @@ -51,10 +51,14 @@ function disable_interface() { } for interface in $(ls /sys/class/net | grep -v ^lo$) ; do + MAC_ADDR_TYPE="$(cat /sys/class/net/${interface}/addr_assign_type)" + echo -n "Inspecting interface: $interface..." if ifquery $interface >/dev/null 2>&1 ; then echo "Has config, skipping." - else + elif [ "$MAC_ADDR_TYPE" != "0" ]; then + echo "Device has generated MAC, skipping." + else ip link set dev $interface up >/dev/null 2>&1 HAS_LINK="$(get_if_link $interface)"