Skip to content

Commit

Permalink
[core] Extract ELF parser out of the BPF module and add build option …
Browse files Browse the repository at this point in the history
…PIPY_BPF
  • Loading branch information
pajama-coder committed Dec 25, 2023
1 parent 03b774b commit 420a772
Show file tree
Hide file tree
Showing 5 changed files with 530 additions and 403 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project(pipy)

option(PIPY_GUI "include builtin GUI" ON)
option(PIPY_SAMPLES "include builtin sample scripts" ON)
option(PIPY_BPF, "enable eBPF support" ON)
option(PIPY_SOIL_FREED_SPACE "invalidate freed space for debugging" OFF)
option(PIPY_ASSERT_SAME_THREAD "enable assertions for strict inner-thread data access" OFF)
option(PIPY_ZLIB "external zlib location" "")
Expand Down Expand Up @@ -191,6 +192,7 @@ add_executable(pipy
src/context.cpp
src/data.cpp
src/deframer.cpp
src/elf.cpp
src/event.cpp
src/event-queue.cpp
src/fetch.cpp
Expand Down Expand Up @@ -324,6 +326,10 @@ if(PIPY_SAMPLES)
add_dependencies(pipy PackSamples)
endif()

if(PIPY_BPF)
add_definitions(-DPIPY_USE_BPF)
endif()

if(PIPY_SOIL_FREED_SPACE)
add_definitions(-DPIPY_SOIL_FREED_SPACE)
endif()
Expand Down Expand Up @@ -357,4 +363,4 @@ target_link_libraries(
leveldb
-pthread
-ldl
)
)
8 changes: 4 additions & 4 deletions samples/bpf/load-balancer/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ setup_net server3 veth3 10.0.3.100/24 10.0.3.200/24
sleep 1

echo 'Starting upstream servers...'
ip netns exec server1 ../../../bin/pipy -e 'pipy().listen(8080).serveHTTP(new Message("hi from server1\n"))' &
ip netns exec server2 ../../../bin/pipy -e 'pipy().listen(8080).serveHTTP(new Message("hi from server2\n"))' &
ip netns exec server3 ../../../bin/pipy -e 'pipy().listen(8080).serveHTTP(new Message("hi from server3\n"))' &
ip netns exec server1 ../../../bin/pipy -e 'pipy().listen(8080).serveHTTP(new Message("hi from server1\n"))' 2> /dev/null &
ip netns exec server2 ../../../bin/pipy -e 'pipy().listen(8080).serveHTTP(new Message("hi from server2\n"))' 2> /dev/null &
ip netns exec server3 ../../../bin/pipy -e 'pipy().listen(8080).serveHTTP(new Message("hi from server3\n"))' 2> /dev/null &
sleep 1

echo 'Loading BPF programs...'
/home/shuang/git/bpftool/src/bpftool prog load /home/shuang/git/pipy/bin/load-balancer.o /sys/fs/bpf/lb
bpftool prog load /home/shuang/git/pipy/bin/load-balancer.o /sys/fs/bpf/lb
ip link set lo xdpgeneric pinned /sys/fs/bpf/lb
ip link set veth0 xdpgeneric pinned /sys/fs/bpf/lb
ip link set veth1 xdpgeneric pinned /sys/fs/bpf/lb
Expand Down
Loading

0 comments on commit 420a772

Please sign in to comment.