@@ -21,7 +21,7 @@ use std::sync::Arc;
2121use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
2222use std:: task:: { Context , Poll } ;
2323
24- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
24+ #[ cfg( feature = "ebpf" ) ]
2525use anyhow:: anyhow;
2626use async_trait:: async_trait;
2727use bytes:: Bytes ;
@@ -32,11 +32,12 @@ use smallvec::SmallVec;
3232use tokio:: net:: UdpSocket ;
3333use tokio:: runtime:: Handle ;
3434use tokio:: sync:: { broadcast, mpsc} ;
35+ #[ cfg( feature = "ebpf" ) ]
3536use tokio:: time:: Instant ;
3637
3738use vey_io_ext:: { UdpMoveRecv , UdpMoveSend , UdpSocketExt } ;
3839use vey_io_sys:: udp:: { RecvMsgHdr , SendMsgHdr } ;
39- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
40+ #[ cfg( feature = "ebpf" ) ]
4041use vey_reuseport:: udp:: { UdpSocketSelectGuard , UdpSocketSelector } ;
4142use vey_socket:: RawSocket ;
4243use vey_types:: acl:: { AclAction , AclNetworkRule } ;
@@ -434,7 +435,7 @@ pub struct ListenUdpRuntime<S> {
434435 conn_track : UdpConnectionTrackConfig ,
435436 packet_max_size : u16 ,
436437 listen_stats : Arc < ListenStats > ,
437- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
438+ #[ cfg( feature = "ebpf" ) ]
438439 socket_selector : Option < UdpSocketSelector > ,
439440}
440441
@@ -455,7 +456,7 @@ where
455456 conn_track,
456457 packet_max_size,
457458 listen_stats,
458- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
459+ #[ cfg( feature = "ebpf" ) ]
459460 socket_selector : None ,
460461 }
461462 }
@@ -532,7 +533,7 @@ where
532533 listen_in_worker,
533534 instance_id : id,
534535 ingress_net_filter : None ,
535- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
536+ #[ cfg( feature = "ebpf" ) ]
536537 _bpf_guard : None ,
537538 _alive_guard : None ,
538539
@@ -554,7 +555,7 @@ where
554555 }
555556 }
556557
557- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
558+ #[ cfg( feature = "ebpf" ) ]
558559 if self
559560 . listen_config
560561 . use_ebpf ( rustix:: process:: getuid ( ) . as_raw ( ) )
@@ -589,15 +590,15 @@ where
589590
590591 let mut runtime = self . create_instance ( i, listen_addr, listen_in_worker) ;
591592 runtime. ingress_net_filter = ingress_net_filter. cloned ( ) ;
592- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
593+ #[ cfg( feature = "ebpf" ) ]
593594 if let Some ( selector) = & mut self . socket_selector {
594595 let guard = selector. add_socket ( RawSocket :: from ( & socket) ) ;
595596 runtime. _bpf_guard = Some ( guard) ;
596597 }
597598 runtime. into_running ( socket, server_reload_sender. subscribe ( ) ) ;
598599 }
599600
600- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
601+ #[ cfg( feature = "ebpf" ) ]
601602 if let Some ( mut selector) = self . socket_selector . take ( ) {
602603 if let Err ( e) = selector. load_and_attach ( ) {
603604 if self . listen_config . fail_on_ebpf_error ( ) {
@@ -639,7 +640,7 @@ struct ListenUdpRuntimeInstance<S> {
639640 listen_in_worker : bool ,
640641 instance_id : usize ,
641642 ingress_net_filter : Option < Arc < AclNetworkRule > > ,
642- #[ cfg( all ( target_os = "linux" , feature = "ebpf" ) ) ]
643+ #[ cfg( feature = "ebpf" ) ]
643644 _bpf_guard : Option < UdpSocketSelectGuard > ,
644645 _alive_guard : Option < ListenAliveGuard > ,
645646
0 commit comments