Skip to content

Commit

Permalink
Merge branch 'cilium:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
doniacld committed Mar 21, 2024
2 parents e903b61 + ea16b85 commit 9ad5027
Show file tree
Hide file tree
Showing 36 changed files with 400 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cilium",
"image": "quay.io/cilium/cilium-builder:819a4f1e57eaacb6aabfc6a1a39d11d4fd794a88@sha256:24781dc80f2be2d8fd66b0ce1405e1f117a3a0ef388758b1ede7831778e3a4f7",
"image": "quay.io/cilium/cilium-builder:bd61a0f0d0887d5836d8ec6e770672742a2b01a9@sha256:26042a41693ca6d978b3b013a5656c55f51a4e7691262f77f175542b8c0e73e2",
"workspaceFolder": "/go/src/github.com/cilium/cilium",
"workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/cilium/cilium,type=bind",
"features": {
Expand Down
39 changes: 7 additions & 32 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
"main",
"v1.15",
"v1.14",
"v1.13",
"v1.12"
"v1.13"
],
"vulnerabilityAlerts": {
"enabled": true
Expand Down Expand Up @@ -139,8 +138,7 @@
"main",
"v1.15",
"v1.14",
"v1.13",
"v1.12"
"v1.13"
]
},
{
Expand All @@ -155,8 +153,7 @@
matchBaseBranches: [
"v1.15",
"v1.14",
"v1.13",
"v1.12"
"v1.13"
]
},
{
Expand Down Expand Up @@ -230,15 +227,6 @@
"v1.13"
],
},
{
"matchPackageNames": [
"docker.io/library/ubuntu"
],
"allowedVersions": "20.04",
"matchBaseBranches": [
"v1.12"
],
},
{
"matchPackageNames": [
"docker.io/library/golang",
Expand All @@ -257,8 +245,7 @@
"allowedVersions": "<1.22",
"matchBaseBranches": [
"v1.14",
"v1.13",
"v1.12"
"v1.13"
]
},
{
Expand Down Expand Up @@ -288,15 +275,6 @@
"v1.13"
]
},
{
"matchPackageNames": [
"docker.io/library/alpine"
],
"allowedVersions": "<3.17",
"matchBaseBranches": [
"v1.12"
]
},
{
"matchPackageNames": [
"gcr.io/etcd-development/etcd"
Expand Down Expand Up @@ -339,8 +317,7 @@
"minor"
],
"matchBaseBranches": [
"v1.13",
"v1.12",
"v1.13"
]
},
{
Expand Down Expand Up @@ -375,8 +352,7 @@
"matchBaseBranches": [
"v1.15",
"v1.14",
"v1.13",
"v1.12"
"v1.13"
]
},
{
Expand All @@ -398,8 +374,7 @@
"matchBaseBranches": [
"v1.15",
"v1.14",
"v1.13",
"v1.12",
"v1.13"
],
},
{
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-images-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}-race
target: release
build-args: |
BASE_IMAGE=quay.io/cilium/cilium-runtime:fc827f3017004337e4a6fa71f481fa148e177242@sha256:8d60345a66aa4595ea8607880f612c908c639b3fa69ea015a649f67f447cc51f
BASE_IMAGE=quay.io/cilium/cilium-runtime:a6ce8fe335c696aa88a5d45d0a810263f9c8449b@sha256:da65d53e6e5c659ec5b15ab1c3ef2f12bc90c619f4170236dc1f6421eeb428be
LOCKDEBUG=1
RACE=1
OPERATOR_VARIANT=${{ matrix.name }}
Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:
quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}-race
target: release
build-args: |
BASE_IMAGE=quay.io/cilium/cilium-runtime:fc827f3017004337e4a6fa71f481fa148e177242@sha256:8d60345a66aa4595ea8607880f612c908c639b3fa69ea015a649f67f447cc51f
BASE_IMAGE=quay.io/cilium/cilium-runtime:a6ce8fe335c696aa88a5d45d0a810263f9c8449b@sha256:da65d53e6e5c659ec5b15ab1c3ef2f12bc90c619f4170236dc1f6421eeb428be
LOCKDEBUG=1
RACE=1
OPERATOR_VARIANT=${{ matrix.name }}
Expand Down
25 changes: 2 additions & 23 deletions .github/workflows/lint-bpf-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
coccinelle:
- 'contrib/coccinelle/**'
bpf-tests-runner:
- 'test/bpf_tests/**'
- 'bpf/tests/bpftest/**'
- 'pkg/bpf/**'
workflow-description:
- '.github/workflows/lint-bpf-checks.yaml'
Expand Down Expand Up @@ -140,32 +140,11 @@ jobs:
name: BPF unit/integration Tests
runs-on: ubuntu-22.04
steps:
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
# renovate: datasource=golang-version depName=go
go-version: 1.22.1
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
with:
path: ${{ needs.set_clang_dir.outputs.clang_dir }}
key: llvm-10.0
- name: Install LLVM and Clang prerequisites
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libtinfo5
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@be40c5af3a4adc3e4a03199995ab73aa37536712 # v1.9.0
with:
version: "10.0"
directory: ${{ needs.set_clang_dir.outputs.clang_dir }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
fetch-depth: 0
- name: Run BPF tests
run: |
make -C test run_bpf_tests || (echo "Run 'make -C test run_bpf_tests' locally to investigate failures"; exit 1)
make run_bpf_tests || (echo "Run 'make run_bpf_tests' locally to investigate failures"; exit 1)
4 changes: 2 additions & 2 deletions .github/workflows/lint-codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:
persist-credentials: false
fetch-depth: 1
- name: Initialize CodeQL
uses: github/codeql-action/init@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
uses: github/codeql-action/init@05963f47d870e2cb19a537396c1f668a348c7d8f # v3.24.8
with:
languages: go
debug: true
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
uses: github/codeql-action/analyze@05963f47d870e2cb19a537396c1f668a348c7d8f # v3.24.8
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ Makefile* @cilium/build
/test/k8s/services.go @cilium/sig-lb @cilium/ci-structure
# Datapath tests
/test/bpf/ @cilium/sig-datapath
/test/bpf_tests/ @cilium/sig-datapath
/bpf/tests/bpftest/ @cilium/sig-datapath
/test/k8s/bandwidth.go @cilium/sig-datapath @cilium/ci-structure
/test/k8s/chaos.go @cilium/sig-datapath @cilium/ci-structure
/test/k8s/datapath_configuration.go @cilium/sig-datapath @cilium/ci-structure
Expand Down
11 changes: 2 additions & 9 deletions Documentation/contributing/testing/bpf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,11 @@ To run the tests in your local environment, execute the following command from t

.. code-block:: shell-session
$ make -C test run_bpf_tests
The output is verbose by default. Verbose mode can be disabled by setting the ``V`` option to ``0``:

.. code-block:: shell-session
$ make -C test run_bpf_tests V=0
$ make run_bpf_tests
.. note::

Running BPF tests only works on Linux machines and requires admin privileges.
The makefile uses sudo implicitly and may prompt you for credentials.
Running BPF tests requires Docker and is only expected to work on Linux.

Writing tests
=============
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,10 @@ force :;
# it exists here so the entire source code repo can be mounted into the container.
CILIUM_BUILDER_IMAGE=$(shell cat images/cilium/Dockerfile | grep "ARG CILIUM_BUILDER_IMAGE=" | cut -d"=" -f2)
run_bpf_tests:
docker run -v $$(pwd):/src --privileged -w /src -e RUN_WITH_SUDO=false $(CILIUM_BUILDER_IMAGE) "make" "-C" "test/" "run_bpf_tests"
docker run --rm --privileged \
-v $$(pwd):/src -w /src \
$(CILIUM_BUILDER_IMAGE) \
"make" "-j$(shell nproc)" "-C" "bpf/tests/" "all" "run"

run-builder:
docker run -it --rm -v $$(pwd):/go/src/github.com/cilium/cilium $(CILIUM_BUILDER_IMAGE) bash
2 changes: 1 addition & 1 deletion api/v1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
include ../../Makefile.defs

# Update this via images/scripts/update-cilium-builder-image.sh
CILIUM_BUILDER_IMAGE=quay.io/cilium/cilium-builder:819a4f1e57eaacb6aabfc6a1a39d11d4fd794a88@sha256:24781dc80f2be2d8fd66b0ce1405e1f117a3a0ef388758b1ede7831778e3a4f7
CILIUM_BUILDER_IMAGE=quay.io/cilium/cilium-builder:bd61a0f0d0887d5836d8ec6e770672742a2b01a9@sha256:26042a41693ca6d978b3b013a5656c55f51a4e7691262f77f175542b8c0e73e2

.PHONY: proto
proto:
Expand Down
39 changes: 34 additions & 5 deletions bpf/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ else
CLANG_FLAGS += -mcpu=v2
endif

.PHONY: all clean
.PHONY: all clean run

TEST_OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))

%.o: %.c $(LIB)
$(ECHO_CC)
# Remove the .o file to force recompilation, only rely on make's caching, not clangs
@$(ECHO_CC)
@# Remove the .o file to force recompilation, only rely on make's caching, not clangs
rm -f $@
$(QUIET) ${CLANG} ${CLANG_FLAGS} -c $< -o $@

%.ll: %.c $(LIB)
$(ECHO_CC)
@$(ECHO_CC)
$(QUIET) ${CLANG} ${CLANG_FLAGS} -c -emit-llvm $< -o $@

%.i: %.c $(LIB)
$(ECHO_CC)
@$(ECHO_CC)
$(QUIET) ${CLANG} ${CLANG_FLAGS} -E -c $< -o $@

all: $(TEST_OBJECTS)
Expand All @@ -53,4 +53,33 @@ clean:
rm -f $(wildcard *.i)
rm -f $(wildcard *.d)

BPF_TEST_FLAGS:=
ifneq ($(shell id -u), 0)
BPF_TEST_FLAGS += -exec "sudo -E"
endif
ifeq ($(V),1)
BPF_TEST_FLAGS += -test.v
endif
ifeq ($(COVER),1)
ifndef COVERFORMAT
COVERFORMAT:=html
endif
BPF_TEST_FLAGS += -coverage-report $(ROOT_DIR)/bpf-coverage.$(COVERFORMAT) -coverage-format $(COVERFORMAT)
ifdef NOCOVER
BPF_TEST_FLAGS += -no-test-coverage "$(NOCOVER)"
endif
endif
ifeq ($(INSTRLOG),1)
BPF_TEST_FLAGS += -instrumentation-log $(ROOT_DIR)/test/bpf-instrumentation.log
endif
ifdef RUN
BPF_TEST_FLAGS += -run $(RUN)
endif
ifdef DUMPCTX
BPF_TEST_FLAGS += -dump-ctx
endif

run:
$(QUIET)$(GO) test ./bpftest -bpf-test-path $(ROOT_DIR)/bpf/tests $(BPF_TEST_FLAGS)

-include $(TEST_OBJECTS:.o=.d)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bpf/tests/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
___bpf_apply(__bpf_log_arg, ___bpf_narg(args))(ptr, args)

/* These values have to stay in sync with the enum */
/* values in test/bpf_tests/trf.proto */
/* values in bpf/tests/bpftest/trf.proto */
#define TEST_ERROR 0
#define TEST_PASS 1
#define TEST_FAIL 2
Expand Down
7 changes: 6 additions & 1 deletion cilium-dbg/cmd/bpf_lb_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"

"github.com/cilium/cilium/pkg/bpf"
"github.com/cilium/cilium/pkg/byteorder"
"github.com/cilium/cilium/pkg/command"
"github.com/cilium/cilium/pkg/common"
"github.com/cilium/cilium/pkg/loadbalancer"
Expand Down Expand Up @@ -96,7 +97,11 @@ func dumpSVC(serviceList map[string][]string) {
if svcKey.IsIPv6() {
ip = "[::]"
}
entry = fmt.Sprintf("%s:%d (%d) (%d) [%s]", ip, 0, revNATID, backendSlot, flags)
extra := ""
if flags.IsL7LB() {
extra = fmt.Sprintf("(L7LB Proxy Port: %d)", byteorder.NetworkToHost16(uint16(svcVal.GetBackendID())))
}
entry = fmt.Sprintf("%s:%d (%d) (%d) [%s] %s", ip, 0, revNATID, backendSlot, flags, extra)
} else if backend, found := backendMap[backendID]; !found {
entry = fmt.Sprintf("backend %d not found", backendID)
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/hubble/hubble-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: hubble-cli
image: quay.io/cilium/hubble:v0.13.0@sha256:eaf525154267394e4fb6b0d0069303830cc70115ca615f683f716575ae5ce9ac
image: quay.io/cilium/hubble:v0.13.2@sha256:750dd97539b20c526f7646e4de56726106abc25dd0cc0dc9b367adfe18db52b4
imagePullPolicy: IfNotPresent
env:
- name: HUBBLE_SERVER
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/coreos/go-systemd/v22 v22.5.0
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/docker/docker v25.0.4+incompatible
github.com/docker/docker v25.0.5+incompatible
github.com/docker/libnetwork v0.8.0-dev.2.0.20210525090646-64b7a4574d14
github.com/evanphx/json-patch v5.9.0+incompatible
github.com/fsnotify/fsnotify v1.7.0
Expand Down Expand Up @@ -153,6 +153,7 @@ require (
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa // indirect
github.com/containerd/containerd v1.7.14 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
Expand Down Expand Up @@ -233,7 +234,6 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions images/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# SPDX-License-Identifier: Apache-2.0

ARG COMPILERS_IMAGE=quay.io/cilium/image-compilers:5569a29cea6b3ad50aeb03102aaf3dc03841197c@sha256:b15dbedb7c49816c74a765e2f6ecdb9359763b8e4e4328d794f48b9cefae9804
ARG CILIUM_RUNTIME_IMAGE=quay.io/cilium/cilium-runtime:fc827f3017004337e4a6fa71f481fa148e177242@sha256:8d60345a66aa4595ea8607880f612c908c639b3fa69ea015a649f67f447cc51f
ARG CILIUM_RUNTIME_IMAGE=quay.io/cilium/cilium-runtime:a6ce8fe335c696aa88a5d45d0a810263f9c8449b@sha256:da65d53e6e5c659ec5b15ab1c3ef2f12bc90c619f4170236dc1f6421eeb428be
ARG TESTER_IMAGE=quay.io/cilium/image-tester:dd09c8d3ef349a909fbcdc99279516baef153f22@sha256:c056d064cb47c97acd607343db5457e1d49d9338d6d8a87e93e23cc93f052c73
ARG GOLANG_IMAGE=docker.io/library/golang:1.22.1@sha256:34ce21a9696a017249614876638ea37ceca13cdd88f582caad06f87a8aa45bf3
ARG GOLANG_IMAGE=docker.io/library/golang:1.22.1@sha256:0b55ab82ac2a54a6f8f85ec8b943b9e470c39e32c109b766bbc1b801f3fa8d3b
ARG CILIUM_LLVM_IMAGE=quay.io/cilium/cilium-llvm:a8c542efc076b62ba683e7699c0013adb6955f0f@sha256:38e8941107bd19eb30bdde6e478760a22325f38d1f2771dfd1b9af81d74235e7

FROM ${COMPILERS_IMAGE} as compilers-image
Expand Down

0 comments on commit 9ad5027

Please sign in to comment.