hs-test: don't use reserved UDP ports for binding

Type: test

Change-Id: Ief0d238bbbf533779618b971f01099aa113c1c08
Signed-off-by: Adrian Villin <avillin@cisco.com>
diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go
index d6b4006..0513e86 100644
--- a/extras/hs-test/infra/hst_suite.go
+++ b/extras/hs-test/infra/hst_suite.go
@@ -12,6 +12,7 @@
 	"os/exec"
 	"path/filepath"
 	"runtime"
+	"slices"
 	"strconv"
 	"strings"
 	"time"
@@ -75,6 +76,29 @@
 	rst: "\033[0m",
 }
 
+// ../../src/vnet/udp/udp_local.h:foreach_udp4_dst_port
+var reservedPorts = []string{
+	"53",
+	"67",
+	"68",
+	"500",
+	"2152",
+	"3784",
+	"3785",
+	"4341",
+	"4342",
+	"4500",
+	"4739",
+	"4784",
+	"4789",
+	"4789",
+	"48879",
+	"4790",
+	"6633",
+	"6081",
+	"53053",
+}
+
 // used for colorful ReportEntry
 type StringerStruct struct {
 	Label string
@@ -658,13 +682,23 @@
 	return CurrentSpecReport().ContainerHierarchyTexts[0]
 }
 
-// Returns last 3 digits of PID + Ginkgo process index as the 4th digit
+// Returns last 3 digits of PID + Ginkgo process index as the 4th digit. If the port is in the 'reservedPorts' slice,
+// increment port number by ten and check again.
 func (s *HstSuite) GetPortFromPpid() string {
 	port := s.Ppid
+	var err error
+	var portInt int
 	for len(port) < 3 {
 		port += "0"
 	}
-	return port[len(port)-3:] + s.ProcessIndex
+	port = port[len(port)-3:] + s.ProcessIndex
+	for slices.Contains(reservedPorts, port) {
+		portInt, err = strconv.Atoi(port)
+		s.AssertNil(err)
+		portInt += 10
+		port = fmt.Sprintf("%d", portInt)
+	}
+	return port
 }
 
 /*