mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix: host disable gso for specific nics
This commit is contained in:
@@ -80,7 +80,25 @@ func NewBaseBridgeDriver(bridge, inter, ip string) (*SBaseBridgeDriver, error) {
|
||||
return nil, fmt.Errorf("%s not exists", inter)
|
||||
}
|
||||
bd.ip = ip
|
||||
bd.inter.SetupGso(options.HostOptions.EthtoolEnableGso)
|
||||
var enableGso bool
|
||||
if len(options.HostOptions.EthtoolEnableGsoInterfaces) > 0 {
|
||||
if utils.IsInStringArray(bridge, options.HostOptions.EthtoolEnableGsoInterfaces) ||
|
||||
utils.IsInStringArray(inter, options.HostOptions.EthtoolEnableGsoInterfaces) {
|
||||
enableGso = true
|
||||
} else {
|
||||
enableGso = false
|
||||
}
|
||||
} else if len(options.HostOptions.EthtoolDisableGsoInterfaces) > 0 {
|
||||
if utils.IsInStringArray(bridge, options.HostOptions.EthtoolDisableGsoInterfaces) ||
|
||||
utils.IsInStringArray(inter, options.HostOptions.EthtoolDisableGsoInterfaces) {
|
||||
enableGso = false
|
||||
} else {
|
||||
enableGso = true
|
||||
}
|
||||
} else {
|
||||
enableGso = options.HostOptions.EthtoolEnableGso
|
||||
}
|
||||
bd.inter.SetupGso(enableGso)
|
||||
} else if len(ip) > 0 {
|
||||
return nil, fmt.Errorf("A bridge without interface must have no IP")
|
||||
}
|
||||
|
||||
@@ -1621,10 +1621,9 @@ func (h *SHostInfo) doSyncNicInfo(nic *SNIC) error {
|
||||
content := jsonutils.NewDict()
|
||||
content.Set("bridge", jsonutils.NewString(nic.Bridge))
|
||||
content.Set("interface", jsonutils.NewString(nic.Inter))
|
||||
query := jsonutils.NewDict()
|
||||
query.Set("mac_addr", jsonutils.NewString(nic.BridgeDev.GetMac()))
|
||||
content.Set("mac_addr", jsonutils.NewString(nic.BridgeDev.GetMac()))
|
||||
_, err := modules.Hostwires.Update(h.GetSession(),
|
||||
h.HostId, nic.WireId, query, content)
|
||||
h.HostId, nic.WireId, nil, content)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "modules.Hostwires.Update")
|
||||
}
|
||||
@@ -2137,6 +2136,7 @@ func (h *SHostInfo) OnCatalogChanged(catalog mcclient.KeystoneServiceCatalogV3)
|
||||
|
||||
func (h *SHostInfo) getNicsTelegrafConf() []map[string]interface{} {
|
||||
var ret = make([]map[string]interface{}, 0)
|
||||
existing := make(map[string]struct{})
|
||||
for i, n := range h.Nics {
|
||||
ret = append(ret, map[string]interface{}{
|
||||
"name": n.Inter,
|
||||
@@ -2148,6 +2148,16 @@ func (h *SHostInfo) getNicsTelegrafConf() []map[string]interface{} {
|
||||
"alias": fmt.Sprintf("br%d", i),
|
||||
"speed": n.Bandwidth,
|
||||
})
|
||||
existing[n.Inter] = struct{}{}
|
||||
}
|
||||
phyNics, _ := sysutils.Nics()
|
||||
for _, pnic := range phyNics {
|
||||
if _, ok := existing[pnic.Dev]; !ok {
|
||||
ret = append(ret, map[string]interface{}{
|
||||
"name": pnic.Dev,
|
||||
"speed": pnic.Speed,
|
||||
})
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -175,6 +175,9 @@ type SHostOptions struct {
|
||||
|
||||
EthtoolEnableGso bool `help:"use ethtool to turn on or off GSO(generic segment offloading)" default:"false" json:"ethtool_enable_gso"`
|
||||
|
||||
EthtoolEnableGsoInterfaces []string `help:"use ethtool to turn on GSO for the specific interfaces" json:"ethtool_enable_gso_interfaces"`
|
||||
EthtoolDisableGsoInterfaces []string `help:"use ethtool to turn off GSO for the specific interfaces" json:"ethtool_disable_gso_interfaces"`
|
||||
|
||||
EnableVmUuid bool `help:"enable vm UUID" default:"true" json:"enable_vm_uuid"`
|
||||
|
||||
EnableVirtioRngDevice bool `help:"enable qemu virtio-rng device" default:"true"`
|
||||
|
||||
Reference in New Issue
Block a user