Some while ago Netlink Family names were changed from ODP_* to OVS_*. This leaded to upgrade related issues when the new ovs-dpctl wanted to remove existing datapaths from the old kernel module by using 'ovs_datapath' instead of 'odp_datapath' name.
This patch allows package preinst scipts to take a copy of the old ovs-dpctl tool for later use. Issue #8548 --- debian/automake.mk | 1 + debian/openvswitch-switch.postrm | 1 + debian/openvswitch-switch.preinst | 11 +++++++++++ rhel/openvswitch.spec.in | 8 ++++++++ utilities/ovs-ctl.in | 36 +++++++++++++++++++++++++++++++++--- xenserver/openvswitch-xen.spec | 8 ++++++++ 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 debian/openvswitch-switch.preinst diff --git a/debian/automake.mk b/debian/automake.mk index d289830..f37e6de 100644 --- a/debian/automake.mk +++ b/debian/automake.mk @@ -39,6 +39,7 @@ EXTRA_DIST += \ debian/openvswitch-switch.manpages \ debian/openvswitch-switch.postinst \ debian/openvswitch-switch.postrm \ + debian/openvswitch-switch.preinst \ debian/openvswitch-switch.template \ debian/ovsdbmonitor.install \ debian/ovsdbmonitor.manpages \ diff --git a/debian/openvswitch-switch.postrm b/debian/openvswitch-switch.postrm index b785c54..b264dc4 100755 --- a/debian/openvswitch-switch.postrm +++ b/debian/openvswitch-switch.postrm @@ -25,6 +25,7 @@ case "$1" in rm -f /etc/openvswitch/.conf.db.~lock~ rm -f /etc/default/openvswitch-switch rm -f /var/log/openvswitch/* + rm -f /usr/bin/ovs-dpctl.old ;; remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) diff --git a/debian/openvswitch-switch.preinst b/debian/openvswitch-switch.preinst new file mode 100644 index 0000000..6f8dff2 --- /dev/null +++ b/debian/openvswitch-switch.preinst @@ -0,0 +1,11 @@ +#!/bin/sh +# preinst script for openvswitch-switch +# +# see: dh_installdeb(1) + +set -e + +dpctl=`command -v ovs-dpctl || true` +if [ $dpctl ]; then + command -v ovs-dpctl.old > /dev/null || cp $dpctl $dpctl.old || true +fi \ No newline at end of file diff --git a/rhel/openvswitch.spec.in b/rhel/openvswitch.spec.in index 2cf9535..fd0c695 100644 --- a/rhel/openvswitch.spec.in +++ b/rhel/openvswitch.spec.in @@ -61,6 +61,13 @@ install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch %clean rm -rf $RPM_BUILD_ROOT +%pre +dpctl=`command -v ovs-dpctl || true` +if [ $dpctl ]; then + command -v ovs-dpctl.old > /dev/null || cp $dpctl $dpctl.old || true +fi + + %post # Create default or update existing /etc/sysconfig/openvswitch. SYSCONFIG=/etc/sysconfig/openvswitch @@ -92,6 +99,7 @@ if [ "$1" = "0" ]; then # $1 = 0 for uninstall rm -f /etc/openvswitch/conf.db rm -f /etc/sysconfig/openvswitch rm -f /etc/openvswitch/vswitchd.cacert + rm -f /usr/bin/ovs-dpctl.old fi exit 0 diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index 8788e4a..67a3ff9 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -260,11 +260,41 @@ save_interfaces () { "$datadir/scripts/ovs-save" $ifaces > "$script" } +get_right_dpctl() { + # Output the right ovs-dpctl that can remove datapaths from currently + # loaded kernel module. + # + # This is a workaround so that users could upgrade OpenvSwitch without + # rebooting Linux due to the Netlink family name change from ODP_* + # to OVS_*. + # + # The package preinst script creates a copy of the old ovs-dpctl binary. + # If the new ovs-dpctl binary is not able to communicate with + # kernel space, then the force-reload-kmod command will fall-back to + # the old ovs-dpctl binary. + ret1=1 + ret2=1 + if [ `command -v ovs-dpctl` ]; then + ovs-dpctl dump-dps > /dev/null 2>&1 + ret1=$? + fi + if [ `command -v ovs-dpctl.old` ]; then + ovs-dpctl.old dump-dps > /dev/null 2>&1 + ret2=$? + fi + if [ $ret1 -ne 0 ] && [ $ret2 -eq 0 ]; then + printf "ovs-dpctl.old" + else + printf "ovs-dpctl" + fi +} + force_reload_kmod () { ifaces=`internal_interfaces` action "Detected internal interfaces: $ifaces" true - + dpctl=`get_right_dpctl` stop + log_success_msg "Using $dpctl to remove datapaths from kernel module" script=`mktemp` trap 'rm -f "$script"' 0 1 2 13 15 @@ -277,8 +307,8 @@ force_reload_kmod () { fi chmod +x "$script" - for dp in `ovs-dpctl dump-dps`; do - action "Removing datapath: $dp" ovs-dpctl del-dp "$dp" + for dp in `$dpctl dump-dps`; do + action "Removing datapath: $dp" $dpctl del-dp "$dp" done if test -e /sys/module/brcompat_mod; then diff --git a/xenserver/openvswitch-xen.spec b/xenserver/openvswitch-xen.spec index f5c1231..f1dcaa3 100644 --- a/xenserver/openvswitch-xen.spec +++ b/xenserver/openvswitch-xen.spec @@ -126,6 +126,13 @@ install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch %clean rm -rf $RPM_BUILD_ROOT +%pre +dpctl=`command -v ovs-dpctl || true` +if [ $dpctl ]; then + command -v ovs-dpctl.old > /dev/null || cp $dpctl $dpctl.old || true +fi + + %post if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else cat >>/etc/sysctl.conf <<EOF @@ -309,6 +316,7 @@ if [ "$1" = "0" ]; then # $1 = 0 for uninstall rm -f /etc/openvswitch/conf.db rm -f /etc/sysconfig/openvswitch rm -f /etc/openvswitch/vswitchd.cacert + rm -f /usr/bin/ovs-dpctl.old # Remove saved XenServer scripts directory, but only if it's empty rmdir -p /usr/lib/openvswitch/xs-saved 2>/dev/null -- 1.7.4.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev