Skip to content

Commit 685680c

Browse files
committed
fix sockops description error
1 parent fe5b53d commit 685680c

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/29-sockops/README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,32 +181,41 @@ sudo bpftool prog attach pinned /sys/fs/bpf/bpf_redir msg_verdict pinned /sys/fs
181181

182182
```console
183183
$ sudo bpftool prog show
184-
63: sock_ops name bpf_sockmap tag 275467be1d69253d gpl
184+
63: sock_ops name bpf_sockops_handler tag 275467be1d69253d gpl
185185
loaded_at 2019-01-24T13:07:17+0200 uid 0
186186
xlated 1232B jited 750B memlock 4096B map_ids 58
187187
64: sk_msg name bpf_redir tag bc78074aa9dd96f4 gpl
188188
loaded_at 2019-01-24T13:07:17+0200 uid 0
189189
xlated 304B jited 233B memlock 4096B map_ids 58
190190
```
191191

192-
### 运行 [iperf3](https://iperf.fr/) 服务器
192+
### 使用 iperf3 或 curl 进行测试
193+
194+
运行 [iperf3](https://iperf.fr/) 服务器
193195

194196
```shell
195197
iperf3 -s -p 5001
196198
```
197199

198-
### 运行 [iperf3](https://iperf.fr/) 客户端
200+
运行 [iperf3](https://iperf.fr/) 客户端
199201

200202
```shell
201203
iperf3 -c 127.0.0.1 -t 10 -l 64k -p 5001
202204
```
203205

206+
或者也可以用 Python 和 curl 进行测试:
207+
208+
```sh
209+
python3 -m http.server
210+
curl http://0.0.0.0:8000/
211+
```
212+
204213
### 收集追踪
205214

206215
查看``sock_ops``追踪本地连接建立
207216

208217
```console
209-
$ ./trace_bpf_output.sh
218+
$ ./trace_bpf_output.sh # 实际上就是 sudo cat /sys/kernel/debug/tracing/trace_pipe
210219
iperf3-9516 [001] .... 22500.634108: 0: <<< ipv4 op = 4, port 18583 --> 4135
211220
iperf3-9516 [001] ..s1 22500.634137: 0: <<< ipv4 op = 5, port 4135 --> 18583
212221
iperf3-9516 [001] .... 22500.634523: 0: <<< ipv4 op = 4, port 19095 --> 4135
@@ -215,10 +224,10 @@ iperf3-9516 [001] ..s1 22500.634536: 0: <<< ipv4 op = 5, port 4135 --> 19095
215224

216225
当iperf3 -c建立连接后,你应该可以看到上述用于套接字建立的事件。如果你没有看到任何事件,那么 eBPF 程序可能没有正确地附加上。
217226

218-
此外,当``sk_msg``生效后,可以发现当使用tcpdump捕捉本地lo设备流量时,只能捕获三次握手和四次挥手流量,而iperf数据流量没有被捕获到。如果捕获到iperf数据流量,那么 eBPF 程序可能没有正确地附加上。
227+
此外,当``sk_msg``生效后,可以发现当使用 tcpdump 捕捉本地lo设备流量时,只能捕获三次握手和四次挥手流量,而iperf数据流量没有被捕获到。如果捕获到iperf数据流量,那么 eBPF 程序可能没有正确地附加上。
219228

220229
```console
221-
$ ./trace_lo_traffic.sh # 实际上就是 sudo cat /sys/kernel/debug/tracing/trace_pipe
230+
$ ./trace_lo_traffic.sh # tcpdump -i lo port 5001
222231

223232
# 三次握手
224233
13:24:07.181804 IP localhost.46506 > localhost.5001: Flags [S], seq 620239881, win 65495, options [mss 65495,sackOK,TS val 1982813394 ecr 0,nop,wscale 7], length 0

src/29-sockops/README_en.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,35 @@ $ sudo bpftool prog show
189189
xlated 304B jited 233B memlock 4096B map_ids 58
190190
```
191191

192-
### Running the iperf3 Server
192+
### Test with iperf3 or curl
193+
194+
See <https://iperf.fr/> to install iperf3.
195+
196+
Running the iperf3 Server:
193197

194198
```shell
195199
iperf3 -s -p 5001
196200
```
197201

198-
### Running the iperf3 Client
202+
Running the iperf3 Client:
199203

200204
```shell
201205
iperf3 -c 127.0.0.1 -t 10 -l 64k -p 5001
202206
```
203207

208+
Or you can use curl and python:
209+
210+
```sh
211+
python3 -m http.server
212+
curl http://0.0.0.0:8000/
213+
```
214+
204215
### Collecting Traces
205216

206217
Check the `sock_ops` trace for local connection establishments.
207218

208219
```console
209-
$ ./trace_bpf_output.sh
220+
$ ./trace_bpf_output.sh # which is basically sudo cat /sys/kernel/debug/tracing/trace_pipe
210221
iperf3-9516 [001] .... 22500.634108: 0: <<< ipv4 op = 4, port 18583 --> 4135
211222
iperf3-9516 [001] ..s1 22500.634137: 0: <<< ipv4 op = 5, port 4135 --> 18583
212223
iperf3-9516 [001] .... 22500.634523: 0: <<< ipv4 op = 4, port 19095 --> 4135
@@ -218,7 +229,7 @@ When the connection is established between `iperf3 -c` and the server, you shoul
218229
Furthermore, when `sk_msg` takes effect, you should observe that when capturing local traffic on the loopback interface using tcpdump, only the three-way handshake and four-way termination traffic are captured, and the actual data flow of iperf is not captured. If the iperf data flow is captured, then the eBPF programs may not have been attached correctly.
219230

220231
```console
221-
$ ./trace_lo_traffic.sh # which is basically sudo cat /sys/kernel/debug/tracing/trace_pipe
232+
$ ./trace_lo_traffic.sh # tcpdump -i lo port 5001
222233

223234
# Three-way handshake
224235
13:24:07.181804 IP localhost.46506 > localhost.5001: Flags [S], seq 620239881, win 65495, options [mss 65495,sackOK,TS val 1982813394 ecr 0,nop,wscale 7], length 0

0 commit comments

Comments
 (0)