• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kubeovn / kube-ovn / 20984576930

14 Jan 2026 06:20AM UTC coverage: 22.732% (-0.002%) from 22.734%
20984576930

Pull #6159

github

changluyi
add some debug

Signed-off-by: clyi <clyi@alauda.io>
Pull Request #6159: add metallb underlay v6 dualcase

0 of 9 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

12184 of 53599 relevant lines covered (22.73%)

0.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pkg/daemon/flow_rules_linux.go
1
package daemon
2

3
import (
4
        "errors"
5
        "fmt"
6
        "strings"
7

8
        "k8s.io/klog/v2"
9

10
        kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
11
        "github.com/kubeovn/kube-ovn/pkg/util"
12
)
13

14
const flowKindUnderlayService = "usvc"
15

16
func (c *Controller) AddOrUpdateUnderlaySubnetSvcLocalFlowCache(serviceIP string, port uint16, protocol, dstMac, underlayNic, bridgeName string) error {
×
17
        inPort, err := c.getPortID(bridgeName, underlayNic)
×
18
        if err != nil {
×
19
                return err
×
20
        }
×
21

22
        outPort, err := c.getPortID(bridgeName, "patch-localnet.")
×
23
        if err != nil {
×
24
                return err
×
25
        }
×
26

27
        isIPv6 := util.CheckProtocol(serviceIP) == kubeovnv1.ProtocolIPv6
×
28
        protoStr := ""
×
29
        switch strings.ToUpper(protocol) {
×
30
        case "TCP":
×
31
                protoStr = "tcp"
×
32
                if isIPv6 {
×
33
                        protoStr = "tcp6"
×
34
                }
×
35
        case "UDP":
×
36
                protoStr = "udp"
×
37
                if isIPv6 {
×
38
                        protoStr = "udp6"
×
39
                }
×
40
        default:
×
41
                return fmt.Errorf("unsupported protocol %s", protocol)
×
42
        }
43

44
        cookie := fmt.Sprintf("0x%x", util.UnderlaySvcLocalOpenFlowCookieV4)
×
45
        nwDst := "nw_dst"
×
NEW
46
        flowDstIP := serviceIP
×
47
        if isIPv6 {
×
48
                cookie = fmt.Sprintf("0x%x", util.UnderlaySvcLocalOpenFlowCookieV6)
×
49
                nwDst = "ipv6_dst"
×
NEW
50
                flowDstIP = fmt.Sprintf("[%s]", serviceIP)
×
UNCOV
51
        }
×
52

53
        flow := fmt.Sprintf("cookie=%s,priority=%d,in_port=%d,%s,%s=%s,tp_dst=%d "+
×
54
                "actions=mod_dl_dst:%s,output:%d",
×
NEW
55
                cookie, util.UnderlaySvcLocalOpenFlowPriority, inPort, protoStr, nwDst, flowDstIP, port, dstMac, outPort)
×
56

×
57
        key := buildFlowKey(flowKindUnderlayService, serviceIP, port, protocol, "")
×
58
        c.setFlowCache(c.flowCache, bridgeName, key, []string{flow})
×
59

×
60
        klog.V(5).Infof("updated underlay flow cache for service %s", key)
×
61
        c.requestFlowSync()
×
62
        return nil
×
63
}
64

65
func (c *Controller) deleteUnderlaySubnetSvcLocalFlowCache(bridgeName, serviceIP string, port uint16, protocol string) {
×
66
        key := buildFlowKey(flowKindUnderlayService, serviceIP, port, protocol, "")
×
67

×
68
        c.deleteFlowCache(c.flowCache, bridgeName, key)
×
69

×
70
        klog.V(5).Infof("deleted underlay flow cache for service %s", key)
×
71
        c.requestFlowSync()
×
72
}
×
73

74
func buildFlowKey(kind, ip string, port uint16, protocol, extra string) string {
×
75
        if extra == "" {
×
76
                return fmt.Sprintf("%s-%s-%s-%d", kind, ip, protocol, port)
×
77
        }
×
78
        return fmt.Sprintf("%s-%s-%s-%d-%s", kind, ip, protocol, port, extra)
×
79
}
80

81
func (c *Controller) getPortID(bridgeName, portName string) (int, error) {
×
82
        if c.ovsClient == nil {
×
83
                return 0, errors.New("ovs client not initialized")
×
84
        }
×
85

86
        portInfo, err := c.ovsClient.OpenFlow.DumpPort(bridgeName, portName)
×
87
        if err != nil {
×
88
                return 0, fmt.Errorf("failed to dump port %s on bridge %s: %w", portName, bridgeName, err)
×
89
        }
×
90
        return portInfo.PortID, nil
×
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc