Skip to content

Commit ae4ce37

Browse files
dolibalidolibali
and
dolibali
authored
add loop check for tunnel nic (#4736)
* add loop check for tunnel nic Signed-off-by: dolibali <zhangzihao2_yewu@cmss.chinamobile.com> * fix gofumpt err Signed-off-by: dolibali <zhangzihao2_yewu@cmss.chinamobile.com> --------- Signed-off-by: dolibali <zhangzihao2_yewu@cmss.chinamobile.com> Co-authored-by: dolibali <zhangzihao2_yewu@cmss.chinamobile.com>
1 parent 1bf233b commit ae4ce37

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

pkg/daemon/controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
596596
klog.Info("Started workers")
597597
go wait.Until(c.loopOvn0Check, 5*time.Second, stopCh)
598598
go wait.Until(c.loopOvnExt0Check, 5*time.Second, stopCh)
599+
go wait.Until(c.loopTunnelCheck, 5*time.Second, stopCh)
599600
go wait.Until(c.runAddOrUpdateProviderNetworkWorker, time.Second, stopCh)
600601
go wait.Until(c.runDeleteProviderNetworkWorker, time.Second, stopCh)
601602
go wait.Until(c.runSubnetWorker, time.Second, stopCh)

pkg/daemon/ovs_linux.go

+30
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,36 @@ func (c *Controller) loopOvn0Check() {
714714
}
715715
}
716716

717+
// This method checks the status of the tunnel interface,
718+
// If the interface is found to be down, it attempts to bring it up
719+
func (c *Controller) loopTunnelCheck() {
720+
tunnelType := c.config.NetworkType
721+
var tunnelNic string
722+
switch tunnelType {
723+
case "vxlan":
724+
tunnelNic = util.VxlanNic
725+
case "geneve":
726+
tunnelNic = util.GeneveNic
727+
case "stt":
728+
// TODO: tunnelNic = "stt tunnel nic name"
729+
return
730+
default:
731+
return
732+
}
733+
734+
link, err := netlink.LinkByName(tunnelNic)
735+
if err != nil || link == nil {
736+
return
737+
}
738+
739+
if link.Attrs().OperState == netlink.OperDown {
740+
klog.Errorf("nic: %s is down, attempting to bring it up", tunnelNic)
741+
if err := netlink.LinkSetUp(link); err != nil {
742+
klog.Errorf("fail to bring up nic: %s, %v", tunnelNic, err)
743+
}
744+
}
745+
}
746+
717747
func (c *Controller) checkNodeGwNicInNs(nodeExtIP, ip, gw string, gwNS ns.NetNS) error {
718748
exists, err := ovs.PortExists(util.NodeGwNic)
719749
if err != nil {

pkg/daemon/ovs_windows.go

+4
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ func (c *Controller) loopOvnExt0Check() {
343343
// no need to check ovnext0 on Windows
344344
}
345345

346+
func (c *Controller) loopTunnelCheck() {
347+
// no need to check tunnel on Windows
348+
}
349+
346350
func configureMirrorLink(portName string, mtu int) error {
347351
adapter, err := util.GetNetAdapter(portName, false)
348352
if err != nil {

pkg/util/const.go

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ const (
133133
NodeLspPrefix = "node-"
134134
NodeAllowPriority = "3000"
135135

136+
VxlanNic = "vxlan_sys_4789"
137+
GeneveNic = "genev_sys_6081"
138+
136139
SecurityGroupHighestPriority = "2300"
137140
SecurityGroupBasePriority = "2005"
138141
SecurityGroupAllowPriority = "2004"

0 commit comments

Comments
 (0)