Skip to content

Commit f123930

Browse files
jfl929930xcaspar
authored andcommitted
The problem of wrong return value of destroy under non root Linux
Signed-off-by: jfl929930 <[email protected]>
1 parent 0dc90d1 commit f123930

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

exec/bin/tcnetwork/tcnetwork.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,19 @@ func addQdiscForDL(channel spec.Channel, ctx context.Context, netInterface strin
377377
}
378378

379379
// stopNet, no need to add os.Exit
380-
func stopNet(netInterface string) {
380+
func stopNet(netInterface string) *spec.Response{
381381
ctx := context.Background()
382-
cl.Run(ctx, "tc", fmt.Sprintf(`filter del dev %s parent 1: prio 4`, netInterface))
383-
cl.Run(ctx, "tc", fmt.Sprintf(`qdisc del dev %s root`, netInterface))
382+
run := cl.Run(ctx, "tc", fmt.Sprintf(`filter del dev %s parent 1: prio 4`, netInterface))
383+
response := cl.Run(ctx, "tc", fmt.Sprintf(`qdisc del dev %s root`, netInterface))
384+
if !response.Success {
385+
bin.PrintErrAndExit(response.Err)
386+
return response
387+
} else if !run.Success {
388+
bin.PrintErrAndExit(run.Err)
389+
return run
390+
}
391+
bin.PrintOutputAndExit(response.Result.(string))
392+
return response
384393
}
385394

386395
// getPeerPorts returns all ports communicating with the port

0 commit comments

Comments
 (0)