[VOL-5402]-VGC all fixes till date from jan 2024
Change-Id: I2857e0ef9b1829a28c6e3ad04da96b826cb900b6
Signed-off-by: Akash Soni <akash.soni@radisys.com>
diff --git a/internal/pkg/util/utils.go b/internal/pkg/util/utils.go
index 6157413..36aab0b 100644
--- a/internal/pkg/util/utils.go
+++ b/internal/pkg/util/utils.go
@@ -18,6 +18,7 @@
import (
"encoding/binary"
"net"
+ "strconv"
"strings"
"voltha-go-controller/internal/pkg/of"
@@ -132,6 +133,34 @@
return ipList
}
+// GetUniFromMetadata returns uni port from write metadata of DS flows.
+func GetUniFromMetadata(metadata uint64) uint32 {
+ return uint32(metadata & 0xFFFFFFFF)
+}
+
+// GetUniFromDSDhcpFlow returns uni port from the flow cookie
+func GetUniFromDSDhcpFlow(cookie uint64) uint32 {
+ uniport := uint32(cookie >> 16)
+ uniport = uniport & 0xFFFFFFFF
+ return uniport
+}
+
+// GetUniPortFromFlow returns uni port from the flow data
+func GetUniPortFromFlow(nniPort string, flow *of.VoltSubFlow) uint32 {
+ var portNo uint32
+ if nniPort == strconv.Itoa(int(flow.Match.InPort)) {
+ if of.IPProtocolUDP == flow.Match.L4Protocol {
+ // For DHCP DS flow, uniport is not part of metadata. Hence retrieve it from cookie
+ portNo = GetUniFromDSDhcpFlow(flow.Cookie)
+ } else {
+ portNo = GetUniFromMetadata(flow.Action.Metadata)
+ }
+ } else {
+ portNo = flow.Match.InPort
+ }
+ return portNo
+}
+
// MacAddrsMatch for comparison of MAC addresses and return true if MAC addresses matches
func MacAddrsMatch(addr1 net.HardwareAddr, addr2 net.HardwareAddr) bool {
if len(addr1) != len(addr2) {