Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented disabling of tx offload for linux nodes eth0 interfaces #212

Merged
merged 7 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sync"
"time"

"github.com/containernetworking/plugins/pkg/ns"
"github.com/docker/docker/api/types"
docker "github.com/docker/docker/client"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -105,7 +106,7 @@ func (c *cLab) CreateNode(ctx context.Context, node *Node, certs *certificates)
func (c *cLab) ExecPostDeployTasks(ctx context.Context, node *Node) error {
switch node.Kind {
case "ceos":
log.Infof("Running postdeploy actions for '%s' node", node.ShortName)
log.Debugf("Running postdeploy actions for Arista cEOS '%s' node", node.ShortName)
// regenerate ceos config since it is now known which IP address docker assigned to this container
err := node.generateConfig(node.ResConfig)
if err != nil {
Expand All @@ -122,6 +123,24 @@ func (c *cLab) ExecPostDeployTasks(ctx context.Context, node *Node) error {
if err != nil {
return err
}

case "linux":
log.Debugf("Running postdeploy actions for Linux '%s' node", node.ShortName)
// disable tx checksum offload for linux containers on lo and eth0 interfaces
nodeNS, err := ns.GetNS(node.NSPath)
if err != nil {
return err
}
err = nodeNS.Do(func(_ ns.NetNS) error {
// disabling offload on lo0 interface
err = EthtoolTXOff("eth0")
if err != nil {
log.Infof("Failed to disable TX checksum offload for 'eth0' interface for Linux '%s' node: %v", node.ShortName, err)
}
return nil
})
return err

}
return nil
}
8 changes: 7 additions & 1 deletion clab/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
dockerNetIPv4Addr = "172.20.20.0/24"
dockerNetIPv6Addr = "2001:172:20:20::/80"
dockerNetMTU = "1450"
srlDefaultType = "ixr6"
srlDefaultType = "ixr6"
)

// supported kinds
Expand Down Expand Up @@ -119,12 +119,14 @@ type Node struct {
TLSCert string
TLSKey string
TLSAnchor string
NSPath string // network namespace path for this node
}

// Link is a struct that contains the information of a link between 2 containers
type Link struct {
A *Endpoint
B *Endpoint
MTU int
Labels map[string]string
}

Expand Down Expand Up @@ -470,6 +472,10 @@ func (c *cLab) NewLink(l LinkConfig) *Link {
link := new(Link)
link.Labels = l.Labels

if link.MTU <= 0 {
link.MTU = 1500
}

for i, d := range l.Endpoints {
// i indicates the number and d presents the string, which need to be
// split in node and endpoint name
Expand Down
16 changes: 8 additions & 8 deletions clab/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const sysctlBase = "/proc/sys"

// CreateBridge creates a docker bridge
func (c *cLab) CreateBridge(ctx context.Context) (err error) {
log.Info("Creating docker bridge")
log.Debugf("Creating docker bridge: Name: %s, IPv4Subnet: '%s', IPv6Subnet: '%s", c.Config.Mgmt.Network, c.Config.Mgmt.IPv4Subnet, c.Config.Mgmt.IPv6Subnet)
log.Infof("Creating docker network: Name='%s', IPv4Subnet='%s', IPv6Subnet='%s'", c.Config.Mgmt.Network, c.Config.Mgmt.IPv4Subnet, c.Config.Mgmt.IPv6Subnet)

enableIPv6 := false
var ipamConfig []network.IPAMConfig
Expand Down Expand Up @@ -144,7 +143,7 @@ func (c *cLab) DeleteBridge(ctx context.Context) (err error) {

// CreateContainer creates a docker container
func (c *cLab) CreateContainer(ctx context.Context, node *Node) (err error) {
log.Infof("Create container: %s", node.ShortName)
log.Infof("Creating container: %s", node.ShortName)

err = c.PullImageIfRequired(ctx, node.Image)
if err != nil {
Expand Down Expand Up @@ -212,7 +211,8 @@ func (c *cLab) CreateContainer(ctx context.Context, node *Node) (err error) {
if err != nil {
return err
}
return linkContainerNS(cJSON.State.Pid, node.LongName)
node.NSPath = "/proc/" + strconv.Itoa(cJSON.State.Pid) + "/ns/net"
return linkContainerNS(node.NSPath, node.LongName)
}

func (c *cLab) PullImageIfRequired(ctx context.Context, imageName string) error {
Expand Down Expand Up @@ -345,13 +345,14 @@ func (c *cLab) DeleteContainer(ctx context.Context, name string) error {
var err error
force := !c.gracefulShutdown
if c.gracefulShutdown {
log.Infof("Stopping container: %s", name)
err = c.DockerClient.ContainerStop(ctx, name, &c.timeout)
if err != nil {
log.Errorf("could not stop container '%s': %v", name, err)
force = true
}
}
log.Infof("Removing container: %s", name)
log.Debugf("Removing container: %s", name)
err = c.DockerClient.ContainerRemove(ctx, name, types.ContainerRemoveOptions{Force: force})
if err != nil {
return err
Expand All @@ -362,11 +363,10 @@ func (c *cLab) DeleteContainer(ctx context.Context, name string) error {

// linkContainerNS creates a symlink for containers network namespace
// so that it can be managed by iproute2 utility
func linkContainerNS(pid int, containerName string) error {
func linkContainerNS(nspath string, containerName string) error {
CreateDirectory("/run/netns/", 0755)
src := "/proc/" + strconv.Itoa(pid) + "/ns/net"
dst := "/run/netns/" + containerName
err := os.Symlink(src, dst)
err := os.Symlink(nspath, dst)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion clab/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (c *cLab) CreateNodeDirStructure(node *Node) (err error) {

switch node.Kind {
case "srl":
log.Infof("Create directory structure for SRL container: %s", node.ShortName)
log.Debugf("Creating directory structure for SRL container: %s", node.ShortName)
var src string
var dst string

Expand Down
Loading