• Home
Name Date Size #Lines LOC

..--

CMakeLists.txtD03-May-2024281 54

README.txtD03-May-20242 KiB4435

simulation.pyD03-May-20244.4 KiB11295

vlan_learning.cD03-May-20242 KiB6348

vlan_learning.pyD03-May-20243.7 KiB9769

README.txt

1This example shows a unique way to use a BPF program to demux any ethernet
2traffic into a pool of worker veth+namespaces (or any ifindex-based
3destination) depending on a configurable mapping of src-mac to ifindex. As
4part of the ingress processing, the program will dynamically learn the source
5ifindex of the matched source mac.
6
7Simulate a physical network with a vlan aware switch and clients that may
8connect to any vlan. The program will detect the known clients and pass the
9traffic through to a dedicated namespace for processing. Clients may have
10overlapping IP spaces and the traffic will still work.
11
12               |           bpf program                      |
13cli0 --|       |                            /--|-- worker0  |
14cli1 --| trunk | +->--->-handle_p2v(pkt)-> /---|-- worker1  |
15cli2 --|=======|=+                        /----|-- worker2  |
16...  --|       | +-<---<-handle_v2p(pkt)-<-----|--  ...     |
17cliN --|       |                          \----|-- workerM  |
18       |       |                              ^             |
19     phys      |                            veth            |
20    switch     |                                            |
21
22To run the example, simply:
23
24sudo /path/to/vlan_learning/vlan_learning.py
25
26Serving HTTP on 0.0.0.0 port 80 ...
27Serving HTTP on 0.0.0.0 port 80 ...
28Serving HTTP on 0.0.0.0 port 80 ...
29  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
30                                 Dload  Upload   Total   Spent    Left  Speed
31  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0172.16.1.100 - - [04/Nov/2015 10:54:47] "GET / HTTP/1.1" 200 -
32100   574  100   574    0     0  45580      0 --:--:-- --:--:-- --:--:-- 47833
33
34...
35
36Press enter to exit:
37mac 020000000000 rx pkts = 95, rx bytes = 7022
38                 tx pkts = 0, tx bytes = 0
39mac 020000000001 rx pkts = 95, rx bytes = 7022
40                 tx pkts = 0, tx bytes = 0
41mac 020000000002 rx pkts = 97, rx bytes = 7154
42                 tx pkts = 0, tx bytes = 0
43
44