Skip to content

Commit

Permalink
Merge pull request #781 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR - Use libbpf for ebpf tc hooks
  • Loading branch information
UltraInstinct14 authored Aug 31, 2024
2 parents 2efe1c1 + fff2abb commit 37f0a2c
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 26 deletions.
9 changes: 0 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ RUN mkdir -p /opt/loxilb && \
if [ -d /usr/local/build/lib64 ] ; then mv /usr/local/build/lib64 /usr/local/build/lib; fi && \
cp -fr /usr/local/build/lib/* /usr/lib/ && ldconfig && \
rm -fr openssl-3.3.1* && \
# Install loxilb's custom ntc tool
wget https://github.com/loxilb-io/iproute2/archive/refs/heads/main.zip && \
unzip main.zip && cd iproute2-main/ && rm -fr libbpf && wget https://github.com/loxilb-io/libbpf/archive/refs/heads/main.zip && \
unzip main.zip && mv libbpf-main libbpf && cd libbpf/src/ && mkdir build && \
make install && DESTDIR=build OBJDIR=build make install && cd - && \
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:`pwd`/libbpf/src/ && \
LIBBPF_FORCE=on LIBBPF_DIR=`pwd`/libbpf/src/build ./configure && make && \
cp -f tc/tc /usr/local/sbin/ntc && cd .. && rm -fr main.zip iproute2-main && \
# Install bpftool
wget https://github.com/libbpf/bpftool/releases/download/v7.2.0/bpftool-libbpf-v7.2.0-sources.tar.gz && \
tar -xvzf bpftool-libbpf-v7.2.0-sources.tar.gz && cd bpftool/src/ && \
Expand Down Expand Up @@ -108,7 +100,6 @@ COPY --from=build /usr/local/sbin/loxilb_dp_debug /usr/local/sbin/loxilb_dp_debu
COPY --from=build /usr/local/sbin/loxicmd /usr/local/sbin/loxicmd
COPY --from=build /opt/loxilb /opt/loxilb
COPY --from=build /root/loxilb-io/loxilb/loxilb /root/loxilb-io/loxilb/loxilb
COPY --from=build /usr/local/sbin/ntc /usr/local/sbin/ntc
COPY --from=build /usr/local/sbin/bpftool /usr/local/sbin/bpftool
COPY --from=build /usr/sbin/gobgp* /usr/sbin/
COPY --from=build /root/.bashrc /root/.bashrc
Expand Down
4 changes: 2 additions & 2 deletions cicd/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ function create_lb_rule() {
return
fi

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_func)
if [[ $hook != *"tc_packet_func"* ]]; then
echo "ERROR : No hook point found";
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions cicd/docker-k0s-lb/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ function create_lb_rule() {
echo "$1: loxicmd create lb ${args[*]}"
$dexec $1 loxicmd create lb ${args[*]}

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_func)
if [[ $hook != *"tc_packet_func"* ]]; then
echo "ERROR : No hook point found";
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions cicd/docker-k3s-calico/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ function create_lb_rule() {
echo "$1: loxicmd create lb ${args[*]}"
$dexec $1 loxicmd create lb ${args[*]}

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_func)
if [[ $hook != *"tc_packet_func"* ]]; then
echo "ERROR : No hook point found";
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions cicd/docker-k3s-cilium/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ function create_lb_rule() {
echo "$1: loxicmd create lb ${args[*]}"
$dexec $1 loxicmd create lb ${args[*]}

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_func)
if [[ $hook != *"tc_packet_func"* ]]; then
echo "ERROR : No hook point found";
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions cicd/docker-k3s-lb/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ function create_lb_rule() {
echo "$1: loxicmd create lb ${args[*]}"
$dexec $1 loxicmd create lb ${args[*]}

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_func)
if [[ $hook != *"tc_packet_func"* ]]; then
echo "ERROR : No hook point found";
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions cicd/k0s-incluster/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ function create_lb_rule() {
echo "$1: loxicmd create lb ${args[*]}"
$dexec $1 loxicmd create lb ${args[*]}

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_func)
if [[ $hook != *"tc_packet_func"* ]]; then
echo "ERROR : No hook point found";
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions cicd/k3s-incluster/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ function create_lb_rule() {
echo "$1: loxicmd create lb ${args[*]}"
$dexec $1 loxicmd create lb ${args[*]}

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_func)
if [[ $hook != *"tc_packet_func"* ]]; then
echo "ERROR : No hook point found";
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion cicd/microk8s-incluster/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ function create_lb_rule() {
echo "$1: loxicmd create lb ${args[*]}"
$dexec $1 loxicmd create lb ${args[*]}

hook=$($dexec llb1 ntc filter show dev eth0 ingress | grep tc_packet_hook)
hook=$($dexec llb1 tc filter show dev eth0 ingress | grep tc_packet_hook)
if [[ $hook != *"tc_packet_hook"* ]]; then
echo "ERROR : No hook point found";
exit 1
Expand Down
2 changes: 1 addition & 1 deletion pkg/loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func (e *DpEbpfH) loadEbpfPgm(name string) int {
ret := -1
for _, f := range filters {
if t, ok := f.(*nlp.BpfFilter); ok {
if strings.Contains(t.Name, C.TC_LL_SEC_DEFAULT) {
if strings.Contains(t.Name, "tc_packet_func") {
ret = 0
break
}
Expand Down

0 comments on commit 37f0a2c

Please sign in to comment.