Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 4 | "fmt" |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 5 | "github.com/edwarnicke/exechelper" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 6 | "os" |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 7 | "os/exec" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 8 | "os/signal" |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 9 | "strings" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 10 | "syscall" |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 11 | "time" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 12 | |
| 13 | "go.fd.io/govpp" |
| 14 | "go.fd.io/govpp/api" |
| 15 | "go.fd.io/govpp/binapi/af_packet" |
| 16 | interfaces "go.fd.io/govpp/binapi/interface" |
| 17 | "go.fd.io/govpp/binapi/interface_types" |
| 18 | "go.fd.io/govpp/binapi/session" |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 19 | "go.fd.io/govpp/binapi/tapv2" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 20 | "go.fd.io/govpp/binapi/vpe" |
| 21 | "go.fd.io/govpp/core" |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 22 | ) |
| 23 | |
| 24 | const vppConfigTemplate = `unix { |
| 25 | nodaemon |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 26 | log %[1]s%[4]s |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 27 | full-coredump |
| 28 | cli-listen %[1]s%[2]s |
| 29 | runtime-dir %[1]s/var/run |
| 30 | gid vpp |
| 31 | } |
| 32 | |
| 33 | api-trace { |
| 34 | on |
| 35 | } |
| 36 | |
| 37 | api-segment { |
| 38 | gid vpp |
| 39 | } |
| 40 | |
| 41 | socksvr { |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 42 | socket-name %[1]s%[3]s |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | statseg { |
| 46 | socket-name %[1]s/var/run/vpp/stats.sock |
| 47 | } |
| 48 | |
| 49 | plugins { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 50 | plugin default { disable } |
| 51 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 52 | plugin unittest_plugin.so { enable } |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 53 | plugin quic_plugin.so { enable } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 54 | plugin af_packet_plugin.so { enable } |
| 55 | plugin hs_apps_plugin.so { enable } |
| 56 | plugin http_plugin.so { enable } |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 57 | } |
| 58 | |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 59 | logging { |
| 60 | default-log-level debug |
| 61 | default-syslog-log-level debug |
| 62 | } |
| 63 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 64 | ` |
| 65 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 66 | const ( |
| 67 | defaultCliSocketFilePath = "/var/run/vpp/cli.sock" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 68 | defaultApiSocketFilePath = "/var/run/vpp/api.sock" |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 69 | defaultLogFilePath = "/var/log/vpp/vpp.log" |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 70 | ) |
| 71 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 72 | type VppInstance struct { |
Maros Ondrejicka | 300f70d | 2023-02-21 10:53:20 +0100 | [diff] [blame] | 73 | container *Container |
| 74 | additionalConfig Stanza |
| 75 | connection *core.Connection |
| 76 | apiChannel api.Channel |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 77 | } |
| 78 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 79 | func (vpp *VppInstance) Suite() *HstSuite { |
| 80 | return vpp.container.suite |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 81 | } |
| 82 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 83 | func (vpp *VppInstance) getCliSocket() string { |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 84 | return fmt.Sprintf("%s%s", vpp.container.GetContainerWorkDir(), defaultCliSocketFilePath) |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 85 | } |
| 86 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 87 | func (vpp *VppInstance) getRunDir() string { |
| 88 | return vpp.container.GetContainerWorkDir() + "/var/run/vpp" |
| 89 | } |
| 90 | |
| 91 | func (vpp *VppInstance) getLogDir() string { |
| 92 | return vpp.container.GetContainerWorkDir() + "/var/log/vpp" |
| 93 | } |
| 94 | |
| 95 | func (vpp *VppInstance) getEtcDir() string { |
| 96 | return vpp.container.GetContainerWorkDir() + "/etc/vpp" |
| 97 | } |
| 98 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 99 | func (vpp *VppInstance) start() error { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 100 | // Create folders |
| 101 | containerWorkDir := vpp.container.GetContainerWorkDir() |
| 102 | |
| 103 | vpp.container.exec("mkdir --mode=0700 -p " + vpp.getRunDir()) |
| 104 | vpp.container.exec("mkdir --mode=0700 -p " + vpp.getLogDir()) |
| 105 | vpp.container.exec("mkdir --mode=0700 -p " + vpp.getEtcDir()) |
| 106 | |
| 107 | // Create startup.conf inside the container |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 108 | configContent := fmt.Sprintf( |
Maros Ondrejicka | 300f70d | 2023-02-21 10:53:20 +0100 | [diff] [blame] | 109 | vppConfigTemplate, |
| 110 | containerWorkDir, |
| 111 | defaultCliSocketFilePath, |
| 112 | defaultApiSocketFilePath, |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 113 | defaultLogFilePath, |
Maros Ondrejicka | 300f70d | 2023-02-21 10:53:20 +0100 | [diff] [blame] | 114 | ) |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 115 | configContent += vpp.additionalConfig.ToString() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 116 | startupFileName := vpp.getEtcDir() + "/startup.conf" |
| 117 | vpp.container.createFile(startupFileName, configContent) |
| 118 | |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 119 | if *IsVppDebug { |
| 120 | sig := make(chan os.Signal, 1) |
| 121 | signal.Notify(sig, syscall.SIGINT) |
| 122 | cont := make(chan bool, 1) |
| 123 | go func() { |
| 124 | sig := <-sig |
| 125 | fmt.Println(sig) |
| 126 | cont <- true |
| 127 | }() |
| 128 | |
| 129 | // Start VPP in GDB and wait for user to attach it |
| 130 | vpp.container.execServer("su -c \"gdb -ex run --args vpp -c " + startupFileName + " &> /proc/1/fd/1\"") |
| 131 | fmt.Println("run following command in different terminal:") |
| 132 | fmt.Println("docker exec -it " + vpp.container.name + " gdb -ex \"attach $(docker exec " + vpp.container.name + " pidof gdb)\"") |
| 133 | fmt.Println("Afterwards press CTRL+C to continue") |
| 134 | <-cont |
| 135 | fmt.Println("continuing...") |
| 136 | } else { |
| 137 | // Start VPP |
| 138 | vpp.container.execServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"") |
| 139 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 140 | |
| 141 | // Connect to VPP and store the connection |
| 142 | sockAddress := vpp.container.GetHostWorkDir() + defaultApiSocketFilePath |
| 143 | conn, connEv, err := govpp.AsyncConnect( |
| 144 | sockAddress, |
| 145 | core.DefaultMaxReconnectAttempts, |
| 146 | core.DefaultReconnectInterval) |
| 147 | if err != nil { |
| 148 | fmt.Println("async connect error: ", err) |
| 149 | } |
| 150 | vpp.connection = conn |
| 151 | |
| 152 | // ... wait for Connected event |
| 153 | e := <-connEv |
| 154 | if e.State != core.Connected { |
| 155 | fmt.Println("connecting to VPP failed: ", e.Error) |
| 156 | } |
| 157 | |
| 158 | // ... check compatibility of used messages |
| 159 | ch, err := conn.NewAPIChannel() |
| 160 | if err != nil { |
| 161 | fmt.Println("creating channel failed: ", err) |
| 162 | } |
| 163 | if err := ch.CheckCompatiblity(vpe.AllMessages()...); err != nil { |
| 164 | fmt.Println("compatibility error: ", err) |
| 165 | } |
| 166 | if err := ch.CheckCompatiblity(interfaces.AllMessages()...); err != nil { |
| 167 | fmt.Println("compatibility error: ", err) |
| 168 | } |
| 169 | vpp.apiChannel = ch |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 170 | |
| 171 | return nil |
| 172 | } |
| 173 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 174 | func (vpp *VppInstance) vppctl(command string, arguments ...any) string { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 175 | vppCliCommand := fmt.Sprintf(command, arguments...) |
| 176 | containerExecCommand := fmt.Sprintf("docker exec --detach=false %[1]s vppctl -s %[2]s %[3]s", |
| 177 | vpp.container.name, vpp.getCliSocket(), vppCliCommand) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 178 | vpp.Suite().log(containerExecCommand) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 179 | output, err := exechelper.CombinedOutput(containerExecCommand) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 180 | vpp.Suite().assertNil(err) |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 181 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 182 | return string(output) |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 183 | } |
| 184 | |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 185 | func (vpp *VppInstance) waitForApp(appName string, timeout int) { |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 186 | for i := 0; i < timeout; i++ { |
| 187 | o := vpp.vppctl("show app") |
| 188 | if strings.Contains(o, appName) { |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 189 | return |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 190 | } |
| 191 | time.Sleep(1 * time.Second) |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 192 | } |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 193 | vpp.Suite().assertNil(1, "Timeout while waiting for app '%s'", appName) |
| 194 | return |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 195 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 196 | |
| 197 | func (vpp *VppInstance) createAfPacket( |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 198 | veth *NetInterface, |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 199 | ) (interface_types.InterfaceIndex, error) { |
| 200 | createReq := &af_packet.AfPacketCreateV2{ |
| 201 | UseRandomHwAddr: true, |
| 202 | HostIfName: veth.Name(), |
| 203 | } |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 204 | if veth.HwAddress() != (MacAddress{}) { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 205 | createReq.UseRandomHwAddr = false |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 206 | createReq.HwAddr = veth.HwAddress() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 207 | } |
| 208 | createReply := &af_packet.AfPacketCreateV2Reply{} |
| 209 | |
| 210 | if err := vpp.apiChannel.SendRequest(createReq).ReceiveReply(createReply); err != nil { |
| 211 | return 0, err |
| 212 | } |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 213 | veth.SetIndex(createReply.SwIfIndex) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 214 | |
| 215 | // Set to up |
| 216 | upReq := &interfaces.SwInterfaceSetFlags{ |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 217 | SwIfIndex: veth.Index(), |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 218 | Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, |
| 219 | } |
| 220 | upReply := &interfaces.SwInterfaceSetFlagsReply{} |
| 221 | |
| 222 | if err := vpp.apiChannel.SendRequest(upReq).ReceiveReply(upReply); err != nil { |
| 223 | return 0, err |
| 224 | } |
| 225 | |
| 226 | // Add address |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 227 | if veth.AddressWithPrefix() == (AddressWithPrefix{}) { |
| 228 | var err error |
| 229 | var ip4Address string |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 230 | if ip4Address, err = veth.addresser.NewIp4Address(veth.Peer().networkNumber); err == nil { |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 231 | veth.SetAddress(ip4Address) |
| 232 | } else { |
| 233 | return 0, err |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 234 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 235 | } |
| 236 | addressReq := &interfaces.SwInterfaceAddDelAddress{ |
| 237 | IsAdd: true, |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 238 | SwIfIndex: veth.Index(), |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 239 | Prefix: veth.AddressWithPrefix(), |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 240 | } |
| 241 | addressReply := &interfaces.SwInterfaceAddDelAddressReply{} |
| 242 | |
| 243 | if err := vpp.apiChannel.SendRequest(addressReq).ReceiveReply(addressReply); err != nil { |
| 244 | return 0, err |
| 245 | } |
| 246 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 247 | return veth.Index(), nil |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | func (vpp *VppInstance) addAppNamespace( |
| 251 | secret uint64, |
| 252 | ifx interface_types.InterfaceIndex, |
| 253 | namespaceId string, |
| 254 | ) error { |
| 255 | req := &session.AppNamespaceAddDelV2{ |
| 256 | Secret: secret, |
| 257 | SwIfIndex: ifx, |
| 258 | NamespaceID: namespaceId, |
| 259 | } |
| 260 | reply := &session.AppNamespaceAddDelV2Reply{} |
| 261 | |
| 262 | if err := vpp.apiChannel.SendRequest(req).ReceiveReply(reply); err != nil { |
| 263 | return err |
| 264 | } |
| 265 | |
| 266 | sessionReq := &session.SessionEnableDisable{ |
| 267 | IsEnable: true, |
| 268 | } |
| 269 | sessionReply := &session.SessionEnableDisableReply{} |
| 270 | |
| 271 | if err := vpp.apiChannel.SendRequest(sessionReq).ReceiveReply(sessionReply); err != nil { |
| 272 | return err |
| 273 | } |
| 274 | |
| 275 | return nil |
| 276 | } |
| 277 | |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 278 | func (vpp *VppInstance) createTap( |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 279 | tap *NetInterface, |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 280 | tapId ...uint32, |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 281 | ) error { |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 282 | var id uint32 = 1 |
| 283 | if len(tapId) > 0 { |
| 284 | id = tapId[0] |
| 285 | } |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 286 | createTapReq := &tapv2.TapCreateV2{ |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 287 | ID: id, |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 288 | HostIfNameSet: true, |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 289 | HostIfName: tap.Name(), |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 290 | HostIP4PrefixSet: true, |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 291 | HostIP4Prefix: tap.IP4AddressWithPrefix(), |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 292 | } |
| 293 | createTapReply := &tapv2.TapCreateV2Reply{} |
| 294 | |
| 295 | // Create tap interface |
| 296 | if err := vpp.apiChannel.SendRequest(createTapReq).ReceiveReply(createTapReply); err != nil { |
| 297 | return err |
| 298 | } |
| 299 | |
| 300 | // Add address |
| 301 | addAddressReq := &interfaces.SwInterfaceAddDelAddress{ |
| 302 | IsAdd: true, |
| 303 | SwIfIndex: createTapReply.SwIfIndex, |
Maros Ondrejicka | 40cba40 | 2023-02-23 13:19:15 +0100 | [diff] [blame] | 304 | Prefix: tap.Peer().AddressWithPrefix(), |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 305 | } |
| 306 | addAddressReply := &interfaces.SwInterfaceAddDelAddressReply{} |
| 307 | |
| 308 | if err := vpp.apiChannel.SendRequest(addAddressReq).ReceiveReply(addAddressReply); err != nil { |
| 309 | return err |
| 310 | } |
| 311 | |
| 312 | // Set interface to up |
| 313 | upReq := &interfaces.SwInterfaceSetFlags{ |
| 314 | SwIfIndex: createTapReply.SwIfIndex, |
| 315 | Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, |
| 316 | } |
| 317 | upReply := &interfaces.SwInterfaceSetFlagsReply{} |
| 318 | |
| 319 | if err := vpp.apiChannel.SendRequest(upReq).ReceiveReply(upReply); err != nil { |
| 320 | return err |
| 321 | } |
| 322 | |
| 323 | return nil |
| 324 | } |
| 325 | |
Maros Ondrejicka | a2d5262 | 2023-02-24 11:26:39 +0100 | [diff] [blame] | 326 | func (vpp *VppInstance) saveLogs() { |
| 327 | logTarget := vpp.container.getLogDirPath() + "vppinstance-" + vpp.container.name + ".log" |
| 328 | logSource := vpp.container.GetHostWorkDir() + defaultLogFilePath |
| 329 | cmd := exec.Command("cp", logSource, logTarget) |
| 330 | vpp.Suite().T().Helper() |
| 331 | vpp.Suite().log(cmd.String()) |
| 332 | cmd.Run() |
| 333 | } |
| 334 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 335 | func (vpp *VppInstance) disconnect() { |
| 336 | vpp.connection.Disconnect() |
| 337 | vpp.apiChannel.Close() |
| 338 | } |