Skip to content

Commit 04fae80

Browse files
committed
feat: agent add syscall_trace_id_disabled
1 parent 78eed03 commit 04fae80

File tree

17 files changed

+201
-124
lines changed

17 files changed

+201
-124
lines changed

agent/src/config/config.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ pub struct EbpfYamlConfig {
404404
pub syscall_out_of_order_cache_size: usize,
405405
pub syscall_out_of_order_reassembly: Vec<String>,
406406
pub syscall_segmentation_reassembly: Vec<String>,
407+
pub syscall_trace_id_disabled: bool,
407408
}
408409

409410
impl Default for EbpfYamlConfig {
@@ -431,6 +432,7 @@ impl Default for EbpfYamlConfig {
431432
syscall_out_of_order_reassembly: vec![],
432433
syscall_segmentation_reassembly: vec![],
433434
syscall_out_of_order_cache_size: 16,
435+
syscall_trace_id_disabled: false,
434436
}
435437
}
436438
}
@@ -1412,8 +1414,7 @@ impl RuntimeConfig {
14121414
global_pps_threshold: 2000000,
14131415
#[cfg(target_os = "linux")]
14141416
extra_netns_regex: Default::default(),
1415-
tap_interface_regex: "^(tap.*|cali.*|veth.*|eth.*|en[ospx].*|lxc.*|lo|[0-9a-f]+_h)$"
1416-
.into(),
1417+
tap_interface_regex: "".into(),
14171418
host: Default::default(),
14181419
rsyslog_enabled: false,
14191420
output_vlan: 0,
@@ -1540,7 +1541,9 @@ impl RuntimeConfig {
15401541
)));
15411542
}
15421543

1543-
if regex::Regex::new(&self.tap_interface_regex).is_err() {
1544+
if !self.tap_interface_regex.is_empty()
1545+
&& regex::Regex::new(&self.tap_interface_regex).is_err()
1546+
{
15441547
return Err(ConfigError::RuntimeConfigInvalid(format!(
15451548
"malformed tap-interface-regex({})",
15461549
self.tap_interface_regex

agent/src/config/handler.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,6 +2324,13 @@ impl ConfigHandler {
23242324
callbacks.push(leaky_bucket_callback);
23252325
}
23262326

2327+
// FIXME: 仅做测试用
2328+
if new_config.dispatcher.tap_interface_regex
2329+
== "^(tap.*|cali.*|veth.*|eth.*|en[osipx].*|lxc.*|lo|[0-9a-f]+_h)$"
2330+
{
2331+
new_config.dispatcher.tap_interface_regex = "".to_string();
2332+
}
2333+
23272334
info!(
23282335
"dispatcher config change from {:#?} to {:#?}",
23292336
candidate_config.dispatcher, new_config.dispatcher

agent/src/dispatcher/analyzer_mode_dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl AnalyzerModeDispatcher {
282282
let mut output_batch = Vec::with_capacity(HANDLER_BATCH_SIZE);
283283
let mut flow_map = FlowMap::new(
284284
id as u32,
285-
flow_output_queue,
285+
Some(flow_output_queue),
286286
l7_stats_output_queue,
287287
policy_getter,
288288
log_output_queue,

agent/src/dispatcher/local_mode_dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl LocalModeDispatcher {
7878
}
7979
let mut flow_map = FlowMap::new(
8080
base.id as u32,
81-
base.flow_output_queue.clone(),
81+
Some(base.flow_output_queue.clone()),
8282
base.l7_stats_output_queue.clone(),
8383
base.policy_getter,
8484
base.log_output_queue.clone(),

agent/src/dispatcher/local_plus_mode_dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl LocalPlusModeDispatcher {
125125
let mut output_batch = Vec::with_capacity(HANDLER_BATCH_SIZE);
126126
let mut flow_map = FlowMap::new(
127127
id as u32,
128-
flow_output_queue,
128+
Some(flow_output_queue),
129129
l7_stats_output_queue,
130130
policy_getter,
131131
log_output_queue,

agent/src/dispatcher/mirror_mode_dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ impl MirrorModeDispatcher {
543543

544544
let mut flow_map = FlowMap::new(
545545
self.base.id as u32,
546-
self.base.flow_output_queue.clone(),
546+
Some(self.base.flow_output_queue.clone()),
547547
self.base.l7_stats_output_queue.clone(),
548548
self.base.policy_getter,
549549
self.base.log_output_queue.clone(),

agent/src/dispatcher/mirror_plus_mode_dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl MirrorPlusModeDispatcher {
301301
let mut batch = Vec::with_capacity(HANDLER_BATCH_SIZE);
302302
let mut flow_map = FlowMap::new(
303303
id as u32,
304-
flow_output_queue,
304+
Some(flow_output_queue),
305305
l7_stats_output_queue,
306306
policy_getter,
307307
log_output_queue,

agent/src/ebpf_dispatcher/ebpf_dispatcher.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::common::l7_protocol_log::{
3535
};
3636
use crate::common::meta_packet::{MetaPacket, SegmentFlags};
3737
use crate::common::proc_event::{BoxedProcEvents, EventType, ProcEvent};
38-
use crate::common::{FlowAclListener, FlowAclListenerId, TaggedFlow};
38+
use crate::common::{FlowAclListener, FlowAclListenerId};
3939
use crate::config::handler::{CollectorAccess, EbpfAccess, EbpfConfig, LogParserAccess};
4040
use crate::config::FlowAccess;
4141
use crate::ebpf;
@@ -221,8 +221,7 @@ struct EbpfDispatcher {
221221

222222
config: EbpfAccess,
223223
output: DebugSender<Box<AppProto>>, // Send AppProtos to the AppProtoLogsParser
224-
flow_output: DebugSender<Arc<BatchedBox<TaggedFlow>>>, // Send TaggedFlows to the QuadrupleGenerator
225-
l7_stats_output: DebugSender<BatchedBox<L7Stats>>, // Send L7Stats to the QuadrupleGenerator
224+
l7_stats_output: DebugSender<BatchedBox<L7Stats>>, // Send L7Stats to the QuadrupleGenerator
226225
stats_collector: Arc<stats::Collector>,
227226
}
228227

@@ -323,7 +322,7 @@ impl EbpfDispatcher {
323322
);
324323
let mut flow_map = FlowMap::new(
325324
self.dispatcher_id as u32,
326-
self.flow_output.clone(),
325+
None,
327326
self.l7_stats_output.clone(),
328327
self.policy_getter,
329328
self.output.clone(),
@@ -692,6 +691,10 @@ impl EbpfCollector {
692691
}
693692
}
694693

694+
if config.ebpf.syscall_trace_id_disabled {
695+
ebpf::disable_syscall_trace_id();
696+
}
697+
695698
if ebpf::running_socket_tracer(
696699
Self::ebpf_l7_callback, /* 回调接口 rust -> C */
697700
config.ebpf.thread_num as i32, /* 工作线程数,是指用户态有多少线程参与数据处理 */
@@ -861,7 +864,6 @@ impl EbpfCollector {
861864
collector_config: CollectorAccess,
862865
policy_getter: PolicyGetter,
863866
output: DebugSender<Box<AppProto>>,
864-
flow_output: DebugSender<Arc<BatchedBox<TaggedFlow>>>,
865867
l7_stats_output: DebugSender<BatchedBox<L7Stats>>,
866868
proc_event_output: DebugSender<BoxedProcEvents>,
867869
ebpf_profile_sender: DebugSender<Profile>,
@@ -907,7 +909,6 @@ impl EbpfCollector {
907909
config,
908910
log_parser_config,
909911
output,
910-
flow_output,
911912
l7_stats_output,
912913
flow_map_config,
913914
stats_collector,

agent/src/flow_generator/flow_map.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub struct FlowMap {
175175

176176
tagged_flow_allocator: Allocator<TaggedFlow>,
177177
l7_stats_allocator: Allocator<L7Stats>,
178-
output_queue: DebugSender<Arc<BatchedBox<TaggedFlow>>>,
178+
output_queue: Option<DebugSender<Arc<BatchedBox<TaggedFlow>>>>,
179179
l7_stats_output_queue: DebugSender<BatchedBox<L7Stats>>,
180180
out_log_queue: DebugSender<Box<AppProto>>,
181181
output_buffer: Vec<Arc<BatchedBox<TaggedFlow>>>,
@@ -211,7 +211,7 @@ pub struct FlowMap {
211211
impl FlowMap {
212212
pub fn new(
213213
id: u32,
214-
output_queue: DebugSender<Arc<BatchedBox<TaggedFlow>>>,
214+
output_queue: Option<DebugSender<Arc<BatchedBox<TaggedFlow>>>>,
215215
l7_stats_output_queue: DebugSender<BatchedBox<L7Stats>>,
216216
policy_getter: PolicyGetter,
217217
app_proto_log_queue: DebugSender<Box<AppProto>>,
@@ -1837,8 +1837,13 @@ impl FlowMap {
18371837
self.l7_stats_buffer.clear();
18381838
}
18391839
}
1840-
if self.output_buffer.len() > 0 {
1841-
if let Err(e) = self.output_queue.send_all(&mut self.output_buffer) {
1840+
if self.output_queue.is_some() && self.output_buffer.len() > 0 {
1841+
if let Err(e) = self
1842+
.output_queue
1843+
.as_ref()
1844+
.unwrap()
1845+
.send_all(&mut self.output_buffer)
1846+
{
18421847
warn!(
18431848
"flow-map push tagged flows to queue failed, because {:?}",
18441849
e
@@ -1866,14 +1871,21 @@ impl FlowMap {
18661871
Ordering::Relaxed,
18671872
);
18681873

1869-
self.output_buffer.push(tagged_flow);
1870-
if self.output_buffer.len() >= QUEUE_BATCH_SIZE {
1871-
if let Err(e) = self.output_queue.send_all(&mut self.output_buffer) {
1872-
warn!(
1873-
"flow-map push tagged flows to queue failed, because {:?}",
1874-
e
1875-
);
1876-
self.output_buffer.clear();
1874+
if self.output_queue.is_some() {
1875+
self.output_buffer.push(tagged_flow);
1876+
if self.output_buffer.len() >= QUEUE_BATCH_SIZE {
1877+
if let Err(e) = self
1878+
.output_queue
1879+
.as_ref()
1880+
.unwrap()
1881+
.send_all(&mut self.output_buffer)
1882+
{
1883+
warn!(
1884+
"flow-map push tagged flows to queue failed, because {:?}",
1885+
e
1886+
);
1887+
self.output_buffer.clear();
1888+
}
18771889
}
18781890
}
18791891
}
@@ -2505,7 +2517,7 @@ pub fn _new_flow_map_and_receiver(
25052517
config.flow.trident_type = trident_type;
25062518
let flow_map = FlowMap::new(
25072519
0,
2508-
output_queue_sender,
2520+
Some(output_queue_sender),
25092521
l7_stats_output_queue_sender,
25102522
policy_getter,
25112523
app_proto_log_queue,

agent/src/flow_generator/protocol_logs/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ impl MetaAppProto {
244244
}
245245

246246
Some(Self {
247-
base_info,
248247
direction: meta_packet.lookup_key.direction,
248+
base_info,
249249
direction_score: flow.flow.direction_score,
250250
l7_info,
251251
})

0 commit comments

Comments
 (0)