Skip to content

Commit

Permalink
controller: fix DHCP MTU when the default network mode is underlay (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian authored Jun 14, 2023
1 parent ea56b56 commit 88f706e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,25 +596,24 @@ func (c *Controller) checkSubnetConflict(subnet *kubeovnv1.Subnet) error {
}

func (c *Controller) updateSubnetDHCPOption(subnet *kubeovnv1.Subnet, needRouter bool) error {
var dhcpOptionsUUIDs *ovs.DHCPOptionsUUIDs
var err error
var mtu int
if subnet.Spec.Vlan != "" {
mtu = 1500
} else {
mtu := util.DefaultMTU
if subnet.Spec.Vlan == "" {
switch c.config.NetworkType {
case util.NetworkTypeVxlan:
mtu = 1500 - util.VxlanHeaderLength
case util.NetworkTypeVlan:
// default to geneve
fallthrough
case util.NetworkTypeGeneve:
mtu = 1500 - util.GeneveHeaderLength
mtu -= util.GeneveHeaderLength
case util.NetworkTypeVxlan:
mtu -= util.VxlanHeaderLength
case util.NetworkTypeStt:
mtu = 1500 - util.SttHeaderLength
mtu -= util.SttHeaderLength
default:
return fmt.Errorf("invalid network type: %s", c.config.NetworkType)
}
}

dhcpOptionsUUIDs, err = c.ovnLegacyClient.UpdateDHCPOptions(subnet.Name, subnet.Spec.CIDRBlock, subnet.Spec.Gateway, subnet.Spec.DHCPv4Options, subnet.Spec.DHCPv6Options, subnet.Spec.EnableDHCP, mtu)
dhcpOptionsUUIDs, err := c.ovnLegacyClient.UpdateDHCPOptions(subnet.Name, subnet.Spec.CIDRBlock, subnet.Spec.Gateway, subnet.Spec.DHCPv4Options, subnet.Spec.DHCPv6Options, subnet.Spec.EnableDHCP, mtu)
if err != nil {
klog.Errorf("failed to update dhcp options for switch %s, %v", subnet.Name, err)
return err
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const (
SubnetAllowPriority = "1001"
DefaultDropPriority = "1000"

DefaultMTU = 1500

GeneveHeaderLength = 100
VxlanHeaderLength = 50
SttHeaderLength = 72
Expand Down

0 comments on commit 88f706e

Please sign in to comment.