TT#14008 unload kernel module after shutdown

This has become important after the latest change to run rtpengine as
non-root user as it requires reloading the kernel module with the new
user/group permissions.

Change-Id: Iedf2624402397f5d444955e9d5d6d5aa414be1c3
pull/1446/head
Richard Fuchs 3 years ago
parent f738752793
commit 23f5660314

@ -74,11 +74,30 @@ firewall_teardown()
return
fi
# XXX: Wait a bit to make sure the daemon has been stopped.
sleep 1
# The daemon might take a little while to stop: keep trying to remove the
# table until we can.
for x in $(seq 1 10); do
TABLE_REMOVE_SUCCESS=true
if [ ! -e /proc/rtpengine/control ]; then
break
fi
if [ ! -d /proc/rtpengine/"$TABLE" ]; then
break
fi
if [ -e /proc/rtpengine/control ]; then
echo "del $TABLE" >/proc/rtpengine/control 2>/dev/null
if [ $? -eq 0 ]; then
break
fi
TABLE_REMOVE_SUCCESS=false
sleep 0.1
done
if ! $TABLE_REMOVE_SUCCESS; then
echo "Failed to remove the iptables kernel table after shutdown of rtpengine." >&2
return
fi
if [ "$MANAGE_IPTABLES" != "yes" ]; then
@ -87,6 +106,25 @@ firewall_teardown()
iptables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
ip6tables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
# The module refcount might also be delayed going to zero.
for x in $(seq 1 10); do
MODULE_UNLOAD_SUCCESS=true
if ! lsmod | grep -q "$MODNAME"; then
break
fi
if rmmod "$MODNAME"; then
break
fi
MODULE_UNLOAD_SUCCESS=false
sleep 0.1
done
if ! $MODULE_UNLOAD_SUCCESS; then
echo "Failed to unload the kernel module $MODNAME." >&2
fi
}
case "$1" in

Loading…
Cancel
Save