From a6f45302c1a0cffe875235bc36d97115d2d66f476b567b90d6615568f51033da Mon Sep 17 00:00:00 2001 From: OBS User autobuild Date: Thu, 13 Aug 2009 16:04:28 +0000 Subject: [PATCH] Accepting request 17525 from network Copy from network/dhcp based on submit request 17525 from user mtomaschewski OBS-URL: https://build.opensuse.org/request/show/17525 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/dhcp?expand=0&rev=25 --- dhcp.changes | 7 +++ dhcp.spec | 11 +++- if-up.d.dhcpd-restart-hook | 113 +++++++++++++++++++++++++++++++++++++ sysconfig.dhcpd | 22 ++++++++ 4 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 if-up.d.dhcpd-restart-hook diff --git a/dhcp.changes b/dhcp.changes index 6aa2453..6486bc0 100644 --- a/dhcp.changes +++ b/dhcp.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Aug 12 10:38:26 CEST 2009 - mt@suse.de + +- Added dhcpd-restart-hook if-up.d script that restarts dhcp server + while network restart when a virtual interfaces as bridge, bond + or vlan goes up again (bnc#517810). + ------------------------------------------------------------------- Wed Jul 29 14:05:41 CEST 2009 - mt@suse.de diff --git a/dhcp.spec b/dhcp.spec index b405f76..f3dcf9c 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -31,7 +31,7 @@ License: BSD 3-clause (or similar) Group: Productivity/Networking/Boot/Servers AutoReqProv: on Version: 3.1.2p1 -Release: 1 +Release: 2 Summary: Common Files Used by ISC DHCP Software Url: http://www.isc.org/isc/dhcp.html Source0: http://ftp.isc.org/isc/dhcp/dhcp-%{version}.tar.gz @@ -56,6 +56,7 @@ Source40: http://www3.baylor.edu/~Jeff_Wilson/GiveAway/leases.awk Source41: http://www.suse.de/~poeml/dnscompr.py Source42: dhcpd.xml Source43: SuSEfirewall2.dhcp-server +Source44: if-up.d.dhcpd-restart-hook Patch0: dhcp-3.1.1-paths.dif ## chroot patch by Ari Edelkind (see readme) ## and patch supplied by @@ -305,6 +306,12 @@ find $RPM_BUILD_ROOT/%{_mandir} -type f | xargs chmod 644 install -m 644 $RPM_SOURCE_DIR/dhcpd.xml $RPM_BUILD_ROOT/%{omc_svcdir}/ install -m 644 $RPM_SOURCE_DIR/SuSEfirewall2.dhcp-server \ $RPM_BUILD_ROOT/%{susefw2dir}/dhcp-server +install -m 755 -d $RPM_BUILD_ROOT/etc/sysconfig/network/if-up.d +install -m 755 -d $RPM_BUILD_ROOT/etc/sysconfig/network/scripts +install -m 755 $RPM_SOURCE_DIR/if-up.d.dhcpd-restart-hook \ + $RPM_BUILD_ROOT/etc/sysconfig/network/scripts/dhcpd-restart-hook +ln -sf ../scripts/dhcpd-restart-hook \ + $RPM_BUILD_ROOT/etc/sysconfig/network/if-up.d/60-dhcpd-restart-hook %pre # In the past, the name of the source package was "dhcp" but the subpackage @@ -447,6 +454,8 @@ if ! test -f /.buildenv; then rm -rf $RPM_BUILD_ROOT; fi /var/adm/fillup-templates/sysconfig.syslog-dhcpd %dir /var/lib/dhcp/%_lib %{omc_svcdir}/dhcpd.xml +/etc/sysconfig/network/scripts/dhcpd-restart-hook +/etc/sysconfig/network/if-up.d/60-dhcpd-restart-hook %files client %defattr(-,root,root) diff --git a/if-up.d.dhcpd-restart-hook b/if-up.d.dhcpd-restart-hook new file mode 100644 index 0000000..807f222 --- /dev/null +++ b/if-up.d.dhcpd-restart-hook @@ -0,0 +1,113 @@ +#! /bin/bash +# +# dhcpd-restart-hook - script to restart dhcpd on virtual interfaces +# +# Copyright (C) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# Author(s): Marius Tomaschewski , 2009 +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Please send feedback via http://www.suse.de/feedback +# + +set -e + +unset ${!LC_*} LANUGUAGE +export LANG=POSIX +export PATH=/sbin:/usr/sbin:/usr/bin:/bin + +SCRIPTNAME=${0##*/} + +usage () { + echo "usage: $SCRIPTNAME [] [-o ]" + echo "" + echo "Any options are ignored" + exit $R_USAGE +} + +R_INTERNAL=1 # internal error, e.g. no config or missing scripts +cd /etc/sysconfig/network || exit $R_INTERNAL + +case $1 in ""|-h|*help*) usage ;; esac +INTERFACE="$1" +if test "x$2" != x -a "x$2" != "x-o" ; then + CONFIG=$INTERFACE + INTERFACE="$2" +else + CONFIG=$INTERFACE +fi + + +. /etc/sysconfig/network/config +. /etc/sysconfig/network/scripts/functions + +. /etc/sysconfig/dhcpd 2>/dev/null +. /etc/sysconfig/network/ifcfg-"$CONFIG" 2>/dev/null || true + +: ${DHCPD_IFUP_RESTART:=auto} + +iface_needs_restart() +{ + test -d /sys/class/net/$1/bridge -o \ + -d /sys/class/net/$1/bonding -o \ + -d /proc/net/vlan/$1 +} + +case "$0" in +*if-up.d*) + # + # don't do anything if we are disabled either + # in the /etc/sysconfig/dhcpd or per interface + # in the /etc/sysconfig/network/ifcfg-"$CONFIG" + # + test "$DHCPD_IFUP_RESTART" = no && exit 0 + + # don't restart for loopback interface + case $INTERFACE in (lo) exit 0 ;; esac + + restart_needed=$DHCPD_IFUP_RESTART + if test -n "$DHCPD_INTERFACE" \ + -a "$restart_needed" != yes ; + then + for I in $DHCPD_INTERFACE ; do + test -n "$I" || continue + + # don't restart when _one_ involved + # interface is not available/up yet + is_iface_up $I || exit 0 + + # check if this interface is involved + if test "$I" = "$INTERFACE" ; then + + # check if a restart is needed + if iface_needs_restart $I ; then + restart_needed=yes + fi + fi + done + fi + + if test "$restart_needed" = yes ; then + /etc/init.d/dhcpd try-restart + fi +;; +*if-down.d*) + # don't do anything +;; +*) + echo "$SCRIPTNAME: don't know what to do" >&2 +;; +esac + diff --git a/sysconfig.dhcpd b/sysconfig.dhcpd index dc4f1e6..406cb88 100644 --- a/sysconfig.dhcpd +++ b/sysconfig.dhcpd @@ -16,6 +16,28 @@ # DHCPD_INTERFACE="" +## Type: list(yes,no,auto,) +## Default: +## Description: Restart dhcp server when interface goes up (again) +# +# When the dhcp server is listening on a virtual interface, e.g. bridge, +# bonding or vlan, and this interface gets deleted and recreated during +# a network restart, dhcpd will stop answering requests on this interface +# and needs a restart as well. +# Begining with SLE-10 SP3, we install an if-up.d post script (see ifup(8) +# and also ifservices(5)), enabled in auto mode by default. This variable +# can be used to force or avoid the dhcp server restart: +# +# no: do not restart dhcpd +# yes: force a dhcp server restart +# auto: (default) restart for virtual interfaces (bond,bridge,vlan) when +# all interfaces used in DHCPD_INTERFACE variable are up as well. +# +# Except of this global setting, the variable can be specified per interface +# in the interface configurations (/etc/sysconfig/network/ifcfg-$name). +# +DHCPD_IFUP_RESTART="" + ## Type: yesno ## Default: yes ## ServiceRestart: dhcpd