[ovs-dev] [PATCH] rhel: update openvswitch init script to include functionality in debians init script.

Gurucharan Shetty shettyg at nicira.com
Tue Oct 1 16:15:16 UTC 2013


On Mon, Sep 30, 2013 at 6:47 PM, Duffie Cooley <dcooley at nicira.com> wrote:
> From: Duffie Cooley <dcooley at nicira.com>
>
> This pulls some of the changes to the debian init script into the rhel init
> script. Specifically this is a fix for a request to make sure that the
> openvswitch status command  in rhel based distros gives a useful exit
> status. That was fixed in
>
> commit 5e0c05bc058c78a11be6747f62e6ad88e5d06b70
> debian: Fix exit status of openvswitch-switch init script "status"
> command
>
> This patch also pulls in the load_kmod logic in
>
> commit 19cbf2b8a49d18eb8a8047c3b03953e6e9f0116f
> debian: force-reload-kmod while package upgrading.
>
> to enable users of rhel based distros to have the same
> functionality.
>
>
> Signed-off-by: Duffie Cooley <dcooley at nicira.com>
> ---
>  rhel/etc_init.d_openvswitch | 56
> ++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 53 insertions(+), 3 deletions(-)
>
> diff --git a/rhel/etc_init.d_openvswitch b/rhel/etc_init.d_openvswitch
> index 7e64132..e02174d 100755
> --- a/rhel/etc_init.d_openvswitch
> +++ b/rhel/etc_init.d_openvswitch
> @@ -1,6 +1,6 @@
>  #!/bin/sh
>  #
> -# openvswitch
> +# Copyright (C) 2013 Nicira, Inc.
>  #
>  # chkconfig: 2345 09 91
>  # description: Manage Open vSwitch kernel modules and user-space daemons
> @@ -30,7 +30,29 @@
>  . /usr/share/openvswitch/scripts/ovs-lib || exit 1
>  test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch
>
> +load_kmod () {
> +    ovs_ctl load-kmod || exit $?
> +}
> +
>  start () {
> +    if ovs_ctl load-kmod; then
> +        :
> +    else
> +        echo "Module has probably not been built for this kernel."
> +    fi
We will try to load the kernel module inside the 'ovs-ctl start'. But
I see how this error message is more clear.
I wonder whether a 'load-kmod' command will also be helpful in the
case statements at the end of the file.
>      set ovs_ctl ${1-start}
>      set "$@" --system-id=random
>      if test X"$FORCE_COREFILES" != X; then
> @@ -46,7 +68,7 @@ start () {
>      set "$@" --mlockall="$VSWITCHD_MLOCKALL"
>      fi
>      set "$@" $OVS_CTL_OPTS
> -    "$@"
> +    "$@" || exit $?
>
>      touch /var/lock/subsys/openvswitch
>  }
> @@ -57,8 +79,35 @@ stop () {
>  }
>
>  restart () {
> -    if [ "$1" = "--save-flows=yes" ]; then
> +    # OVS_FORCE_RELOAD_KMOD can be set by package postinst script.
> +    if [ "$1" = "--save-flows=yes" ] || \
> +        [ "${OVS_FORCE_RELOAD_KMOD}" = "no" ]; then
>          start restart
> +    elif [ "${OVS_FORCE_RELOAD_KMOD}" = "yes" ]; then
> +        depmod -a
> +
> +        if [ -e /sys/module/openvswitch ]; then
> +            LOADED_SRCVERSION=`cat /sys/module/openvswitch/srcversion`
> +            LOADED_VERSION=`cat /sys/module/openvswitch/version`
> +        elif [ -e /sys/module/openvswitch_mod ]; then
> +            LOADED_SRCVERSION=`cat /sys/module/openvswitch_mod/srcversion`
> +            LOADED_VERSION=`cat /sys/module/openvswitch_mod/version`
> +        fi
> +        SRCVERSION=`modinfo -F srcversion openvswitch 2>/dev/null`
> +        VERSION=`modinfo -F version openvswitch 2>/dev/null`
> +
> +        ovs_ctl_log "Package upgrading:\n"\
> +                    "Loaded version: ${LOADED_VERSION}
> ${LOADED_SRCVERSION}.\n"\
> +                    "Version on disk: ${VERSION} ${SRCVERSION}."
> +
> +        # If the kernel module was previously loaded and it is
> different than
> +        # the kernel module on disk, then do a 'force-reload-kmod'.
> +        if [ -n "${LOADED_SRCVERSION}" ] && [ -n "${SRCVERSION}" ] && \
> +            [ "${SRCVERSION}" != "${LOADED_SRCVERSION}" ]; then
> +            start force-reload-kmod
> +        else
> +            start restart
> +        fi
Duffie,
 The above logic is used during package upgrading in debian based
systems. After a package is upgraded there, packages automatically do
a 'restart' and that would not replace the kernel module. To replace
the kernel module, one would previously have to run the
'force-reload-kmod' command again manually resulting in 2 restarts
which can be considered expensive. With the above logic, we solved
that problem for debian based systems.

In case of RHEL, there is no automatic restart after a package
upgrade. The user has a choice either to do a 'restart' or
'force-reload-kmod'. So I am not sure the second part of the above
patch actually helps RHEL environment.




>      else
>          stop
>          start
> @@ -81,6 +130,7 @@ case $1 in
>          ;;
>      status)
>          ovs_ctl status
> +        exit $?
>          ;;
>      version)
>          ovs_ctl version
> --
> 1.8.1.2
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list