Skip to content

Commit 78bca6a

Browse files
vasremdpf-release
authored andcommitted
fix: adjust hash function for ofport_request to use uint16
* fix: adjust hash function for ofport_request to use uint16 * fix: adjust hash function for ofport_request to use uint16 This commit adjusts the hash function of ofport_request to use unit16 to decrease the chance of collision. See comment code for more info. Signed-off-by: Vasilis Remmas <[email protected]> (cherry picked from commit 590a0db5e33dcfbaf504c59769d13dab2745f24c) ee7e4e38 fix: adjust hash function for ofport_request to use uint16 Co-authored-by: Vasilis Remmas <[email protected]> Based on release-v25.7@3b0d4f2b35b3d55a252c7f38afc253984d9e2432
1 parent 3f199ce commit 78bca6a

File tree

1 file changed

+11
-2
lines changed
  • third_party/forked/ovs-cni/pkg/ovsdb

1 file changed

+11
-2
lines changed

third_party/forked/ovs-cni/pkg/ovsdb/ovsdb.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ const (
7272
MirrorConsumer
7373
)
7474

75-
func hash(s string) uint8 {
75+
func hash(s string) uint16 {
7676
h := fnv.New32a()
7777
h.Write([]byte(s))
78-
return uint8(h.Sum32())
78+
return uint16(h.Sum32())
7979
}
8080

8181
// ConnectToOvsDb connect to ovsdb
@@ -1081,6 +1081,15 @@ func createInterfaceOperation(intfName string, ofportRequest uint, ovnPortName s
10811081
if ofportRequest != 0 {
10821082
intf["ofport_request"] = ofportRequest
10831083
} else {
1084+
// Some interfaces are added in the br-sfc without ofport_request. In particular, this is the case for p0 and p1.
1085+
// When ofport_request is specified, then this interface might temporarily evict another interface that has this
1086+
// ofport, if the latter doesn't specify ofport_request. In particular, this is the case for p0 and p1. Evicting
1087+
// those interface leads to downtime in traffic. The hash function returns uint16 to decrease the chance of
1088+
// hitting that issue, but it's not guaranteed that we won't hit that issue.
1089+
// TODO: Consider adding ofport_request when adding DPUServiceInterface of type physical to ensure those ports
1090+
// are not evicted. This may lead to issues with collisions and errors when trying to bring up HBN, but it's not
1091+
// worse than what we have today, as it's going to be visible why this issue occurs. Additional logic in the hash
1092+
// function can be added to ensure no collisions.
10841093
intf["ofport_request"] = hash(intfName)
10851094
}
10861095

0 commit comments

Comments
 (0)