Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mdns]: Refactor stage #1 #776

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bb5e9fc
feat(mdns): refactor stage #1
david-cermak Feb 7, 2025
83a59da
feat(mdns): Make mdns-debug a separate module
david-cermak Mar 8, 2025
6502567
feat(mdns): Separate packet-tx and browse
david-cermak Mar 9, 2025
a569c63
feat(mdns): Add responder module
david-cermak Mar 9, 2025
d50d89c
feat(mdns): Querier-search stuff, Responder-pcb stuff
david-cermak Mar 10, 2025
ff5cef6
feat(mdns): action queue abstraction
david-cermak Mar 11, 2025
62bd747
fix(mdns): Minor cleanup of packet parser
david-cermak Mar 11, 2025
21a5dc5
fix(mdns): Cleanup and split interfaces between modules
david-cermak Mar 12, 2025
28128a8
feat(mdns): Add fuzzing job with AFL++
david-cermak Mar 19, 2025
3e5946a
fix(mdns): Rename and cleanup
david-cermak Mar 21, 2025
acd3c13
feat(mdns): Add service module
david-cermak Mar 24, 2025
2005f3f
fix(mdns): Forward porting 8ca45f34fa delete race
david-cermak Mar 24, 2025
2b15776
fix(mdns): Minor cleanup
david-cermak Mar 26, 2025
0bd74cb
fix(mdns): Refactor fuzzer test suite
david-cermak Mar 27, 2025
6db95af
fix(mdns): Add host unit tests
david-cermak Mar 30, 2025
0974c6b
fix(mdns): Add receiver unit tests
david-cermak Mar 31, 2025
afbec7d
feat(mdns): Add test template for mdns-sender
david-cermak Mar 31, 2025
d847677
fix(mdns): Minor cleanup
david-cermak Apr 1, 2025
7330f78
fix(mdns): Cleanup querier and pcb
david-cermak Apr 1, 2025
c41424e
fix(mdns): Cleanup mdns sender
david-cermak Apr 1, 2025
1738b70
fix(mdns): Cleanup mdns sender
david-cermak Apr 1, 2025
48fef6f
fix(mdns): Add documentation about the refactor, remove old fuzz
david-cermak Apr 2, 2025
582d2e4
fix(mdns): Add refactoring details to help review changes
david-cermak Apr 2, 2025
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
95 changes: 93 additions & 2 deletions .github/workflows/mdns__host-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ jobs:
shell: bash
run: |
. ${IDF_PATH}/export.sh
cd components/mdns/tests/test_afl_fuzz_host/
make INSTR=off
cd components/mdns/tests/host_unit_test/
idf.py reconfigure
mkdir build2 && cd build2
cmake ..
cmake --build .
- name: Test no malloc functions
shell: bash
run: |
Expand All @@ -68,3 +71,91 @@ jobs:
diff -q $file /tmp/$file || exit 1
echo "OK"
done

host_unit_test:
if: contains(github.event.pull_request.labels.*.name, 'mdns') || github.event_name == 'push'
name: Unit tests on host
strategy:
matrix:
idf_ver: ["latest"]

runs-on: ubuntu-22.04
container: espressif/idf:${{ matrix.idf_ver }}
steps:
- name: Checkout esp-protocols
uses: actions/checkout@v4
- name: Install bsdlib and ruby
run: |
apt-get update -y
apt-get install -y libbsd-dev ruby
- name: Build and run unit tests
shell: bash
run: |
. ${IDF_PATH}/export.sh
cd components/mdns/tests/host_unit_test/
idf.py reconfigure
mkdir build2 && cd build2
cmake -DUNIT_TESTS=test_receiver ..
cmake --build .
ctest --extra-verbose
cd ..
mkdir build3 && cd build3
cmake -DUNIT_TESTS=test_sender ..
cmake --build .
ctest --extra-verbose


fuzz_test:
if: contains(github.event.pull_request.labels.*.name, 'mdns-fuzz') || github.event_name == 'push'
name: Fuzzer tests for mdns lib
strategy:
matrix:
idf_ver: ["latest"]

runs-on: ubuntu-22.04
container: aflplusplus/aflplusplus
steps:
- name: Checkout esp-protocols
uses: actions/checkout@v4

- name: Checkout ESP-IDF
uses: actions/checkout@v4
with:
repository: espressif/esp-idf
path: idf
submodules: recursive

- name: Install Necessary Libs
run: |
apt-get update -y
apt-get install -y libbsd-dev

- name: Run AFL++
shell: bash
run: |
export IDF_PATH=$GITHUB_WORKSPACE/idf
cd components/mdns/tests/host_unit_test/
pip install dnslib
cd input && python generate_cases.py && cd ..
mkdir build2 && cd build2
cmake -DCMAKE_C_COMPILER=afl-cc ..
cmake --build .
cd ..
timeout 10m afl-fuzz -i input -o out -- build2/mdns_host_unit_test || \
if [ $? -eq 124 ]; then # timeout exit code
if [ -n "$(find out/default/crashes -type f 2>/dev/null)" ]; then
echo "Crashes found!";
tar -czf out/default/crashes.tar.gz -C out/default crashes;
exit 1;
fi
else
exit 1;
fi

- name: Upload Crash Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: fuzz-crashes
path: components/mdns/tests/host_unit_test/out/default/crashes.tar.gz
if-no-files-found: ignore
8 changes: 6 additions & 2 deletions components/mdns/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ endif()

set(MDNS_MEMORY "mdns_mem_caps.c")

set(MDNS_CORE "mdns_responder.c" "mdns_receive.c" "mdns_utils.c" "mdns_debug.c" "mdns_browser.c" "mdns_send.c" "mdns_netif.c"
"mdns_querier.c" "mdns_pcb.c" "mdns_service.c")
#set(MDNS_CORE "mdns.c" )

idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
set(dependencies esp_netif_linux esp_event)
set(private_dependencies esp_timer console esp_system)
set(srcs "mdns.c" ${MDNS_MEMORY} ${MDNS_NETWORKING} ${MDNS_CONSOLE})
set(srcs ${MDNS_CORE} ${MDNS_MEMORY} ${MDNS_NETWORKING} ${MDNS_CONSOLE})
else()
set(dependencies lwip console esp_netif)
set(private_dependencies esp_timer esp_wifi)
set(srcs "mdns.c" ${MDNS_MEMORY} ${MDNS_NETWORKING} ${MDNS_CONSOLE})
set(srcs ${MDNS_CORE} ${MDNS_MEMORY} ${MDNS_NETWORKING} ${MDNS_CONSOLE})
endif()

idf_component_register(
Expand Down
Loading