{"id":18739927,"url":"https://github.com/withlin/xdp-redirect-lab","last_synced_at":"2026-02-15T10:05:51.385Z","repository":{"id":96511979,"uuid":"434213782","full_name":"withlin/xdp-redirect-lab","owner":"withlin","description":"xdp redirect veth pair conn lab","archived":false,"fork":false,"pushed_at":"2022-04-06T11:02:59.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-28T18:32:40.441Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/withlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-02T12:33:44.000Z","updated_at":"2021-12-02T12:34:33.000Z","dependencies_parsed_at":"2023-07-06T09:00:47.504Z","dependency_job_id":null,"html_url":"https://github.com/withlin/xdp-redirect-lab","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fxdp-redirect-lab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fxdp-redirect-lab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fxdp-redirect-lab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fxdp-redirect-lab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/withlin","download_url":"https://codeload.github.com/withlin/xdp-redirect-lab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239619570,"owners_count":19669447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T15:37:54.272Z","updated_at":"2026-02-15T10:05:51.340Z","avatar_url":"https://github.com/withlin.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# xdp-redirect-lab\nxdp redirect veth pair conn lab\n\n\n\n\n### XDP REDIRECT \n\n# iperf1\n\n```\n172.17.0.2\nvethd32424b\n02:42:ac:11:00:02\n\n./xdp_loader --dev vethd32424b --force --progsec xdp_redirect_map\n\n./xdp_prog_user -d vethd32424b -r  veth70d1189  --src-mac 02:42:ac:11:00:02 --dest-mac 02:42:ac:11:00:03\n\n```\n\n# iperf3\n\n```\n172.17.0.3\nveth70d1189\n02:42:ac:11:00:03\n\n\n\n\n\n./xdp_loader --dev veth70d1189 --force --progsec xdp_redirect_map\n\n./xdp_prog_user -d veth70d1189 -r vethd32424b --src-mac 02:42:ac:11:00:03 --dest-mac 02:42:ac:11:00:02\n\n```\n\n\n\n### Lab\n\n\n\n\n### 没使用xdp加速\n\n```\n/ $ iperf3 -c 172.17.0.3\nConnecting to host 172.17.0.3, port 5201\n[  5] local 172.17.0.2 port 40596 connected to 172.17.0.3 port 5201\n[ ID] Interval           Transfer     Bitrate         Retr  Cwnd\n[  5]   0.00-1.00   sec  4.05 GBytes  34.8 Gbits/sec  388    930 KBytes\n[  5]   1.00-2.00   sec  3.98 GBytes  34.2 Gbits/sec  449    940 KBytes\n[  5]   2.00-3.00   sec  4.05 GBytes  34.8 Gbits/sec  493    963 KBytes\n[  5]   3.00-4.00   sec  3.71 GBytes  31.8 Gbits/sec    3    994 KBytes\n[  5]   4.00-5.00   sec  4.02 GBytes  34.5 Gbits/sec    3   1010 KBytes\n[  5]   5.00-6.00   sec  4.08 GBytes  35.1 Gbits/sec    5   1020 KBytes\n[  5]   6.00-7.00   sec  3.95 GBytes  34.0 Gbits/sec    2   1.01 MBytes\n[  5]   7.00-8.00   sec  4.01 GBytes  34.5 Gbits/sec    2   1.01 MBytes\n[  5]   8.00-9.00   sec  3.67 GBytes  31.5 Gbits/sec    5   1.01 MBytes\n[  5]   9.00-10.00  sec  3.91 GBytes  33.5 Gbits/sec    0   1.03 MBytes\n- - - - - - - - - - - - - - - - - - - - - - - - -\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-10.00  sec  39.4 GBytes  33.9 Gbits/sec  1350             sender\n[  5]   0.00-10.00  sec  39.4 GBytes  33.9 Gbits/sec                  receiver\n\n```\n\n#### 使用XDP加速后\n\n```\niperf Done.\n/ $ iperf3 -c 172.17.0.3\nConnecting to host 172.17.0.3, port 5201\n[  5] local 172.17.0.2 port 40722 connected to 172.17.0.3 port 5201\n[ ID] Interval           Transfer     Bitrate         Retr  Cwnd\n[  5]   0.00-1.00   sec   782 MBytes  6.56 Gbits/sec    0    269 KBytes\n[  5]   1.00-2.00   sec   772 MBytes  6.48 Gbits/sec    0    426 KBytes\n[  5]   2.00-3.00   sec   796 MBytes  6.68 Gbits/sec    0    426 KBytes\n[  5]   3.00-4.00   sec   784 MBytes  6.58 Gbits/sec  104    199 KBytes\n[  5]   4.00-5.00   sec   719 MBytes  6.02 Gbits/sec    6    197 KBytes\n[  5]   5.00-6.00   sec   775 MBytes  6.50 Gbits/sec    0    225 KBytes\n[  5]   6.00-7.00   sec   573 MBytes  4.81 Gbits/sec   53    269 KBytes\n[  5]   7.00-8.00   sec   821 MBytes  6.89 Gbits/sec    0    448 KBytes\n[  5]   8.00-9.00   sec   650 MBytes  5.44 Gbits/sec  376    218 KBytes\n[  5]   9.00-10.00  sec   815 MBytes  6.83 Gbits/sec    0    249 KBytes\n- - - - - - - - - - - - - - - - - - - - - - - - -\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-10.00  sec  7.31 GBytes  6.28 Gbits/sec  539             sender\n[  5]   0.00-10.00  sec  7.31 GBytes  6.28 Gbits/sec                  receiver\n\n```\n\n\n#### XDP status\n```\nXDP-action  \nXDP_ABORTED            0 pkts (         0 pps)           0 Kbytes (     0 Mbits/s) period:2.000435\nXDP_DROP               0 pkts (         0 pps)           0 Kbytes (     0 Mbits/s) period:2.000441\nXDP_PASS          659425 pkts (         0 pps)       43524 Kbytes (     0 Mbits/s) period:2.000438\nXDP_TX                 0 pkts (         0 pps)           0 Kbytes (     0 Mbits/s) period:2.000434\nXDP_REDIRECT           0 pkts (         0 pps)           0 Kbytes (     0 Mbits/s) period:2.000429\n```\n\n\n### 尝试关掉一些一些参数\n```\nroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/ff0a5996e2d2  ethtool  -K eth0 tso offroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/ff0a5996e2d2  ethtool  -K eth0 lro  offroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/1eebaa5a17b4 ethtool -K eth0 tso offroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/1eebaa5a17b4 ethtool -K eth0 lro  off\nroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/1eebaa5a17b4 ethtool -K eth0 gso  off\nroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/1eebaa5a17b4 ethtool -K eth0 gro  off\nroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/ff0a5996e2d2  ethtool  -K eth0 gso  offroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# nsenter --net=/var/run/docker/netns/ff0a5996e2d2  ethtool  -K eth0 gro  offroot@ubuntu-hirsute:~/withlin/xdp-tutorial/packet03-redirecting# \n\n```\n\n#### 总结\n\n\u003e 加速 加了个寂寞\n\nxdp在 veth pair 上会导致TSO 停止工作，数据包被线性化，导致TCP包在两个 veth之前吞吐量降低。该问题还在内核修复阶段，XDP_REDIRECT 在veth设备之间只会变的更慢。。。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithlin%2Fxdp-redirect-lab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwithlin%2Fxdp-redirect-lab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithlin%2Fxdp-redirect-lab/lists"}