我的 eBPF 封包要去哪裡?

我的 eBPF 封包要去哪裡?

我有一個使用 eBPF 的測試案例,它在 2 個命名空間之間設定「ping」。我的 eBPF 程式攔截流的第一個資料包,將其發送到用戶空間,在用戶空間中它用於構造映射,以便流的後續資料包直接從接收 eth 傳遞到生成 ping 回复的內核。然後第一個資料包被送入 eBPF 傳輸隊列,我希望它進入內核並生成 ping 回复,但實際上我沒有看到該資料包的進一步踪跡;不在介面上的“tcpdump”中,也不在“pwru”中。誰能告訴我我做錯了什麼?

我的測試用例在這裡https://github.com/tjcw/bpf-examples/tree/tjcw-send-first-packet-debug-20221210.1121/AF_XDP-filter;它的運行腳本在這裡https://github.com/tjcw/bpf-examples/blob/tjcw-send-first-packet-debug-20221210.1121/AF_XDP-filter/ping-namespace-direct-with-dummy/run.sh

運行日誌(包括格式化的tcpdump)在這裡https://github.com/tjcw/bpf-examples/blob/tjcw-send-first-packet-debug-20221210.1121/AF_XDP-filter/ping-namespace-direct-with-dummy/runlog.txt日誌來自pwru這裡https://github.com/tjcw/bpf-examples/blob/tjcw-send-first-packet-debug-20221210.1121/AF_XDP-filter/ping-namespace-direct-with-dummy/pwru.txt

我正在完全更新的 Ubuntu 22.04 下運行。

抱歉,上面的執行日誌沒有 tcpdump 輸出。這裡https://github.com/tjcw/bpf-examples/blob/tjcw-send-first-packet-debug-20221210.1121/AF_XDP-filter/ping-namespace-direct-with-dummy/run2.txt這就是我打算用 tcpdumps 發布的內容。

我在目錄中新增了 UDP 測試https://github.com/tjcw/bpf-examples/tree/tjcw-send-first-packet-debug-20221212.1400/AF_XDP-filter(請參閱檔案 udp-sender-count.c 和 udp-receiver.c ,並在目錄 udp-namespace-direct-with-dummy 中執行腳本和日誌檔案)。此測試案例顯示第一個資料包被重定向到使用者空間然後遺失,第二個資料包到達 udp 偵聽器。

答案1

相關內容