-
Notifications
You must be signed in to change notification settings - Fork 299
/
Copy pathdisableTxOffload.go
64 lines (53 loc) · 1.56 KB
/
disableTxOffload.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause
package cmd
import (
"context"
"github.com/charmbracelet/log"
"github.com/spf13/cobra"
"github.com/srl-labs/containerlab/clab"
"github.com/srl-labs/containerlab/cmd/common"
"github.com/srl-labs/containerlab/runtime"
"github.com/srl-labs/containerlab/utils"
)
var cntName string
// upgradeCmd represents the version command.
var disableTxOffloadCmd = &cobra.Command{
Use: "disable-tx-offload",
Short: "disables tx checksum offload on eth0 interface of a container",
PreRunE: common.CheckAndGetRootPrivs,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
opts := []clab.ClabOption{
clab.WithTimeout(common.Timeout),
clab.WithRuntime(common.Runtime,
&runtime.RuntimeConfig{
Debug: common.Debug,
Timeout: common.Timeout,
GracefulShutdown: common.Graceful,
},
),
clab.WithDebug(common.Debug),
}
c, err := clab.NewContainerLab(opts...)
if err != nil {
return err
}
node, err := c.GetNode(cntName)
if err != nil {
return err
}
err = node.ExecFunction(ctx, utils.NSEthtoolTXOff(cntName, "eth0"))
if err != nil {
return err
}
log.Infof("Tx checksum offload disabled for eth0 interface of %s container", cntName)
return nil
},
}
func init() {
toolsCmd.AddCommand(disableTxOffloadCmd)
disableTxOffloadCmd.Flags().StringVarP(&cntName, "container", "c", "", "container name to disable offload in")
_ = disableTxOffloadCmd.MarkFlagRequired("container")
}