From 86bdbf04ab651d34a4d3f36a6168e21d86fee9c4 Mon Sep 17 00:00:00 2001 From: Charles Han Date: Wed, 18 Oct 2023 11:12:30 +0800 Subject: [PATCH 1/3] Fix: kvmexittime tools structure definition conflict on kernel 5.10 --- .../tools/detect/virt/kvmexittime/bpf/kvmexittime.bpf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/tools/detect/virt/kvmexittime/bpf/kvmexittime.bpf.c b/source/tools/detect/virt/kvmexittime/bpf/kvmexittime.bpf.c index 69c024ad..9bf4849e 100644 --- a/source/tools/detect/virt/kvmexittime/bpf/kvmexittime.bpf.c +++ b/source/tools/detect/virt/kvmexittime/bpf/kvmexittime.bpf.c @@ -26,12 +26,12 @@ struct { __type(value, struct kvm_exit_time); } counts SEC(".maps"); -struct trace_event_raw_kvm_entry { +struct sysak_trace_event_raw_kvm_entry { struct trace_entry ent; unsigned int vcpu_id; }; -struct trace_event_raw_kvm_exit { +struct sysak_trace_event_raw_kvm_exit { struct trace_entry ent; unsigned int exit_reason; unsigned long guest_rip; @@ -65,7 +65,7 @@ bool filter(u32 tgid, u32 pid) } SEC("tp/kvm/kvm_exit") -int handle__kvm_exit(struct trace_event_raw_kvm_exit *ctx) { +int handle__kvm_exit(struct sysak_trace_event_raw_kvm_exit *ctx) { u64 current; u32 pid, tgid; struct kvm_exit_timestamps *ts, zero = {.kvm_exit_timestamp=0, .exit_reason=0}; @@ -92,7 +92,7 @@ int handle__kvm_exit(struct trace_event_raw_kvm_exit *ctx) { } SEC("tp/kvm/kvm_entry") -int handle__kvm_entry(struct trace_event_raw_kvm_entry *ctx) { +int handle__kvm_entry(struct sysak_trace_event_raw_kvm_entry *ctx) { u64 current; u32 pid, tgid; struct kvm_exit_timestamps *ts; -- Gitee From 1e53523e47a9fd891a4457385297cf5ff050c2f1 Mon Sep 17 00:00:00 2001 From: Charles Han Date: Wed, 18 Oct 2023 19:46:31 +0800 Subject: [PATCH 2/3] Fix: Pingtrace: Limit input parameters --- .../net/PingTrace/src/common/options.hpp | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/source/tools/detect/net/PingTrace/src/common/options.hpp b/source/tools/detect/net/PingTrace/src/common/options.hpp index d59ac148..ac926eb1 100644 --- a/source/tools/detect/net/PingTrace/src/common/options.hpp +++ b/source/tools/detect/net/PingTrace/src/common/options.hpp @@ -118,6 +118,32 @@ struct options { try { app.parse(argc, argv); + + if (this->max_count == 0) { + std::cout<< "-C, --count Only the integer bigger than 0 is valid." <interval_us == 0) { + std::cout<< "-i Only the integer bigger than 0 is valid." <runtime == 0) { + std::cout<< "-t Only the integer bigger than 0 is valid." <log_max_size == 0) { + std::cout<< "--logsize Only the integer bigger than 0 is valid." <log_max_backup == 0) { + std::cout<< "--logbackup Only the integer bigger than 0 is valid." <ip.empty()) this->run_client = true; if (this->help || (!this->run_client && !this->run_server)) @@ -139,4 +165,4 @@ struct options { }; // namespace pingtrace -#endif \ No newline at end of file +#endif -- Gitee From 2bff754e2d434fd8e95c5936b0c82d2a318d643b Mon Sep 17 00:00:00 2001 From: Charles Han Date: Wed, 18 Oct 2023 20:01:00 +0800 Subject: [PATCH 3/3] Fix: sysmonitor limit input paramter -m --- .../detect/sched/sysmonitor/sysmonitor.sh | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/source/tools/detect/sched/sysmonitor/sysmonitor.sh b/source/tools/detect/sched/sysmonitor/sysmonitor.sh index 19084ae7..89a56e54 100755 --- a/source/tools/detect/sched/sysmonitor/sysmonitor.sh +++ b/source/tools/detect/sched/sysmonitor/sysmonitor.sh @@ -35,6 +35,23 @@ monitor() { done } +validate_option_m() { + local input=$1 + + if [[ $input =~ ^[0-9]+([.][0-9]+)?$ ]]; then + if (( $(bc <<< "$input >= 0 && $input <= 100") == 1 )); then + return 0 + else + echo "Only the range of 0 to 100 is valid in: -m " + return 1 + fi + else + echo "Only the positive integer or floating-point number is valid in: -m " + return 1 + fi +} + + while getopts 'm:f:c:i:lh' OPT; do case $OPT in "h") @@ -42,7 +59,11 @@ while getopts 'm:f:c:i:lh' OPT; do exit 0 ;; "m") - maxsys=$OPTARG + if validate_option_m $OPTARG; then + maxsys=$OPTARG + else + exit 1 + fi ;; "f") datafile=$OPTARG -- Gitee