Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.github
.gitlab-ci.yml
.git
Dockerfile
.dockerignore
.vscode
.idea
README.md
CODEOWNERS

176 changes: 97 additions & 79 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,66 +1,74 @@
# syntax = docker/dockerfile:experimental
FROM ubuntu:20.04 AS build-base-stage
FROM ubuntu:22.04 AS build-base-stage

WORKDIR /

ENV BUILDKIT_VERSION "v0.8.2"
ENV BUILDCTL_SHA256 "b64aec46fb438ea844616b3205c33b01a3a49ea7de1f8539abd0daeb4f07b9f9"
ENV INDENT_SHA256 "12185be748db620f8f7799ea839f0d10ce643b9f5ab1805c960e56eb27941236"
ENV LIBC_SHA256 "9a8caf9f33448a8f2f526e94d00c70cdbdd735caec510df57b3283413df7882a"
# Go version in ppa:longsleep/golang-backports
ENV GO_PACKAGE "golang-1.22-go"

COPY vpp/Makefile /vpp-src/Makefile
COPY vpp/build/external /vpp-src/build/external

RUN echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections

# netbase is needed for Scapy
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=private \
--mount=target=/var/cache/apt,type=cache,sharing=private \
echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections && \
echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections && \
apt-get update && \
apt-get install -y software-properties-common && \
apt-get dist-upgrade -yy && \
apt-get install -y software-properties-common ccache && \
# add reporistory for newer golang releases
add-apt-repository ppa:longsleep/golang-backports && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential sudo git netbase curl ca-certificates \
${GO_PACKAGE} iproute2 gdb tcpdump iputils-ping libpcap-dev \
dumb-init gdbserver clang-11 && \
curl -sSL "https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz" | \
tar -xvz -C /usr/local bin/buildctl && \
echo "${BUILDCTL_SHA256} /usr/local/bin/buildctl" | sha256sum -c && \
apt-get install -y --no-install-recommends \
software-properties-common build-essential sudo git \
# netbase is needed for Scapy
netbase curl ca-certificates iproute2 gdb tcpdump iputils-ping \
# use ccache for clang object files caching
ccache libpcap-dev dumb-init gdbserver \
# golang installed from ppa
golang-1.24-go \
# clang also installed in vpp Makefile, make sure to match versions
clang \
# llvm provides llc for xdp-tools build
llvm \
# gnu linker is used, add missing c++ library
g++-12 \
&& \
ln -s /usr/lib/go-1.24/bin/go /usr/bin/go && \
ln -s /usr/lib/go-1.24/bin/gofmt /usr/bin/gofmt && \
# set clang as default C and C++ compiler
update-alternatives --set c++ /usr/bin/clang++ && \
update-alternatives --set cc /usr/bin/clang &&\
apt-get clean

# configure ccache, but do not provide it in path
# each RUN should provide it separately
ENV CCACHE_DIR=/ccache \
CCACHE_MAXSIZE=600M \
CCACHE_COMPRESS=true \
CCACHE_COMPRESSLEVEL=6 \
GOPATH=/go

# golang uses ccache as well
RUN --mount=target=/ccache,type=cache \
PATH="/usr/lib/ccache:$PATH" && \
go install github.com/onsi/ginkgo/[email protected] && \
mv /go/bin/ginkgo /usr/local/bin && \
go install golang.org/x/tools/[email protected] && \
mv /go/bin/gopls /usr/local/bin

COPY vpp/Makefile /vpp-src/Makefile
COPY vpp/build/external /vpp-src/build/external

RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=private \
--mount=target=/var/cache/apt,type=cache,sharing=private \
--mount=target=/ccache,type=cache \
PATH="/usr/lib/ccache:$PATH" && \
cd /vpp-src && \
curl -sSL -O http://mirrors.kernel.org/ubuntu/pool/main/i/indent/indent_2.2.12-1_amd64.deb && \
echo "${INDENT_SHA256} /vpp-src/indent_2.2.12-1_amd64.deb" | sha256sum -c && \
apt-get install -y --no-install-recommends \
/vpp-src/indent_2.2.12-1_amd64.deb && \
rm /vpp-src/indent_2.2.12-1_amd64.deb && \
git config --global user.email "[email protected]" && \
git config --global user.name "dummy user" && \
git init && \
git add Makefile && \
git commit -m "dummy commit" && \
git tag -a v20.05-rc0 -m "dummy tag" && \
# version requred to have this format
git tag -a v24.02-rc0 -m "dummy tag" && \
make UNATTENDED=yes install-dep install-ext-dep && \
apt-get clean && \
rm -rf /vpp-src && \
ln -s /usr/lib/go-1.22/bin/go /usr/bin/go && \
ln -s /usr/lib/go-1.22/bin/gofmt /usr/bin/gofmt

ENV PATH="/usr/lib/ccache:$PATH"
ENV CCACHE_DIR=/ccache
ENV CCACHE_MAXSIZE=400M
ENV CCACHE_COMPRESS=true
ENV CCACHE_COMPRESSLEVEL=6

ENV GOPATH /go

RUN go install github.com/onsi/ginkgo/[email protected] && \
mv /go/bin/ginkgo /usr/local/bin

RUN go install golang.org/x/tools/[email protected] && \
mv /go/bin/gopls /usr/local/bin
apt-get clean

FROM build-base-stage AS build-stage

Expand All @@ -69,14 +77,22 @@ ADD vpp /vpp-src
# starting from this point, the debug and release buffers differ
ARG BUILD_TYPE

RUN --mount=target=/vpp-src/build-root/.ccache,type=cache \
--mount=target=/ccache,type=cache \
RUN --mount=target=/ccache,type=cache \
PATH="/usr/lib/ccache:$PATH" && \
case ${BUILD_TYPE} in \
debug) target="pkg-deb-debug"; args="-DVPP_ENABLE_TRAJECTORY_TRACE=1";; \
release) target="pkg-deb"; args="";; \
*) echo >&2 "Bad BUILD_TYPE: ${BUILD_TYPE}";; \
debug) \
target="pkg-deb-debug"; \
args="-DVPP_ENABLE_TRAJECTORY_TRACE=1"; \
;; \
release) \
target="pkg-deb"; \
args=""; \
;; \
*) \
echo >&2 "Bad BUILD_TYPE: ${BUILD_TYPE}"; \
;; \
esac; \
echo "TARGET: ${target}" && \
echo "Building target: ${target} with flags ${args}" && \
make -C /vpp-src "${target}" V=1 VPP_EXTRA_CMAKE_ARGS="${args}" && \
ccache -s && \
mkdir -p /out/debs && \
Expand All @@ -89,62 +105,64 @@ COPY --from=build-stage /out/debs .

# dev image starts here
FROM build-base-stage AS dev-stage
ARG BUILD_TYPE

RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=private \
--mount=target=/var/cache/apt,type=cache,sharing=private \
--mount=target=/debs,source=/out/debs,from=build-stage,type=bind \
apt-get install --no-install-recommends -yy \
/debs/vpp_*.deb \
/debs/vpp-dbg_*.deb \
/debs/vpp-plugin-core_*.deb \
/debs/vpp-plugin-devtools_*.deb \
/debs/vpp-plugin-dpdk*.deb \
/debs/libvppinfra_*.deb \
/debs/python3-vpp-api_*.deb \
/debs/vpp-dev_*.deb \
/debs/libvppinfra-dev_*.deb && \
/debs/vpp_*.deb \
/debs/vpp-dbg_*.deb \
/debs/vpp-plugin-core_*.deb \
/debs/vpp-plugin-devtools_*.deb \
/debs/vpp-plugin-dpdk*.deb \
/debs/libvppinfra_*.deb \
/debs/python3-vpp-api_*.deb \
/debs/vpp-dev_*.deb \
/debs/libvppinfra-dev_*.deb && \
apt-get clean

# use clean vpp source so as not to make the image too bloated
ADD vpp /vpp-src
# provide symlinks needed for running the Pythonic integration tests
RUN mkdir -p /vpp-src/build-root/build-test/src && \
ln -fs /vpp-src/test/* /vpp-src/build-root/build-test/src/
# fix git repo ownership issue
RUN git config --global --add safe.directory /src
ln -fs /vpp-src/test/* /vpp-src/build-root/build-test/src/ && \
# fix git repo ownership issue
git config --global --add safe.directory /src

# final image starts here
FROM ubuntu:20.04 AS final-stage
FROM ubuntu:22.04 AS final-stage
ARG BUILD_TYPE
WORKDIR /

ENV VPP_INSTALL_SKIP_SYSCTL=1
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=private \
--mount=target=/var/cache/apt,type=cache,sharing=private \
apt-get update && apt-get dist-upgrade -yy && \
apt-get install --no-install-recommends -yy liblz4-tool tar gdb gdbserver strace \
libhyperscan5 libmbedcrypto3 libmbedtls12 libmbedx509-0 apt-utils \
libpython3-stdlib \
python3 python3-minimal python3.6 python3-minimal \
python3-cffi python3-cffi-backend libnuma1 \
libnl-3-200 libnl-route-3-200 libpcap0.8
apt-get install --no-install-recommends -yy \
liblz4-tool tar gdb gdbserver strace apt-utils \
libhyperscan5 libmbedcrypto7 libmbedtls-dev libmbedx509-1 \
python3 python3-minimal libpython3-stdlib \
python3-cffi python3-cffi-backend libnuma1 \
libnl-3-200 libnl-route-3-200 libpcap0.8

RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=private \
--mount=target=/var/cache/apt,type=cache,sharing=private \
--mount=target=/debs,source=/out/debs,from=build-stage,type=bind \
extra_debs=; \
if [ "${BUILD_TYPE}" = "debug" ]; then \
extra_debs="/debs/vpp-dev_*.deb /debs/libvppinfra-dev_*.deb"; \
extra_debs="${extra_debs} /debs/vpp-dev_*.deb"; \
extra_debs="${extra_debs} /debs/libvppinfra-dev_*.deb"; \
fi && \
apt-get install --no-install-recommends -yy \
/debs/vpp_*.deb \
/debs/vpp-dbg_*.deb \
/debs/vpp-plugin-core_*.deb \
/debs/vpp-plugin-devtools_*.deb \
/debs/vpp-plugin-dpdk*.deb \
/debs/libvppinfra_*.deb \
/debs/python3-vpp-api_*.deb \
${extra_debs} && \
/debs/vpp_*.deb \
/debs/vpp-dbg_*.deb \
/debs/vpp-plugin-core_*.deb \
/debs/vpp-plugin-devtools_*.deb \
/debs/vpp-plugin-dpdk*.deb \
/debs/libvppinfra_*.deb \
/debs/python3-vpp-api_*.deb \
${extra_debs} && \
apt-get clean

ENTRYPOINT /usr/bin/vpp
25 changes: 25 additions & 0 deletions vpp-patches/0031-fix-ASAN-stack-size-calculation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 44e584a2004c4196f9f2eac3cb3f11fd696fa982 Mon Sep 17 00:00:00 2001
From: Vladimir Zhigulin <[email protected]>
Date: Mon, 6 Jan 2025 01:13:34 +0100
Subject: [PATCH] fix: ASAN stack size calculation

---
src/vlib/node_funcs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index 1beac33cf..f20396f52 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -60,7 +60,7 @@ vlib_process_start_switch_stack (vlib_main_t * vm, vlib_process_t * p)
#ifdef CLIB_SANITIZE_ADDR
void *stack = p ? (void *) p->stack : vlib_thread_stacks[vm->thread_index];
u32 stack_bytes =
- p ? (1ULL < p->log2_n_stack_bytes) : VLIB_THREAD_STACK_SIZE;
+ p ? (1ULL << p->log2_n_stack_bytes) : VLIB_THREAD_STACK_SIZE;
__sanitizer_start_switch_fiber (&vm->asan_stack_save, stack, stack_bytes);
#endif
}
--
2.47.1

Loading
Loading