mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-19 13:48:06 +00:00
base-files, ppp: remove protocol specific cleanup code from /sbin/ifdown and move it to protocol stop callbacks
SVN-Revision: 21383
This commit is contained in:
parent
731983969a
commit
66ab73d01f
@ -264,7 +264,6 @@ setup_interface() {
|
|||||||
}
|
}
|
||||||
set_interface_ifname "$config" "$iface_main"
|
set_interface_ifname "$config" "$iface_main"
|
||||||
|
|
||||||
pidfile="/var/run/$iface_main.pid"
|
|
||||||
[ -n "$proto" ] || config_get proto "$config" proto
|
[ -n "$proto" ] || config_get proto "$config" proto
|
||||||
case "$proto" in
|
case "$proto" in
|
||||||
static)
|
static)
|
||||||
@ -272,11 +271,14 @@ setup_interface() {
|
|||||||
setup_interface_static "$iface_main" "$config"
|
setup_interface_static "$iface_main" "$config"
|
||||||
;;
|
;;
|
||||||
dhcp)
|
dhcp)
|
||||||
|
local lockfile="/var/lock/dhcp-$iface_main"
|
||||||
|
lock "$lockfile"
|
||||||
|
|
||||||
# prevent udhcpc from starting more than once
|
# prevent udhcpc from starting more than once
|
||||||
lock "/var/lock/dhcp-$iface_main"
|
local pidfile="/var/run/dhcp-${iface_main}.pid"
|
||||||
local pid="$(cat "$pidfile" 2>/dev/null)"
|
local pid="$(cat "$pidfile" 2>/dev/null)"
|
||||||
if [ -d "/proc/$pid" ] && grep udhcpc "/proc/${pid}/cmdline" >/dev/null 2>/dev/null; then
|
if [ -d "/proc/$pid" ] && grep -qs udhcpc "/proc/${pid}/cmdline"; then
|
||||||
lock -u "/var/lock/dhcp-$iface_main"
|
lock -u "$lockfile"
|
||||||
else
|
else
|
||||||
local ipaddr netmask hostname proto1 clientid
|
local ipaddr netmask hostname proto1 clientid
|
||||||
config_get ipaddr "$config" ipaddr
|
config_get ipaddr "$config" ipaddr
|
||||||
@ -292,7 +294,7 @@ setup_interface() {
|
|||||||
local dhcpopts
|
local dhcpopts
|
||||||
[ ."$proto1" != ."$proto" ] && dhcpopts="-n -q"
|
[ ."$proto1" != ."$proto" ] && dhcpopts="-n -q"
|
||||||
$DEBUG eval udhcpc -t 0 -i "$iface_main" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} ${clientid:+-c $clientid} -b -p "$pidfile" ${dhcpopts:- -O rootpath -R &}
|
$DEBUG eval udhcpc -t 0 -i "$iface_main" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} ${clientid:+-c $clientid} -b -p "$pidfile" ${dhcpopts:- -O rootpath -R &}
|
||||||
lock -u "/var/lock/dhcp-$iface_main"
|
lock -u "$lockfile"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
none)
|
none)
|
||||||
@ -329,6 +331,21 @@ setup_interface() {
|
|||||||
|
|
||||||
stop_interface_dhcp() {
|
stop_interface_dhcp() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
|
|
||||||
|
local iface
|
||||||
|
config_get iface "$config" iface
|
||||||
|
|
||||||
|
local lock="/var/lock/dhcp-${iface}"
|
||||||
|
[ -f "$lock" ] && lock -u "$lock"
|
||||||
|
|
||||||
|
local pidfile="/var/run/dhcp-${iface}.pid"
|
||||||
|
local pid="$(cat "$pidfile" 2>/dev/null)"
|
||||||
|
[ -d "/proc/$pid" ] && {
|
||||||
|
grep -qs udhcpc "/proc/$pid/cmdline" && kill -TERM $pid && \
|
||||||
|
while grep -qs udhcpc "/proc/$pid/cmdline"; do sleep 1; done
|
||||||
|
rm -f "$pidfile"
|
||||||
|
}
|
||||||
|
|
||||||
uci -P /var/state revert "network.$config"
|
uci -P /var/state revert "network.$config"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,28 +29,6 @@ config_get iface "$cfg" device
|
|||||||
# call interface stop handler
|
# call interface stop handler
|
||||||
( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
|
( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
|
||||||
|
|
||||||
# make sure all locks are removed
|
|
||||||
for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
|
|
||||||
[ -f "$lock" ] && {
|
|
||||||
lock -u "$lock"
|
|
||||||
sleep 1
|
|
||||||
}
|
|
||||||
done
|
|
||||||
|
|
||||||
# kill active ppp daemon and other processes
|
|
||||||
config_get ifname "$cfg" ifname
|
|
||||||
pids="$(head -n1 -q /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
|
|
||||||
for pid in $pids; do
|
|
||||||
[ -d "/proc/$pid" ] && {
|
|
||||||
kill $pid
|
|
||||||
[ -d "/proc/$pid" ] && {
|
|
||||||
sleep 1
|
|
||||||
kill -9 $pid 2>/dev/null >/dev/null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
done
|
|
||||||
rm -f /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid
|
|
||||||
|
|
||||||
config_get ifname "$cfg" ifname
|
config_get ifname "$cfg" ifname
|
||||||
config_get device "$cfg" device
|
config_get device "$cfg" device
|
||||||
|
|
||||||
|
@ -10,8 +10,13 @@ stop_interface_ppp() {
|
|||||||
local link="${proto:-ppp}-$ifname"
|
local link="${proto:-ppp}-$ifname"
|
||||||
[ -f "/var/run/ppp-${link}.pid" ] && {
|
[ -f "/var/run/ppp-${link}.pid" ] && {
|
||||||
local pid="$(head -n1 /var/run/ppp-${link}.pid 2>/dev/null)"
|
local pid="$(head -n1 /var/run/ppp-${link}.pid 2>/dev/null)"
|
||||||
grep -qs pppd "/proc/$pid/cmdline" && kill -TERM $pid
|
grep -qs pppd "/proc/$pid/cmdline" && kill -TERM $pid && \
|
||||||
|
while grep -qs pppd "/proc/$pid/cmdline"; do sleep 1; done
|
||||||
|
rm -f "/var/run/ppp-${link}.pid"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local lock="/var/lock/ppp-$link"
|
||||||
|
[ -f "$lock" ] && lock -u "$lock"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_pppd() {
|
start_pppd() {
|
||||||
|
Loading…
Reference in New Issue
Block a user