mirror of
https://github.com/eunomia-bpf/bpf-developer-tutorial.git
synced 2026-11-01 21:24:12 +08:00
fix: address final tutorial portability review
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#ifndef __XDP_TCPDUMP_H
|
#ifndef XDP_TCPDUMP_H_
|
||||||
#define __XDP_TCPDUMP_H
|
#define XDP_TCPDUMP_H_
|
||||||
|
|
||||||
#define MAX_TCP_HEADER_BYTES 60
|
#define MAX_TCP_HEADER_BYTES 60
|
||||||
|
|
||||||
@@ -8,4 +8,4 @@ struct tcp_event {
|
|||||||
unsigned char header[MAX_TCP_HEADER_BYTES];
|
unsigned char header[MAX_TCP_HEADER_BYTES];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __XDP_TCPDUMP_H */
|
#endif /* XDP_TCPDUMP_H_ */
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ To run the XDP load balancer, execute the following command, specifying the inte
|
|||||||
To make XDP work with veth interfaces we need to add a stub eBPF program to the other end of the pair.
|
To make XDP work with veth interfaces we need to add a stub eBPF program to the other end of the pair.
|
||||||
|
|
||||||
```console
|
```console
|
||||||
clang -target bpf -I/usr/include/$(uname -m)-linux-gnu -o stub.bpf.o -c stub.bpf.c
|
clang -target bpf -I/usr/include/$(gcc -print-multiarch) -o stub.bpf.o -c stub.bpf.c
|
||||||
sudo ip l set dev veth7 xdp obj ./stub.bpf.o sec .xdp # stub XDP_PASS on the receiving interface
|
sudo ip l set dev veth7 xdp obj ./stub.bpf.o sec .xdp # stub XDP_PASS on the receiving interface
|
||||||
sudo ip netns exec lb ./xdp_lb veth6 10.0.0.2 de:ad:be:ef:00:02 10.0.0.3 de:ad:be:ef:00:03
|
sudo ip netns exec lb ./xdp_lb veth6 10.0.0.2 de:ad:be:ef:00:02 10.0.0.3 de:ad:be:ef:00:03
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ sudo ./teardown.sh
|
|||||||
要运行 XDP 负载均衡器,执行以下命令,指定接口和后端服务器的 IP 和 MAC 地址。为了让 XDP 在 veth 接口上工作,还需要在 veth 对的另一端挂载一个返回 `XDP_PASS` 的桩程序。
|
要运行 XDP 负载均衡器,执行以下命令,指定接口和后端服务器的 IP 和 MAC 地址。为了让 XDP 在 veth 接口上工作,还需要在 veth 对的另一端挂载一个返回 `XDP_PASS` 的桩程序。
|
||||||
|
|
||||||
```console
|
```console
|
||||||
clang -target bpf -I/usr/include/$(uname -m)-linux-gnu -o stub.bpf.o -c stub.bpf.c
|
clang -target bpf -I/usr/include/$(gcc -print-multiarch) -o stub.bpf.o -c stub.bpf.c
|
||||||
sudo ip l set dev veth7 xdp obj ./stub.bpf.o sec .xdp
|
sudo ip l set dev veth7 xdp obj ./stub.bpf.o sec .xdp
|
||||||
sudo ip netns exec lb ./xdp_lb veth6 10.0.0.2 de:ad:be:ef:00:02 10.0.0.3 de:ad:be:ef:00:03
|
sudo ip netns exec lb ./xdp_lb veth6 10.0.0.2 de:ad:be:ef:00:02 10.0.0.3 de:ad:be:ef:00:03
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user