Skip to content

Commit

Permalink
Increase code specification and readability in vxlan nic name and qos (
Browse files Browse the repository at this point in the history
…#4896)

* Increase code specification and readability in vxlan nic name and qos

---------

Signed-off-by: dolibali <[email protected]>
Co-authored-by: dolibali <[email protected]>
  • Loading branch information
dolibali and dolibali authored Jan 7, 2025
1 parent d66af7c commit 6044136
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
18 changes: 7 additions & 11 deletions cmd/daemon/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
5 changes: 4 additions & 1 deletion pkg/daemon/controller_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6044136

Please sign in to comment.