diff --git a/attributes/default.rb b/attributes/default.rb index 982b4a21..2a8be1ac 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -72,6 +72,12 @@ default["openstack"]["network"]["api"]["bind_port"] = 9696 # logging attribute default["openstack"]["network"]["syslog"]["use"] = false +# Whether or not we want to disable offloading +# on all the NIC interfaces (currently only supports +# ubuntu and debian). This can help if openvswitch +# or nicira plugins are crashing the sdn routers +default['openstack']['network']['disable_offload'] = false + # the plugins to install on the server. this will be # quantum-plugin-%plugin% and the first plugin in the # list should match the core plugin below diff --git a/files/default/disable-eth-offload.sh b/files/default/disable-eth-offload.sh new file mode 100755 index 00000000..2ffad12a --- /dev/null +++ b/files/default/disable-eth-offload.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2013 ATT Services, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +### BEGIN INIT INFO +# Provides: disable-eth-offload +# Required-Start: $network +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Disable NIC Offloads +### END INIT INFO + +function check_setting() { + setting_on="false" + INTERFACE=$1 + SETTING=$2 + if [ -z $INTERFACE ] || [ -z $SETTING ]; then + echo "You didn't call check_setting right, it needs interfaces as \$1 and setting as \$2" + exit 1 + fi + + if [ $LOGGING == "true" ]; then + ethtool -k $INTERFACE | grep $SETTING | grep ": on" + fi + + ethtool -k $INTERFACE | grep $SETTING | grep ": on" > /dev/null + if [ $? == 0 ]; then + setting_on="true" + fi +} + +start () { + + INTERFACES=$( grep auto /etc/network/interfaces | grep -v lo | awk '{ print $NF }' ) + declare -A SETTINGS + SETTINGS=( ["lro"]="large-receive-offload" ["tso"]="tcp-segmentation-offload" ["gso"]="generic-segmentation-offload" ["gro"]="generic-receive-offload" ) + ETHTOOL_BIN="/sbin/ethtool" + LOGGING="false" + setting_on="false" + + for interface in $INTERFACES; do + for setting in "${!SETTINGS[@]}"; do + check_setting $interface ${SETTINGS[$setting]} + if [ $setting_on == "true" ]; then + $ETHTOOL_BIN -K $interface $setting off + if [ $LOGGING == "true" ]; then + echo "RUNNING: $ETHTOOL_BIN -K $interface $setting off" + fi + fi + done + done +} + +case $1 in + start) + start + ;; + *) + echo "Usage: $0 {start}" >&2 + exit 1 + ;; +esac + +exit 0 + diff --git a/recipes/openvswitch.rb b/recipes/openvswitch.rb index d7d81060..2ea3bbd4 100644 --- a/recipes/openvswitch.rb +++ b/recipes/openvswitch.rb @@ -99,3 +99,29 @@ if not ["nicira", "plumgrid", "bigswitch"].include?(main_plugin) notifies :restart, "service[quantum-plugin-openvswitch-agent]", :delayed end end + +if node['openstack']['network']['disable_offload'] + + package "ethtool" do + action :install + options platform_options["package_overrides"] + end + + service "disable-eth-offload" do + supports :restart => false, :start => true, :stop => false, :reload => false + priority({ 2 => [ :start, 19 ]}) + action :nothing + end + + # a priority of 19 ensures we start before openvswitch + # at least on ubuntu and debian + cookbook_file "disable-eth-offload-script" do + path "/etc/init.d/disable-eth-offload" + source "disable-eth-offload.sh" + owner "root" + group "root" + mode "0755" + notifies :enable, "service[disable-eth-offload]" + notifies :start, "service[disable-eth-offload]" + end +end