Merge pull request #12711 from swordqiu/feature/qj-ethtool-enable-gso-option

fix: add host option for ethtool_enable_gso
This commit is contained in:
Zexi Li
2021-11-19 18:30:14 +08:00
committed by GitHub
3 changed files with 17 additions and 6 deletions
@@ -78,7 +78,7 @@ func NewBaseBridgeDriver(bridge, inter, ip string) (*SBaseBridgeDriver, error) {
return nil, fmt.Errorf("%s not exists", inter)
}
bd.ip = ip
bd.inter.DisableGso()
bd.inter.SetupGso(options.HostOptions.EthtoolEnableGso)
} else if len(ip) > 0 {
return nil, fmt.Errorf("A bridge without interface must have no IP")
}
+4 -1
View File
@@ -18,6 +18,7 @@ import (
"os"
common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
"yunion.io/x/onecloud/pkg/util/fileutils2"
)
type SHostOptions struct {
@@ -147,6 +148,8 @@ type SHostOptions struct {
DisableKVM bool `help:"force disable KVM" default:"false" json:"disable_kvm"`
DisableGPU bool `help:"force disable GPU" default:"false" json:"disable_gpu"`
EthtoolEnableGso bool `help:"use ethtool to turn on or off GSO(generic segment offloading)" default:"false" json:"ethtool_enable_gso"`
}
var (
@@ -155,7 +158,7 @@ var (
func Parse() (hostOpts SHostOptions) {
common_options.ParseOptions(&hostOpts, os.Args, "host.conf", "host")
if len(hostOpts.CommonConfigFile) > 0 {
if len(hostOpts.CommonConfigFile) > 0 && fileutils2.Exists(hostOpts.CommonConfigFile) {
commonCfg := &common_options.HostCommonOptions{}
commonCfg.Config = hostOpts.CommonConfigFile
common_options.ParseOptions(commonCfg, []string{os.Args[0]}, "common.conf", "host")
+12 -4
View File
@@ -346,12 +346,20 @@ func (n *SNetInterface) fetchConfig(expectIp string) {
}
func (n *SNetInterface) DisableGso() {
// https://kris.io/2015/10/01/kvm-network-performance-tso-and-gso-turn-it-off/
// General speaking, it is recommended to turn of GSO
// however, this will degrade host network performance
func (n *SNetInterface) SetupGso(on bool) {
onoff := "off"
if on {
onoff = "on"
}
procutils.NewCommand(
"ethtool", "-K", n.name,
"tso", "off", "gso", "off",
"gro", "off", "tx", "off",
"rx", "off", "sg", "off").Run()
"tso", onoff, "gso", onoff,
"ufo", onoff, "lro", onoff,
"gro", onoff, "tx", onoff,
"rx", onoff, "sg", onoff).Run()
}
func (n *SNetInterface) IsSecretInterface() bool {