@@ -3,6 +3,18 @@ use aya_ebpf::{
33 maps:: { LruPerCpuHashMap , PerfEventArray , HashMap } ,
44} ;
55
6+ // docs:
7+ // PacketLog structure used to track an incoming network packet
8+ //
9+ // proto: packet protol (ex. TCP,UDP,ICMP)
10+ // src_ip: source address ip
11+ // src_port: source address port
12+ // dst_ip: destination ip
13+ // dst_port: destination port
14+ // pid: kernel process ID
15+ //
16+
17+
618#[ repr( C ) ]
719#[ derive( Clone , Copy ) ]
820pub struct PacketLog {
@@ -14,7 +26,7 @@ pub struct PacketLog {
1426 pub pid : u32 ,
1527}
1628
17- // This structure is only for active connections
29+ // This structure is only for active connections (TODO: investigate if this is really useful)
1830#[ repr( C ) ]
1931#[ derive( Clone , Copy ) ]
2032pub struct ConnArray {
@@ -25,26 +37,50 @@ pub struct ConnArray {
2537 pub proto : u8 ,
2638}
2739
40+
41+ // docs:
42+ // VethLog structure used to track virtual ethernet interfaces creation and deletion
43+ //
44+ // name: veth name
45+ // state: socket state
46+ // dev_addr: veth device addresses
47+ // event_type: creation or deletion
48+ // netns: veth network namespace
49+ // pid: kernel process ID
50+ //
51+
2852#[ repr( C ) ]
2953#[ derive( Clone , Copy , Debug ) ]
3054pub struct VethLog {
3155 pub name : [ u8 ; 16 ] ,
32- pub state : u64 , //state var type: long unsigned int
56+ pub state : u64 , // state var type: long unsigned int
3357 pub dev_addr : [ u32 ; 8 ] ,
34- pub event_type : u8 , //i choose 1 for veth creation or 2 for veth destruction
58+ pub event_type : u8 , // i choose 1 for veth creation or 2 for veth destruction
3559 pub netns : u32 ,
3660 pub pid : u32
3761
3862}
3963
64+ // docs:
65+ //
66+ // BPF maps used in the conntracker programs
67+ //
68+ // VETH_EVENTS: PerfEventArray used in the veth_tracer functions (veth_tracer.rs module)
69+ //
70+ // BLOCKLIST: an hashmap used to block addresses -----> TODO: key and values are the same for semplicity but we need to
71+ // investigate the possibility to save the service name or the timestamp registered when the command was executed or a simple int index
72+ //
73+
74+
4075#[ map( name = "EventsMap" , pinning = "by_name" ) ]
4176pub static mut EVENTS : PerfEventArray < PacketLog > = PerfEventArray :: new ( 0 ) ;
4277
43- //TODO: ConnectionMap needs a rework after implementing issue #105
78+ // FIXME: this might be useless
4479#[ map( name = "ConnectionMap" ) ]
4580pub static mut ACTIVE_CONNECTIONS : LruPerCpuHashMap < u16 , ConnArray > =
4681 LruPerCpuHashMap :: with_max_entries ( 65536 , 0 ) ;
4782
83+ // FIXME: this might be useless
4884#[ map( name = "ConnectionTrackerMap" ) ]
4985pub static mut CONNTRACKER : LruPerCpuHashMap < ConnArray , u8 > =
5086 LruPerCpuHashMap :: with_max_entries ( 65536 , 0 ) ;
0 commit comments