From 201c9e85277dd6083d0cbc6e1318622583c2a082 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 7 Feb 2014 13:44:00 -0500 Subject: [PATCH] Add Fedora DHCP interfaces via udev rules Updates the dhcp-all-interfaces element so that we add new DHCP interfaces using a udev rule instead of a systemd service. The previous approach (using the systemd service) was proving to be problematic when used with the new Fedora constistent network naming convention rules (em1, em2, etc.). We aren't using these device names as a default yet... but we will need to soon and when we do udev rules seem to be the best way to avoid racy behaviour when calling dhcp-all-interfaces.sh from the systemd service. Change-Id: I87e0aed1f34718e896bd414388886a1f1073b0c0 --- .../install.d/50-dhcp-all-interfaces | 3 +-- .../install.d/dhcp-all-interfaces.service | 14 -------------- elements/dhcp-all-interfaces/install.d/udev.rules | 1 + 3 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.service create mode 100644 elements/dhcp-all-interfaces/install.d/udev.rules diff --git a/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces b/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces index eaa51c71..06098735 100755 --- a/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces +++ b/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces @@ -9,6 +9,5 @@ DIB_INIT_SYSTEM=$(dib-init-system) if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.conf /etc/init/dhcp-all-interfaces.conf elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then - install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.service /usr/lib/systemd/system/dhcp-all-interfaces.service - systemctl enable dhcp-all-interfaces.service + install -D -g root -o root -m 0644 ${SCRIPTDIR}/udev.rules /etc/udev/rules.d/99-dhcp-all-interfaces.rules fi diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.service b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.service deleted file mode 100644 index e19c9240..00000000 --- a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=DHCP All Interfaces Service -Wants=local-fs.target systemd-udev-settle.service -After=local-fs.target systemd-udev-settle.service -Before=network.service - -[Service] -Type=oneshot -ExecStart=/usr/local/sbin/dhcp-all-interfaces.sh -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -Alias=dhcp-all-interfaces.service diff --git a/elements/dhcp-all-interfaces/install.d/udev.rules b/elements/dhcp-all-interfaces/install.d/udev.rules new file mode 100644 index 00000000..88ce3e13 --- /dev/null +++ b/elements/dhcp-all-interfaces/install.d/udev.rules @@ -0,0 +1 @@ +SUBSYSTEM=="net", ACTION=="add", RUN+="/usr/local/sbin/dhcp-all-interfaces.sh $name", RUN+="/sbin/ifup $name"