File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ static BLOCKLIST_IPV4: HashMap<u32, [u16; MAX_RULES_PORT]> =
48
48
#[ no_mangle]
49
49
static TRAFFIC_DIRECTION : i32 = 0 ;
50
50
51
+ #[ no_mangle]
52
+ static PID_HELPER_AVAILABILITY : u8 = 0 ;
53
+
51
54
#[ classifier]
52
55
pub fn oryx ( ctx : TcContext ) -> i32 {
53
56
match process ( ctx) {
@@ -157,7 +160,13 @@ fn process(ctx: TcContext) -> Result<i32, ()> {
157
160
let pid = if is_ingress ( ) {
158
161
None
159
162
} else {
160
- Some ( ( bpf_get_current_pid_tgid ( ) >> 32 ) as u32 )
163
+ let pid_helper_available = unsafe { core:: ptr:: read_volatile ( & PID_HELPER_AVAILABILITY ) } ;
164
+
165
+ if pid_helper_available == 1 {
166
+ Some ( ( bpf_get_current_pid_tgid ( ) >> 32 ) as u32 )
167
+ } else {
168
+ None
169
+ }
161
170
} ;
162
171
163
172
match unsafe { ( * eth_header) . ether_type } {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use aya::{
10
10
include_bytes_aligned,
11
11
maps:: { Array , HashMap } ,
12
12
programs:: { tc, SchedClassifier , TcAttachType } ,
13
+ util:: KernelVersion ,
13
14
EbpfLoader ,
14
15
} ;
15
16
use log:: error;
@@ -29,6 +30,14 @@ use super::{
29
30
EbpfTrafficDirection , RingBuffer ,
30
31
} ;
31
32
33
+ fn is_pid_helper_available ( ) -> bool {
34
+ if let Ok ( current_version) = KernelVersion :: current ( ) {
35
+ current_version >= KernelVersion :: new ( 6 , 10 , 0 )
36
+ } else {
37
+ false
38
+ }
39
+ }
40
+
32
41
pub fn load_egress (
33
42
iface : String ,
34
43
notification_sender : kanal:: Sender < Event > ,
@@ -51,9 +60,12 @@ pub fn load_egress(
51
60
52
61
let traffic_direction = EbpfTrafficDirection :: Egress as i32 ;
53
62
63
+ let pid_helper_available = is_pid_helper_available ( ) as u8 ;
64
+
54
65
#[ cfg( debug_assertions) ]
55
66
let mut bpf = match EbpfLoader :: new ( )
56
67
. set_global ( "TRAFFIC_DIRECTION" , & traffic_direction, true )
68
+ . set_global ( "PID_HELPER_AVAILABILITY" , & pid_helper_available, false )
57
69
. load ( include_bytes_aligned ! ( env!( "ORYX_BIN_PATH" ) ) )
58
70
{
59
71
Ok ( v) => v,
You can’t perform that action at this time.
0 commit comments