diff options
author | 2024-11-27 08:23:43 +0100 | |
---|---|---|
committer | 2024-11-27 16:51:38 +0000 | |
commit | f9f5717633c9c72b8146c7472070675d3fcbe685 (patch) | |
tree | dcf146fa86b92a603e13c9332c3a165d6b641e04 /extras | |
parent | 7d469364c5d9f7dc1b42143a6c6a4a7aafe89b34 (diff) |
hs-test: don't use reserved UDP ports for binding
Type: test
Change-Id: Ief0d238bbbf533779618b971f01099aa113c1c08
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/hs-test/infra/hst_suite.go | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index d6b4006a4e4..0513e86e47b 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -12,6 +12,7 @@ import ( "os/exec" "path/filepath" "runtime" + "slices" "strconv" "strings" "time" @@ -75,6 +76,29 @@ var Colors = colors{ 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 @@ func (s *HstSuite) GetCurrentSuiteName() string { 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 } /* |