summaryrefslogtreecommitdiff
path: root/infra
diff options
context:
space:
mode:
author童宗振 <[email protected]>2024-05-08 13:50:38 +0000
committer童宗振 <[email protected]>2024-05-08 13:50:38 +0000
commitcc85bda3340ba5aedea82050ce458fc145f8e064 (patch)
tree28afdc8c94b610d4ede808dcf35eb4f70f0332fc /infra
parent4e0614bfdd83e4eb3f7a39ef7fa5ab2514b2f0e7 (diff)
(TSG-21101)dp_trace uses traffic_link_id as a restrictionv4.8.6-20240508
Diffstat (limited to 'infra')
-rw-r--r--infra/src/dp_trace.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/infra/src/dp_trace.c b/infra/src/dp_trace.c
index 7b31559..eac9a07 100644
--- a/infra/src/dp_trace.c
+++ b/infra/src/dp_trace.c
@@ -196,6 +196,12 @@ int dp_trace_job_add(struct dp_trace_process * trace, const struct dp_trace_job_
ctx->desc.sampling = desc->sampling;
ctx->desc.snaplen = desc->snaplen;
+ ctx->desc.traffic_link_id_cnt = desc->traffic_link_id_cnt;
+ for (unsigned int i = 0; i < desc->traffic_link_id_cnt; i++)
+ {
+ ctx->desc.traffic_link_ids[i] = desc->traffic_link_ids[i];
+ }
+
ctx->used = true;
instance->nr_job_ctx++;
MR_INFO("[add job:%u] bpf_expr: %s type: %u", rule_index, ctx->desc.bpf_expr, ctx->desc.measurement_type);
@@ -239,11 +245,38 @@ uint16_t dp_trace_filter_exec_jobs_get(struct dp_trace_process * trace, struct r
for (unsigned int i = 0; i < DP_TRACE_JOB_NUM_MAX; i++)
{
ctx = &instance->job_ctx[i];
- if (ctx->used && (pcap_offline_filter(&ctx->fp, &header, pkt) != 0))
+ if (!ctx->used)
+ {
+ continue;
+ }
+
+ // compare traffic_link_id
+ uint8_t traffic_link_id_match = 0;
+ if (ctx->desc.traffic_link_id_cnt == 0)
+ {
+ traffic_link_id_match = 1;
+ }
+ else
+ {
+ for (unsigned j = 0; j < ctx->desc.traffic_link_id_cnt; j++)
+ {
+ if (mrb_meta->traffic_link_id == ctx->desc.traffic_link_ids[j])
+ {
+ traffic_link_id_match = 1;
+ break;
+ }
+ }
+ }
+
+ if (traffic_link_id_match == 0)
+ {
+ continue;
+ }
+
+ if ((pcap_offline_filter(&ctx->fp, &header, pkt) != 0))
{
- // When the maximum number of data packet records is reached, the tag will no longer be added to the data
- // packet.
- // unlimit: ctx->desc.pkt_cnt_max == 0
+ // When the maximum number of data packet records is reached, the tag will no longer be added to the
+ // data packet. unlimit: ctx->desc.pkt_cnt_max == 0
target_packet = true;
if (ctx->desc.pkt_cnt_max != 0 && statistics->filter_exec_hit[i] >= ctx->desc.pkt_cnt_max)
{