Skip to content

Commit

Permalink
fix setting mtu for ovs internal port (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Jan 29, 2023
1 parent 9195dbd commit e70839b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pkg/daemon/ovs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,6 @@ func configureMirrorLink(portName string, mtu int) error {
return fmt.Errorf("can not find mirror nic %s: %v", portName, err)
}

if err = netlink.LinkSetMTU(mirrorLink, mtu); err != nil {
return fmt.Errorf("can not set mirror nic mtu: %v", err)
}

if mirrorLink.Attrs().OperState != netlink.OperUp {
if err = netlink.LinkSetUp(mirrorLink); err != nil {
return fmt.Errorf("can not set mirror nic %s up: %v", portName, err)
Expand All @@ -467,8 +463,13 @@ func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPCo
}

if mtu > 0 {
if err = netlink.LinkSetMTU(nodeLink, mtu); err != nil {
return fmt.Errorf("can not set nic %s mtu: %v", link, err)
if nodeLink.Type() == "openvswitch" {
_, err = ovs.Exec("set", "interface", link, fmt.Sprintf(`mtu_request=%d`, mtu))
} else {
err = netlink.LinkSetMTU(nodeLink, mtu)
}
if err != nil {
return fmt.Errorf("failed to set nic %s mtu: %v", link, err)
}
}

Expand Down Expand Up @@ -601,9 +602,6 @@ func configProviderNic(nicName, brName string) (int, error) {
}
}

if err = netlink.LinkSetMTU(bridge, nic.Attrs().MTU); err != nil {
return 0, fmt.Errorf("failed to set MTU of OVS bridge %s: %v", brName, err)
}
if err = netlink.LinkSetUp(bridge); err != nil {
return 0, fmt.Errorf("failed to set OVS bridge %s up: %v", brName, err)
}
Expand Down

0 comments on commit e70839b

Please sign in to comment.