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

v1.8 backports 2020-10-19 #13628

Merged
merged 2 commits into from
Oct 20, 2020
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
7 changes: 3 additions & 4 deletions Documentation/operations/performance/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ Download the Cilium performance evaluation scripts:

.. code-block:: shell-session

$ git clone https://github.com/cilium/perfeval.git
$ cd perfeval
$ git clone https://github.com/cilium/cilium-perf-networking.git
$ cd cilium-perf-networking

Packet Servers
--------------
Expand All @@ -60,8 +60,7 @@ the Packet machines to use a `"Mixed/Hybrid"
<https://www.packet.com/developers/docs/network/advanced/layer-2/>`_ network
mode, where the secondary interfaces of the machines share a flat L2 network.
While this can be done on the Packet web UI, we include appropriate Terraform
files to automate this process.

(version 0.13) files to automate this process.

.. code-block:: shell-session

Expand Down
13 changes: 10 additions & 3 deletions pkg/datapath/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,16 @@ func (l *Loader) reloadHostDatapath(ctx context.Context, ep datapath.Endpoint, o
directions = append(directions, dirEgress)
objPaths = append(objPaths, netdevObjPath)
} else {
// Remove any previously attached device from egress path if BPF
// NodePort is disabled.
l.DeleteDatapath(ctx, device, dirEgress)
hasDatapath, err := l.HasDatapath(ctx, device, dirEgress)
if err != nil {
log.WithField("device", device).Error(err)
}
if hasDatapath || err != nil {
// Remove any previously attached device from egress path if BPF
// NodePort and host firewall are disabled.
err := l.DeleteDatapath(ctx, device, dirEgress)
log.WithField("device", device).Error(err)
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/datapath/loader/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package loader
import (
"context"
"fmt"
"strings"

"github.com/cilium/cilium/pkg/bpf"
"github.com/cilium/cilium/pkg/command/exec"
Expand Down Expand Up @@ -141,3 +142,15 @@ func (l *Loader) DeleteDatapath(ctx context.Context, ifName, direction string) e

return nil
}

// HasDatapath return true if the interface as a tc filter attached on the given direction.
func (l *Loader) HasDatapath(ctx context.Context, ifName, direction string) (bool, error) {
args := []string{"filter", "show", "dev", ifName, direction}
cmd := exec.CommandContext(ctx, "tc", args...).WithFilters(libbpfFixupMsg)
output, err := cmd.Output(log, true)
if err != nil {
return false, fmt.Errorf("Failed to get tc filter: %s", err)
}

return strings.TrimSpace(string(output)) != "", nil
}