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

kubeovn / kube-ovn / 21031892891

15 Jan 2026 12:49PM UTC coverage: 22.711% (-0.02%) from 22.73%
21031892891

Pull #6159

github

changluyi
fix enable u2o may cause metallb underlay err

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

0 of 62 new or added lines in 3 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

12193 of 53688 relevant lines covered (22.71%)

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 {
×
NEW
24
                klog.V(5).Infof("patch-localnet port not found on bridge %s, skipping underlay service flow for %s:%d (no pods on this node yet)", bridgeName, serviceIP, port)
×
NEW
25
                return nil
×
UNCOV
26
        }
×
27

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

45
        cookie := fmt.Sprintf("0x%x", util.UnderlaySvcLocalOpenFlowCookieV4)
×
46
        nwDst := "nw_dst"
×
47
        if isIPv6 {
×
48
                cookie = fmt.Sprintf("0x%x", util.UnderlaySvcLocalOpenFlowCookieV6)
×
49
                nwDst = "ipv6_dst"
×
50
        }
×
51

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

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

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

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

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

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

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

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

85
        portInfo, err := c.ovsClient.OpenFlow.DumpPort(bridgeName, portName)
×
86
        if err != nil {
×
87
                return 0, fmt.Errorf("failed to dump port %s on bridge %s: %w", portName, bridgeName, err)
×
88
        }
×
89
        return portInfo.PortID, nil
×
90
}
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