Skip to content

Instantly share code, notes, and snippets.

@astoycos
Last active March 7, 2024 06:52
Show Gist options
  • Save astoycos/646e60677ff89d56ea560b82888526ce to your computer and use it in GitHub Desktop.
Save astoycos/646e60677ff89d56ea560b82888526ce to your computer and use it in GitHub Desktop.
First Round Proxy Testing (proxy + sk_msg)
Using Socket proxy from -> https://github.com/astoycos/netns-proxy
Native Socket redirction from -> https://github.com/astoycos/net-ebpf-playground/tree/demo/socket-redirection
1. No bpf redirection
```
[astoycos@localhost net-ebpf-playground]$ iperf3 -4 -c 192.168.122.91 -p 8789
Connecting to host 192.168.122.91, port 8789
[ 5] local 192.168.122.1 port 58868 connected to 192.168.122.91 port 8789
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 47.6 MBytes 399 Mbits/sec 0 290 KBytes
[ 5] 1.00-2.00 sec 46.5 MBytes 390 Mbits/sec 0 290 KBytes
[ 5] 2.00-3.00 sec 49.2 MBytes 413 Mbits/sec 0 290 KBytes
[ 5] 3.00-4.00 sec 48.2 MBytes 404 Mbits/sec 0 290 KBytes
[ 5] 4.00-5.00 sec 44.4 MBytes 372 Mbits/sec 0 290 KBytes
[ 5] 5.00-6.00 sec 48.4 MBytes 406 Mbits/sec 0 290 KBytes
[ 5] 6.00-7.00 sec 48.7 MBytes 408 Mbits/sec 0 290 KBytes
[ 5] 7.00-8.00 sec 45.1 MBytes 378 Mbits/sec 0 290 KBytes
[ 5] 8.00-9.00 sec 46.0 MBytes 386 Mbits/sec 0 290 KBytes
[ 5] 9.00-10.00 sec 46.2 MBytes 387 Mbits/sec 0 290 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 470 MBytes 394 Mbits/sec 0 sender
[ 5] 0.00-10.00 sec 468 MBytes 393 Mbits/sec receiver
iperf Done.
```
2. Super Niave (Redirection from External socket -> Proxy Socket AND Proxy Socket -> Container Socket)
```
[astoycos@localhost net-ebpf-playground]$ iperf3 -4 -c 192.168.122.91 -p 8789
Connecting to host 192.168.122.91, port 8789
[ 5] local 192.168.122.1 port 45662 connected to 192.168.122.91 port 8789
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 123 MBytes 1.03 Gbits/sec 0 250 KBytes
[ 5] 1.00-2.00 sec 133 MBytes 1.12 Gbits/sec 0 250 KBytes
[ 5] 2.00-3.00 sec 126 MBytes 1.05 Gbits/sec 0 250 KBytes
[ 5] 3.00-4.00 sec 133 MBytes 1.11 Gbits/sec 0 250 KBytes
[ 5] 4.00-5.00 sec 133 MBytes 1.12 Gbits/sec 0 263 KBytes
[ 5] 5.00-6.00 sec 132 MBytes 1.11 Gbits/sec 0 277 KBytes
[ 5] 6.00-7.00 sec 130 MBytes 1.09 Gbits/sec 0 277 KBytes
[ 5] 7.00-8.00 sec 125 MBytes 1.05 Gbits/sec 0 277 KBytes
[ 5] 8.00-9.00 sec 133 MBytes 1.11 Gbits/sec 0 277 KBytes
[ 5] 9.00-10.00 sec 130 MBytes 1.09 Gbits/sec 0 277 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 1.27 GBytes 1.09 Gbits/sec 0 sender
[ 5] 0.00-10.00 sec 1.26 GBytes 1.08 Gbits/sec receiver
iperf Done.
```
3. A bit smarter (proxy listening socket -> server Socket)?
TODO (Not sure if this is worth it)
EDIT Not worth it, stick with below flow for now :)
DataFLOW
Traffic enters via Ports 8789 <nodeport>
Three main sockets are created/involved
1. Local -> <nodeIP>:<NodePort> Remote ++++ <NodeGW>:<Random Client Port> [Root Net NS] (Fake bound socket)
- Recieves traffic from remote client
- Sendmsg occurs here for response (No accleration)
2. Local -> <NodeIP>:<Random Port> ++++ Remote -> <PodIP>:<Random Port**> [Root Net NS] (Client Socket)
- Data is copied from 1 to here and then sent to 3
- Sendmsg occurs here for first send (Accleration occurs)
3. Local -> <PodIP>:<Sever Port> ++++ Remote -> <nodeIP>:<Random Port**> [Pod Net Ns] (Destination server socket)
- Sendmsg occurs here for response (Accleration occurs)
Open Question.... for the msg forwarding can we skip 2. and forward directly on ingress path to 3 With an Sk_SKB program?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment