From 3d9e09a4a0abbaab69c716365dc3a9ba2b717f53 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 27 Jan 2015 12:35:11 -0500 Subject: [PATCH] dispatcher: fix ifcfg-rh example dispatcher script (rh #1160013) Routing table entries for a device get flushed when the device is deactivated, but rules table entries don't, so we have to flush them by hand. --- contrib/fedora/rpm/NetworkManager.spec | 3 ++- examples/dispatcher/10-ifcfg-rh-routes.sh | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 70884ff..cf95985 100644 --- a/examples/dispatcher/10-ifcfg-rh-routes.sh +++ b/examples/dispatcher/10-ifcfg-rh-routes.sh @@ -5,7 +5,12 @@ # interfaces that have routing rules associated with them that can't # be expressed by NMSettingIPConfig. (Eg, policy-based routing.) -# This should be installed in dispatcher.d/pre-up.d/ +# This should be installed in both dispatcher.d/ and +# dispatcher.d/pre-up.d/ + +if [ "$2" != "pre-up" -a "$2" != "down" ]; then + exit 0 +fi dir=$(dirname "$CONNECTION_FILENAME") if [ "$dir" != "/etc/sysconfig/network-scripts" ]; then @@ -15,7 +20,15 @@ profile=$(basename "$CONNECTION_FILENAME" | sed -ne 's/^ifcfg-//p') if [ -z "$profile" ]; then exit 0 fi - -if [ -f "$dir/rule-$profile" -o -f "$dir/rule6-$profile" ]; then - /etc/sysconfig/network-scripts/ifup-routes "$DEVICE_IP_IFACE" "$profile" +if ! [ -f "$dir/rule-$profile" -o -f "$dir/rule6-$profile" ]; then + exit 0 fi + +case "$2" in + pre-up) + /etc/sysconfig/network-scripts/ifup-routes "$DEVICE_IP_IFACE" "$profile" + ;; + down) + /etc/sysconfig/network-scripts/ifdown-routes "$DEVICE_IP_IFACE" "$profile" + ;; +esac -- 1.9.3