Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 1 | package hst |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 2 | |
| 3 | import ( |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 4 | "context" |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 5 | "fmt" |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 6 | "go.fd.io/govpp/binapi/ethernet_types" |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 7 | "io" |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 8 | "net" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 9 | "os" |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 10 | "os/exec" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 11 | "os/signal" |
Filip Tehlar | 543cd57 | 2023-06-27 10:01:37 +0200 | [diff] [blame] | 12 | "strconv" |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 13 | "strings" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 14 | "syscall" |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 15 | "time" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 16 | |
Filip Tehlar | 9abba11 | 2023-03-07 10:13:19 +0100 | [diff] [blame] | 17 | "github.com/edwarnicke/exechelper" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 18 | . "github.com/onsi/ginkgo/v2" |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 19 | "github.com/sirupsen/logrus" |
Filip Tehlar | 9abba11 | 2023-03-07 10:13:19 +0100 | [diff] [blame] | 20 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 21 | "go.fd.io/govpp" |
| 22 | "go.fd.io/govpp/api" |
| 23 | "go.fd.io/govpp/binapi/af_packet" |
| 24 | interfaces "go.fd.io/govpp/binapi/interface" |
| 25 | "go.fd.io/govpp/binapi/interface_types" |
| 26 | "go.fd.io/govpp/binapi/session" |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 27 | "go.fd.io/govpp/binapi/tapv2" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 28 | "go.fd.io/govpp/core" |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 29 | ) |
| 30 | |
| 31 | const vppConfigTemplate = `unix { |
| 32 | nodaemon |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 33 | log %[1]s%[4]s |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 34 | full-coredump |
| 35 | cli-listen %[1]s%[2]s |
| 36 | runtime-dir %[1]s/var/run |
| 37 | gid vpp |
| 38 | } |
| 39 | |
| 40 | api-trace { |
| 41 | on |
| 42 | } |
| 43 | |
| 44 | api-segment { |
| 45 | gid vpp |
| 46 | } |
| 47 | |
| 48 | socksvr { |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 49 | socket-name %[1]s%[3]s |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | statseg { |
| 53 | socket-name %[1]s/var/run/vpp/stats.sock |
| 54 | } |
| 55 | |
| 56 | plugins { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 57 | plugin default { disable } |
| 58 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 59 | plugin unittest_plugin.so { enable } |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 60 | plugin quic_plugin.so { enable } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 61 | plugin af_packet_plugin.so { enable } |
| 62 | plugin hs_apps_plugin.so { enable } |
| 63 | plugin http_plugin.so { enable } |
Filip Tehlar | cc1475c | 2023-11-29 12:59:05 +0100 | [diff] [blame] | 64 | plugin http_static_plugin.so { enable } |
| 65 | plugin prom_plugin.so { enable } |
Filip Tehlar | 3336eef | 2023-11-29 07:40:18 +0100 | [diff] [blame] | 66 | plugin tlsopenssl_plugin.so { enable } |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 67 | plugin ping_plugin.so { enable } |
Matus Fabian | c899ab4 | 2024-04-22 13:42:00 +0200 | [diff] [blame] | 68 | plugin nsim_plugin.so { enable } |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 69 | plugin mactime_plugin.so { enable } |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 70 | } |
| 71 | |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 72 | logging { |
| 73 | default-log-level debug |
| 74 | default-syslog-log-level debug |
| 75 | } |
| 76 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 77 | ` |
| 78 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 79 | const ( |
| 80 | defaultCliSocketFilePath = "/var/run/vpp/cli.sock" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 81 | defaultApiSocketFilePath = "/var/run/vpp/api.sock" |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 82 | defaultLogFilePath = "/var/log/vpp/vpp.log" |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 83 | ) |
| 84 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 85 | type VppInstance struct { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 86 | Container *Container |
| 87 | AdditionalConfig []Stanza |
| 88 | Connection *core.Connection |
| 89 | ApiStream api.Stream |
| 90 | Cpus []int |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 91 | } |
| 92 | |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 93 | func (vpp *VppInstance) getSuite() *HstSuite { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 94 | return vpp.Container.Suite |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 95 | } |
| 96 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 97 | func (vpp *VppInstance) getCliSocket() string { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 98 | return fmt.Sprintf("%s%s", vpp.Container.GetContainerWorkDir(), defaultCliSocketFilePath) |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 99 | } |
| 100 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 101 | func (vpp *VppInstance) getRunDir() string { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 102 | return vpp.Container.GetContainerWorkDir() + "/var/run/vpp" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | func (vpp *VppInstance) getLogDir() string { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 106 | return vpp.Container.GetContainerWorkDir() + "/var/log/vpp" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | func (vpp *VppInstance) getEtcDir() string { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 110 | return vpp.Container.GetContainerWorkDir() + "/etc/vpp" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 111 | } |
| 112 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 113 | func (vpp *VppInstance) Start() error { |
Adrian Villin | 93974e2 | 2024-05-30 06:10:59 -0400 | [diff] [blame] | 114 | maxReconnectAttempts := 3 |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 115 | // Replace default logger in govpp with our own |
| 116 | govppLogger := logrus.New() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 117 | govppLogger.SetOutput(io.MultiWriter(vpp.getSuite().Logger.Writer(), GinkgoWriter)) |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 118 | core.SetLogger(govppLogger) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 119 | // Create folders |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 120 | containerWorkDir := vpp.Container.GetContainerWorkDir() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 121 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 122 | vpp.Container.Exec("mkdir --mode=0700 -p " + vpp.getRunDir()) |
| 123 | vpp.Container.Exec("mkdir --mode=0700 -p " + vpp.getLogDir()) |
| 124 | vpp.Container.Exec("mkdir --mode=0700 -p " + vpp.getEtcDir()) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 125 | |
| 126 | // Create startup.conf inside the container |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 127 | configContent := fmt.Sprintf( |
Maros Ondrejicka | 300f70d | 2023-02-21 10:53:20 +0100 | [diff] [blame] | 128 | vppConfigTemplate, |
| 129 | containerWorkDir, |
| 130 | defaultCliSocketFilePath, |
| 131 | defaultApiSocketFilePath, |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 132 | defaultLogFilePath, |
Maros Ondrejicka | 300f70d | 2023-02-21 10:53:20 +0100 | [diff] [blame] | 133 | ) |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 134 | configContent += vpp.generateCpuConfig() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 135 | for _, c := range vpp.AdditionalConfig { |
| 136 | configContent += c.ToString() |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 137 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 138 | startupFileName := vpp.getEtcDir() + "/startup.conf" |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 139 | vpp.Container.CreateFile(startupFileName, configContent) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 140 | |
Filip Tehlar | 1a66150 | 2023-03-08 11:55:50 +0100 | [diff] [blame] | 141 | // create wrapper script for vppctl with proper CLI socket path |
| 142 | cliContent := "#!/usr/bin/bash\nvppctl -s " + vpp.getRunDir() + "/cli.sock" |
| 143 | vppcliFileName := "/usr/bin/vppcli" |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 144 | vpp.Container.CreateFile(vppcliFileName, cliContent) |
| 145 | vpp.Container.Exec("chmod 0755 " + vppcliFileName) |
Filip Tehlar | 1a66150 | 2023-03-08 11:55:50 +0100 | [diff] [blame] | 146 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 147 | vpp.getSuite().Log("starting vpp") |
| 148 | if *IsVppDebug { |
Adrian Villin | 93974e2 | 2024-05-30 06:10:59 -0400 | [diff] [blame] | 149 | // default = 3; VPP will timeout while debugging if there are not enough attempts |
| 150 | maxReconnectAttempts = 5000 |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 151 | sig := make(chan os.Signal, 1) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 152 | signal.Notify(sig, syscall.SIGQUIT) |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 153 | cont := make(chan bool, 1) |
| 154 | go func() { |
Filip Tehlar | 9abba11 | 2023-03-07 10:13:19 +0100 | [diff] [blame] | 155 | <-sig |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 156 | cont <- true |
| 157 | }() |
| 158 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 159 | vpp.Container.ExecServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"") |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 160 | fmt.Println("run following command in different terminal:") |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 161 | fmt.Println("docker exec -it " + vpp.Container.Name + " gdb -ex \"attach $(docker exec " + vpp.Container.Name + " pidof vpp)\"") |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 162 | fmt.Println("Afterwards press CTRL+\\ to continue") |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 163 | <-cont |
| 164 | fmt.Println("continuing...") |
| 165 | } else { |
| 166 | // Start VPP |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 167 | vpp.Container.ExecServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"") |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 168 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 169 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 170 | vpp.getSuite().Log("connecting to vpp") |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 171 | // Connect to VPP and store the connection |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 172 | sockAddress := vpp.Container.GetHostWorkDir() + defaultApiSocketFilePath |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 173 | conn, connEv, err := govpp.AsyncConnect( |
| 174 | sockAddress, |
Adrian Villin | 93974e2 | 2024-05-30 06:10:59 -0400 | [diff] [blame] | 175 | maxReconnectAttempts, |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 176 | core.DefaultReconnectInterval) |
| 177 | if err != nil { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 178 | vpp.getSuite().Log("async connect error: " + fmt.Sprint(err)) |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 179 | return err |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 180 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 181 | vpp.Connection = conn |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 182 | |
| 183 | // ... wait for Connected event |
| 184 | e := <-connEv |
| 185 | if e.State != core.Connected { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 186 | vpp.getSuite().Log("connecting to VPP failed: " + fmt.Sprint(e.Error)) |
Hadi Rayan Al-Sandid | 0eccf45 | 2024-06-24 10:48:54 +0200 | [diff] [blame] | 187 | return e.Error |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 188 | } |
| 189 | |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 190 | ch, err := conn.NewStream( |
| 191 | context.Background(), |
| 192 | core.WithRequestSize(50), |
| 193 | core.WithReplySize(50), |
Adrian Villin | 93974e2 | 2024-05-30 06:10:59 -0400 | [diff] [blame] | 194 | core.WithReplyTimeout(time.Second*5)) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 195 | if err != nil { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 196 | vpp.getSuite().Log("creating stream failed: " + fmt.Sprint(err)) |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 197 | return err |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 198 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 199 | vpp.ApiStream = ch |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 200 | |
| 201 | return nil |
| 202 | } |
| 203 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 204 | func (vpp *VppInstance) Vppctl(command string, arguments ...any) string { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 205 | vppCliCommand := fmt.Sprintf(command, arguments...) |
| 206 | containerExecCommand := fmt.Sprintf("docker exec --detach=false %[1]s vppctl -s %[2]s %[3]s", |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 207 | vpp.Container.Name, vpp.getCliSocket(), vppCliCommand) |
| 208 | vpp.getSuite().Log(containerExecCommand) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 209 | output, err := exechelper.CombinedOutput(containerExecCommand) |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 210 | vpp.getSuite().AssertNil(err) |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 211 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 212 | return string(output) |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 213 | } |
| 214 | |
Filip Tehlar | 543cd57 | 2023-06-27 10:01:37 +0200 | [diff] [blame] | 215 | func (vpp *VppInstance) GetSessionStat(stat string) int { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 216 | o := vpp.Vppctl("show session stats") |
| 217 | vpp.getSuite().Log(o) |
Filip Tehlar | 543cd57 | 2023-06-27 10:01:37 +0200 | [diff] [blame] | 218 | for _, line := range strings.Split(o, "\n") { |
| 219 | if strings.Contains(line, stat) { |
| 220 | tokens := strings.Split(strings.TrimSpace(line), " ") |
| 221 | val, err := strconv.Atoi(tokens[0]) |
| 222 | if err != nil { |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 223 | Fail("failed to parse stat value %s" + fmt.Sprint(err)) |
Filip Tehlar | 543cd57 | 2023-06-27 10:01:37 +0200 | [diff] [blame] | 224 | return 0 |
| 225 | } |
| 226 | return val |
| 227 | } |
| 228 | } |
| 229 | return 0 |
| 230 | } |
| 231 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 232 | func (vpp *VppInstance) WaitForApp(appName string, timeout int) { |
| 233 | vpp.getSuite().Log("waiting for app " + appName) |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 234 | for i := 0; i < timeout; i++ { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 235 | o := vpp.Vppctl("show app") |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 236 | if strings.Contains(o, appName) { |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 237 | return |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 238 | } |
| 239 | time.Sleep(1 * time.Second) |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 240 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 241 | vpp.getSuite().AssertNil(1, "Timeout while waiting for app '%s'", appName) |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 242 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 243 | |
| 244 | func (vpp *VppInstance) createAfPacket( |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 245 | veth *NetInterface, |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 246 | ) (interface_types.InterfaceIndex, error) { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 247 | createReq := &af_packet.AfPacketCreateV3{ |
| 248 | Mode: 1, |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 249 | UseRandomHwAddr: true, |
| 250 | HostIfName: veth.Name(), |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 251 | Flags: af_packet.AfPacketFlags(11), |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 252 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 253 | if veth.HwAddress != (MacAddress{}) { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 254 | createReq.UseRandomHwAddr = false |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 255 | createReq.HwAddr = veth.HwAddress |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 256 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 257 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 258 | vpp.getSuite().Log("create af-packet interface " + veth.Name()) |
| 259 | if err := vpp.ApiStream.SendMsg(createReq); err != nil { |
| 260 | vpp.getSuite().HstFail() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 261 | return 0, err |
| 262 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 263 | replymsg, err := vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 264 | if err != nil { |
| 265 | return 0, err |
| 266 | } |
| 267 | reply := replymsg.(*af_packet.AfPacketCreateV3Reply) |
| 268 | err = api.RetvalToVPPApiError(reply.Retval) |
| 269 | if err != nil { |
| 270 | return 0, err |
| 271 | } |
| 272 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 273 | veth.Index = reply.SwIfIndex |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 274 | |
| 275 | // Set to up |
| 276 | upReq := &interfaces.SwInterfaceSetFlags{ |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 277 | SwIfIndex: veth.Index, |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 278 | Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, |
| 279 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 280 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 281 | vpp.getSuite().Log("set af-packet interface " + veth.Name() + " up") |
| 282 | if err := vpp.ApiStream.SendMsg(upReq); err != nil { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 283 | return 0, err |
| 284 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 285 | replymsg, err = vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 286 | if err != nil { |
| 287 | return 0, err |
| 288 | } |
| 289 | reply2 := replymsg.(*interfaces.SwInterfaceSetFlagsReply) |
| 290 | if err = api.RetvalToVPPApiError(reply2.Retval); err != nil { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 291 | return 0, err |
| 292 | } |
| 293 | |
| 294 | // Add address |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 295 | if veth.AddressWithPrefix() == (AddressWithPrefix{}) { |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 296 | var err error |
| 297 | var ip4Address string |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 298 | if ip4Address, err = veth.Ip4AddrAllocator.NewIp4InterfaceAddress(veth.Peer.NetworkNumber); err == nil { |
| 299 | veth.Ip4Address = ip4Address |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 300 | } else { |
| 301 | return 0, err |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 302 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 303 | } |
| 304 | addressReq := &interfaces.SwInterfaceAddDelAddress{ |
| 305 | IsAdd: true, |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 306 | SwIfIndex: veth.Index, |
| 307 | Prefix: veth.AddressWithPrefix(), |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 308 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 309 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 310 | vpp.getSuite().Log("af-packet interface " + veth.Name() + " add address " + veth.Ip4Address) |
| 311 | if err := vpp.ApiStream.SendMsg(addressReq); err != nil { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 312 | return 0, err |
| 313 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 314 | replymsg, err = vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 315 | if err != nil { |
| 316 | return 0, err |
| 317 | } |
| 318 | reply3 := replymsg.(*interfaces.SwInterfaceAddDelAddressReply) |
| 319 | err = api.RetvalToVPPApiError(reply3.Retval) |
| 320 | if err != nil { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 321 | return 0, err |
| 322 | } |
| 323 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 324 | return veth.Index, nil |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | func (vpp *VppInstance) addAppNamespace( |
| 328 | secret uint64, |
| 329 | ifx interface_types.InterfaceIndex, |
| 330 | namespaceId string, |
| 331 | ) error { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 332 | req := &session.AppNamespaceAddDelV4{ |
| 333 | IsAdd: true, |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 334 | Secret: secret, |
| 335 | SwIfIndex: ifx, |
| 336 | NamespaceID: namespaceId, |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 337 | SockName: defaultApiSocketFilePath, |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 338 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 339 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 340 | vpp.getSuite().Log("add app namespace " + namespaceId) |
| 341 | if err := vpp.ApiStream.SendMsg(req); err != nil { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 342 | return err |
| 343 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 344 | replymsg, err := vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 345 | if err != nil { |
| 346 | return err |
| 347 | } |
| 348 | reply := replymsg.(*session.AppNamespaceAddDelV4Reply) |
| 349 | if err = api.RetvalToVPPApiError(reply.Retval); err != nil { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 350 | return err |
| 351 | } |
| 352 | |
| 353 | sessionReq := &session.SessionEnableDisable{ |
| 354 | IsEnable: true, |
| 355 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 356 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 357 | vpp.getSuite().Log("enable app namespace " + namespaceId) |
| 358 | if err := vpp.ApiStream.SendMsg(sessionReq); err != nil { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 359 | return err |
| 360 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 361 | replymsg, err = vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 362 | if err != nil { |
| 363 | return err |
| 364 | } |
| 365 | reply2 := replymsg.(*session.SessionEnableDisableReply) |
| 366 | if err = api.RetvalToVPPApiError(reply2.Retval); err != nil { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 367 | return err |
| 368 | } |
| 369 | |
| 370 | return nil |
| 371 | } |
| 372 | |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 373 | func (vpp *VppInstance) createTap( |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 374 | tap *NetInterface, |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 375 | tapId ...uint32, |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 376 | ) error { |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 377 | var id uint32 = 1 |
| 378 | if len(tapId) > 0 { |
| 379 | id = tapId[0] |
| 380 | } |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 381 | createTapReq := &tapv2.TapCreateV3{ |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 382 | ID: id, |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 383 | HostIfNameSet: true, |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 384 | HostIfName: tap.Name(), |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 385 | HostIP4PrefixSet: true, |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 386 | HostIP4Prefix: tap.Ip4AddressWithPrefix(), |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 387 | } |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 388 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 389 | vpp.getSuite().Log("create tap interface " + tap.Name()) |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 390 | // Create tap interface |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 391 | if err := vpp.ApiStream.SendMsg(createTapReq); err != nil { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 392 | return err |
| 393 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 394 | replymsg, err := vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 395 | if err != nil { |
| 396 | return err |
| 397 | } |
| 398 | reply := replymsg.(*tapv2.TapCreateV3Reply) |
| 399 | if err = api.RetvalToVPPApiError(reply.Retval); err != nil { |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 400 | return err |
| 401 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 402 | tap.Peer.Index = reply.SwIfIndex |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 403 | |
| 404 | // Get name and mac |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 405 | if err := vpp.ApiStream.SendMsg(&interfaces.SwInterfaceDump{ |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 406 | SwIfIndex: reply.SwIfIndex, |
| 407 | }); err != nil { |
| 408 | return err |
| 409 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 410 | replymsg, err = vpp.ApiStream.RecvMsg() |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 411 | if err != nil { |
| 412 | return err |
| 413 | } |
| 414 | ifDetails := replymsg.(*interfaces.SwInterfaceDetails) |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 415 | tap.Peer.name = ifDetails.InterfaceName |
| 416 | tap.Peer.HwAddress = ifDetails.L2Address |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 417 | |
| 418 | // Add address |
| 419 | addAddressReq := &interfaces.SwInterfaceAddDelAddress{ |
| 420 | IsAdd: true, |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 421 | SwIfIndex: reply.SwIfIndex, |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 422 | Prefix: tap.Peer.AddressWithPrefix(), |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 423 | } |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 424 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 425 | vpp.getSuite().Log("tap interface " + tap.Name() + " add address " + tap.Peer.Ip4Address) |
| 426 | if err := vpp.ApiStream.SendMsg(addAddressReq); err != nil { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 427 | return err |
| 428 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 429 | replymsg, err = vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 430 | if err != nil { |
| 431 | return err |
| 432 | } |
| 433 | reply2 := replymsg.(*interfaces.SwInterfaceAddDelAddressReply) |
| 434 | if err = api.RetvalToVPPApiError(reply2.Retval); err != nil { |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 435 | return err |
| 436 | } |
| 437 | |
| 438 | // Set interface to up |
| 439 | upReq := &interfaces.SwInterfaceSetFlags{ |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 440 | SwIfIndex: reply.SwIfIndex, |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 441 | Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, |
| 442 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 443 | |
| 444 | vpp.getSuite().Log("set tap interface " + tap.Name() + " up") |
| 445 | if err := vpp.ApiStream.SendMsg(upReq); err != nil { |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 446 | return err |
| 447 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 448 | replymsg, err = vpp.ApiStream.RecvMsg() |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 449 | if err != nil { |
| 450 | return err |
| 451 | } |
| 452 | reply3 := replymsg.(*interfaces.SwInterfaceSetFlagsReply) |
| 453 | if err = api.RetvalToVPPApiError(reply3.Retval); err != nil { |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 454 | return err |
| 455 | } |
| 456 | |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 457 | // Get host mac |
| 458 | netIntf, err := net.InterfaceByName(tap.Name()) |
| 459 | if err == nil { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 460 | tap.HwAddress, _ = ethernet_types.ParseMacAddress(netIntf.HardwareAddr.String()) |
Matus Fabian | 82ad966 | 2024-06-04 19:00:00 +0200 | [diff] [blame] | 461 | } |
| 462 | |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 463 | return nil |
| 464 | } |
| 465 | |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 466 | func (vpp *VppInstance) saveLogs() { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 467 | logTarget := vpp.Container.getLogDirPath() + "vppinstance-" + vpp.Container.Name + ".log" |
| 468 | logSource := vpp.Container.GetHostWorkDir() + defaultLogFilePath |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 469 | cmd := exec.Command("cp", logSource, logTarget) |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 470 | vpp.getSuite().Log(cmd.String()) |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 471 | cmd.Run() |
| 472 | } |
| 473 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 474 | func (vpp *VppInstance) Disconnect() { |
| 475 | vpp.Connection.Disconnect() |
| 476 | vpp.ApiStream.Close() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 477 | } |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 478 | |
| 479 | func (vpp *VppInstance) generateCpuConfig() string { |
| 480 | var c Stanza |
| 481 | var s string |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 482 | if len(vpp.Cpus) < 1 { |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 483 | return "" |
| 484 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 485 | c.NewStanza("cpu"). |
| 486 | Append(fmt.Sprintf("main-core %d", vpp.Cpus[0])) |
| 487 | vpp.getSuite().Log(fmt.Sprintf("main-core %d", vpp.Cpus[0])) |
| 488 | workers := vpp.Cpus[1:] |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 489 | |
| 490 | if len(workers) > 0 { |
| 491 | for i := 0; i < len(workers); i++ { |
| 492 | if i != 0 { |
| 493 | s = s + ", " |
| 494 | } |
| 495 | s = s + fmt.Sprintf("%d", workers[i]) |
| 496 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 497 | c.Append(fmt.Sprintf("corelist-workers %s", s)) |
| 498 | vpp.getSuite().Log("corelist-workers " + s) |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 499 | } |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 500 | return c.Close().ToString() |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 501 | } |