Skip to content

Commit

Permalink
fix memory overflow, add mac_binding related options to router (#4603) (
Browse files Browse the repository at this point in the history
#4608)

* add options to router
always_learn_from_arp_request: false
dynamic_neigh_routers: true
mac_binding_age_threshold: 300

Signed-off-by: clyi <[email protected]>
  • Loading branch information
changluyi authored Oct 15, 2024
1 parent 207fcfb commit 6da2b51
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
38 changes: 38 additions & 0 deletions mocks/pkg/ovs/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,25 @@ func (c *Controller) initNodeSwitch() error {

// InitClusterRouter init cluster router to connect different logical switches
func (c *Controller) initClusterRouter() error {
return c.OVNNbClient.CreateLogicalRouter(c.config.ClusterRouter)
if err := c.OVNNbClient.CreateLogicalRouter(c.config.ClusterRouter); err != nil {
klog.Errorf("create logical router %s failed: %v", c.config.ClusterRouter, err)
return err
}

lr, err := c.OVNNbClient.GetLogicalRouter(c.config.ClusterRouter, false)
if err != nil {
klog.Errorf("get logical router %s failed: %v", c.config.ClusterRouter, err)
return err
}

lr.Options = map[string]string{"always_learn_from_arp_request": "false", "dynamic_neigh_routers": "true", "mac_binding_age_threshold": "300"}
err = c.OVNNbClient.UpdateLogicalRouter(lr, &lr.Options)
if err != nil {
klog.Errorf("update logical router %s failed: %v", c.config.ClusterRouter, err)
return err
}

return nil
}

func (c *Controller) initLB(name, protocol string, sessionAffinity bool) error {
Expand Down
19 changes: 18 additions & 1 deletion pkg/controller/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,24 @@ func (c *Controller) getVpcSubnets(vpc *kubeovnv1.Vpc) (subnets []string, defaul

// createVpcRouter create router to connect logical switches in vpc
func (c *Controller) createVpcRouter(lr string) error {
return c.OVNNbClient.CreateLogicalRouter(lr)
if err := c.OVNNbClient.CreateLogicalRouter(lr); err != nil {
klog.Errorf("create logical router %s failed: %v", lr, err)
return err
}

vpcRouter, err := c.OVNNbClient.GetLogicalRouter(lr, false)
if err != nil {
klog.Errorf("get logical router %s failed: %v", lr, err)
return err
}

vpcRouter.Options = map[string]string{"always_learn_from_arp_request": "false", "dynamic_neigh_routers": "true", "mac_binding_age_threshold": "300"}
err = c.OVNNbClient.UpdateLogicalRouter(vpcRouter, &vpcRouter.Options)
if err != nil {
klog.Errorf("update logical router %s failed: %v", lr, err)
return err
}
return nil
}

// deleteVpcRouter delete router to connect logical switches in vpc
Expand Down
1 change: 1 addition & 0 deletions pkg/ovs/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type NBGlobal interface {

type LogicalRouter interface {
CreateLogicalRouter(lrName string) error
UpdateLogicalRouter(lr *ovnnb.LogicalRouter, fields ...interface{}) error
DeleteLogicalRouter(lrName string) error
LogicalRouterUpdateLoadBalancers(lrName string, op ovsdb.Mutator, lbNames ...string) error
GetLogicalRouter(lrName string, ignoreNotFound bool) (*ovnnb.LogicalRouter, error)
Expand Down

0 comments on commit 6da2b51

Please sign in to comment.