From 6044136041af2c8a527faa0e96e7f2e9ca721242 Mon Sep 17 00:00:00 2001 From: dolibali <139439533+dolibali@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:51:23 +0800 Subject: [PATCH] Increase code specification and readability in vxlan nic name and qos (#4896) * Increase code specification and readability in vxlan nic name and qos --------- Signed-off-by: dolibali Co-authored-by: dolibali --- cmd/daemon/init.go | 18 +++++++----------- pkg/daemon/controller_linux.go | 5 ++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cmd/daemon/init.go b/cmd/daemon/init.go index 4c323206df6..ebe2bf293db 100644 --- a/cmd/daemon/init.go +++ b/cmd/daemon/init.go @@ -9,11 +9,7 @@ import ( "kernel.org/pub/linux/libs/security/libcap/cap" "github.com/kubeovn/kube-ovn/pkg/daemon" -) - -const ( - geneveLinkName = "genev_sys_6081" - vxlanLinkName = "vxlan_sys_4789" + "github.com/kubeovn/kube-ovn/pkg/util" ) func printCaps() { @@ -22,27 +18,27 @@ func printCaps() { } func initForOS() error { - if _, err := netlink.LinkByName(geneveLinkName); err != nil { + if _, err := netlink.LinkByName(util.GeneveNic); err != nil { if _, ok := err.(netlink.LinkNotFoundError); ok { return nil } - klog.Errorf("failed to get link %s: %v", geneveLinkName, err) + klog.Errorf("failed to get link %s: %v", util.GeneveNic, err) return err } // disable checksum for genev_sys_6081 as default - return daemon.TurnOffNicTxChecksum(geneveLinkName) + return daemon.TurnOffNicTxChecksum(util.GeneveNic) } func setVxlanNicTxOff() error { - if _, err := netlink.LinkByName(vxlanLinkName); err != nil { + if _, err := netlink.LinkByName(util.VxlanNic); err != nil { if _, ok := err.(netlink.LinkNotFoundError); ok { return nil } - klog.Errorf("failed to get link %s: %v", vxlanLinkName, err) + klog.Errorf("failed to get link %s: %v", util.VxlanNic, err) return err } // disable checksum for vxlan_sys_4789 as default - return daemon.TurnOffNicTxChecksum(vxlanLinkName) + return daemon.TurnOffNicTxChecksum(util.VxlanNic) } diff --git a/pkg/daemon/controller_linux.go b/pkg/daemon/controller_linux.go index ef34359aeea..3576d7ace0a 100644 --- a/pkg/daemon/controller_linux.go +++ b/pkg/daemon/controller_linux.go @@ -573,8 +573,11 @@ func (c *Controller) handlePod(key string) error { } // set default nic bandwidth + // ovsIngress and ovsEgress are derived from the pod's egress and ingress rate annotations respectively, their roles are reversed from the OVS interface perspective. ifaceID := ovs.PodNameToPortName(podName, pod.Namespace, util.OvnProvider) - err = ovs.SetInterfaceBandwidth(podName, pod.Namespace, ifaceID, pod.Annotations[util.EgressRateAnnotation], pod.Annotations[util.IngressRateAnnotation]) + ovsIngress := pod.Annotations[util.EgressRateAnnotation] + ovsEgress := pod.Annotations[util.IngressRateAnnotation] + err = ovs.SetInterfaceBandwidth(podName, pod.Namespace, ifaceID, ovsIngress, ovsEgress) if err != nil { klog.Error(err) return err