Home | History | Annotate | only in /external/bcc/examples/networking/vlan_learning
Up to higher level directory
NameDateSize
CMakeLists.txt22-Oct-2020281
README.txt22-Oct-20202K
simulation.py22-Oct-20204.4K
vlan_learning.c22-Oct-20202K
vlan_learning.py22-Oct-20203.7K

README.txt

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