Skip to content

Commit

Permalink
add loop check for tunnel nic (#4736)
Browse files Browse the repository at this point in the history
* add loop check for tunnel nic

Signed-off-by: dolibali <[email protected]>

* fix gofumpt err

Signed-off-by: dolibali <[email protected]>

---------

Signed-off-by: dolibali <[email protected]>
Co-authored-by: dolibali <[email protected]>
  • Loading branch information
dolibali and dolibali authored Nov 18, 2024
1 parent 1bf233b commit ae4ce37
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
klog.Info("Started workers")
go wait.Until(c.loopOvn0Check, 5*time.Second, stopCh)
go wait.Until(c.loopOvnExt0Check, 5*time.Second, stopCh)
go wait.Until(c.loopTunnelCheck, 5*time.Second, stopCh)
go wait.Until(c.runAddOrUpdateProviderNetworkWorker, time.Second, stopCh)
go wait.Until(c.runDeleteProviderNetworkWorker, time.Second, stopCh)
go wait.Until(c.runSubnetWorker, time.Second, stopCh)
Expand Down
30 changes: 30 additions & 0 deletions pkg/daemon/ovs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,36 @@ func (c *Controller) loopOvn0Check() {
}
}

// This method checks the status of the tunnel interface,
// If the interface is found to be down, it attempts to bring it up
func (c *Controller) loopTunnelCheck() {
tunnelType := c.config.NetworkType
var tunnelNic string
switch tunnelType {
case "vxlan":
tunnelNic = util.VxlanNic
case "geneve":
tunnelNic = util.GeneveNic
case "stt":
// TODO: tunnelNic = "stt tunnel nic name"
return
default:
return
}

link, err := netlink.LinkByName(tunnelNic)
if err != nil || link == nil {
return
}

if link.Attrs().OperState == netlink.OperDown {
klog.Errorf("nic: %s is down, attempting to bring it up", tunnelNic)
if err := netlink.LinkSetUp(link); err != nil {
klog.Errorf("fail to bring up nic: %s, %v", tunnelNic, err)
}
}
}

func (c *Controller) checkNodeGwNicInNs(nodeExtIP, ip, gw string, gwNS ns.NetNS) error {
exists, err := ovs.PortExists(util.NodeGwNic)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/daemon/ovs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ func (c *Controller) loopOvnExt0Check() {
// no need to check ovnext0 on Windows
}

func (c *Controller) loopTunnelCheck() {
// no need to check tunnel on Windows
}

func configureMirrorLink(portName string, mtu int) error {
adapter, err := util.GetNetAdapter(portName, false)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ const (
NodeLspPrefix = "node-"
NodeAllowPriority = "3000"

VxlanNic = "vxlan_sys_4789"
GeneveNic = "genev_sys_6081"

SecurityGroupHighestPriority = "2300"
SecurityGroupBasePriority = "2005"
SecurityGroupAllowPriority = "2004"
Expand Down

0 comments on commit ae4ce37

Please sign in to comment.