-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from wide-vsix/slankdev-less-dependency
Less Dependency
- Loading branch information
Showing
42 changed files
with
9,722 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
ARG CILIUM_LLVM_IMAGE=quay.io/cilium/cilium-llvm:3408daa17f6490a464dfc746961e28ae31964c66 | ||
ARG UBUNTU_IMAGE=docker.io/library/ubuntu:22.04 | ||
|
||
# STAGE(llvm-dist) | ||
FROM ${CILIUM_LLVM_IMAGE} as llvm-dist | ||
|
||
# STAGE(iproute2-dist) | ||
FROM ${UBUNTU_IMAGE} as iproute2-dist | ||
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y \ | ||
vim curl git gcc make flex bison clang-12 libbsd-dev libbfd-dev \ | ||
libcap-dev libelf-dev gcc-multilib pkg-config linux-tools-`uname -r` | ||
ARG LIBBPF_VERSION="0.8.0" | ||
ARG IPROUTE2_VERSION="5.18.0" | ||
ADD https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz . | ||
RUN tar xvf v${LIBBPF_VERSION}.tar.gz | ||
RUN cd libbpf-${LIBBPF_VERSION}/src && make install BUILD_STATIC_ONLY=1 && make install_pkgconfig | ||
ADD https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/snapshot/iproute2-${IPROUTE2_VERSION}.tar.gz . | ||
RUN tar xvf iproute2-${IPROUTE2_VERSION}.tar.gz | ||
RUN cd iproute2-${IPROUTE2_VERSION} && ./configure --libbpf_force=on --libbpf_dir=/ && make install | ||
|
||
# STAGE(flowctl-dist) | ||
FROM golang:1.17 as flowctl-dist | ||
WORKDIR /opt | ||
COPY ./ ./ | ||
RUN CGO_ENABLED=0 go build -o ./bin/flowctl ./cmd/flowctl/main.go | ||
|
||
# STAGE(rootfs) | ||
FROM ${UBUNTU_IMAGE} as rootfs | ||
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y --no-install-recommends \ | ||
curl libelf1 libmnl0 bash-completion iptables ipset kmod ca-certificates \ | ||
libelf-dev libbsd-dev jq | ||
COPY ./bpf /usr/include/bpf | ||
COPY --from=llvm-dist /usr/local/bin/clang /usr/local/bin/llc /usr/local/bin/ | ||
COPY --from=iproute2-dist /usr/sbin/ip /usr/sbin/ss /usr/sbin/tc /usr/sbin/ | ||
COPY --from=flowctl-dist /opt/bin/flowctl /usr/bin/ | ||
RUN echo "source /etc/bash_completion" >> /root/.bashrc | ||
RUN echo ". <(flowctl completion bash)" >> /root/.bashrc | ||
|
||
# FINAL STAGE | ||
FROM scratch | ||
COPY --from=rootfs / / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright Authors of Cilium. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ | ||
/* Copyright Authors of Cilium */ | ||
|
||
#ifndef __BPF_ACCESS_H_ | ||
#define __BPF_ACCESS_H_ | ||
|
||
#include "compiler.h" | ||
|
||
#if defined(__bpf__) | ||
static __always_inline __maybe_unused __u32 | ||
map_array_get_32(const __u32 *array, __u32 index, const __u32 limit) | ||
{ | ||
__u32 datum = 0; | ||
|
||
if (__builtin_constant_p(index) || | ||
!__builtin_constant_p(limit)) | ||
__throw_build_bug(); | ||
|
||
/* LLVM tends to optimize code away that is needed for the verifier to | ||
* understand dynamic map access. Input constraint is that index < limit | ||
* for this util function, so we never fail here, and returned datum is | ||
* always valid. | ||
*/ | ||
asm volatile("%[index] <<= 2\n\t" | ||
"if %[index] > %[limit] goto +1\n\t" | ||
"%[array] += %[index]\n\t" | ||
"%[datum] = *(u32 *)(%[array] + 0)\n\t" | ||
: [datum]"=r"(datum) | ||
: [limit]"i"(limit), [array]"r"(array), [index]"r"(index) | ||
: /* no clobbers */ ); | ||
|
||
return datum; | ||
} | ||
#else | ||
# define map_array_get_32(array, index, limit) __throw_build_bug() | ||
#endif /* __bpf__ */ | ||
#endif /* __BPF_ACCESS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ | ||
/* Copyright Authors of Cilium */ | ||
|
||
#ifndef __BPF_API__ | ||
#define __BPF_API__ | ||
|
||
#include <linux/types.h> | ||
#include <linux/byteorder.h> | ||
#include <linux/bpf.h> | ||
#include <linux/if_packet.h> | ||
|
||
#include "compiler.h" | ||
#include "section.h" | ||
#include "helpers.h" | ||
#include "builtins.h" | ||
#include "tailcall.h" | ||
#include "errno.h" | ||
#include "loader.h" | ||
#include "csum.h" | ||
#include "access.h" | ||
|
||
#endif /* __BPF_API__ */ |
Oops, something went wrong.