Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Src div0 5920 v4 #9253

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,10 @@ void FlowInitConfig(bool quiet)
FatalError("Invalid value for flow.hash-size: NULL");
}

if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
if (StringParseUint32(&configval, 10, strlen(conf_val), conf_val) > 0 || configval == 0) {
flow_config.hash_size = configval;
} else {
FatalError("Invalid value for flow.hash-size");
}
}
if ((ConfGet("flow.prealloc", &conf_val)) == 1)
Expand Down
6 changes: 6 additions & 0 deletions src/source-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,18 @@ static void DPDKFreeMbufArray(struct rte_mbuf **mbuf_array, uint16_t mbuf_cnt, u
static uint64_t CyclesToMicroseconds(const uint64_t cycles)
{
const uint64_t ticks_per_us = rte_get_tsc_hz() / 1000000;
if (ticks_per_us == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukashino is this necessary? Or can rte_get_tsc_hz return < 1000000?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be possible only when:

  • the CPU would have a clock rate less than 100MHz
  • the CPU would not be well supported by DPDK and some register would return 0/random number instead ticks per second

So, assuming every CPU has a clock rate of at least 800MHz, and we will not care about unsupported CPUs then it should be fine even without the check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks, I feel it's probably safer to keep the check

return 0;
}
return cycles / ticks_per_us;
}

static uint64_t CyclesToSeconds(const uint64_t cycles)
{
const uint64_t ticks_per_s = rte_get_tsc_hz();
if (ticks_per_s == 0) {
return 0;
}
return cycles / ticks_per_s;
}

Expand Down
6 changes: 4 additions & 2 deletions src/source-windivert.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ static SCTime_t WinDivertTimestampToTimeStamp(WinDivertThreadVars *wd_tv, INT64
struct timeval tv;

int64_t qpc_delta = (int64_t)timestamp_count - wd_tv->qpc_start_count;
int64_t unix_usec =
wd_tv->qpc_start_time + (qpc_delta / wd_tv->qpc_freq_usec);
int64_t unix_usec = wd_tv->qpc_start_time;
if (wd_tv->qpc_freq_usec) {
unix_usec += qpc_delta / wd_tv->qpc_freq_usec;
}

tv.tv_sec = (long)(unix_usec / (1000 * 1000));
tv.tv_usec = (long)(unix_usec - (int64_t)tv.tv_sec * (1000 * 1000));
Expand Down
14 changes: 8 additions & 6 deletions src/util-pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,14 @@ void PoolReturn(Pool *p, void *data)

void PoolPrintSaturation(Pool *p)
{
SCLogDebug("pool %p is using %" PRIu32 " out of %" PRIu32 " items (%02.1f%%), max %" PRIu32
" (%02.1f%%): pool struct memory %" PRIu64 ".",
p, p->outstanding, p->max_buckets,
(float)(p->outstanding) / (float)(p->max_buckets) * 100, p->max_outstanding,
(float)(p->max_outstanding) / (float)(p->max_buckets) * 100,
(uint64_t)(p->max_buckets * sizeof(PoolBucket)));
if (p->max_buckets > 0) {
SCLogDebug("pool %p is using %" PRIu32 " out of %" PRIu32 " items (%02.1f%%), max %" PRIu32
" (%02.1f%%): pool struct memory %" PRIu64 ".",
p, p->outstanding, p->max_buckets,
(float)(p->outstanding) / (float)(p->max_buckets) * 100, p->max_outstanding,
(float)(p->max_outstanding) / (float)(p->max_buckets) * 100,
(uint64_t)(p->max_buckets * sizeof(PoolBucket)));
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/util-profiling-prefilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void DoDump(SCProfilePrefilterDetectCtx *rules_ctx, FILE *fp, const char
avgticks = (double)(ticks / d->called);
}
double avgbytes = 0;
if (d->total_bytes && d->called) {
if (d->total_bytes && d->bytes_called) {
avgbytes = (double)(d->total_bytes / d->bytes_called);
}
double ticks_per_byte = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/util-profiling-rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ static void *SCProfilingRuleDump(SCProfileDetectCtx *rules_ctx, int file_output)
summary[i].ticks = rules_ctx->data[i].ticks_match + rules_ctx->data[i].ticks_no_match;
summary[i].checks = rules_ctx->data[i].checks;

if (summary[i].ticks > 0) {
if (summary[i].checks > 0) {
summary[i].avgticks = (long double)summary[i].ticks / (long double)summary[i].checks;
}

Expand Down
Loading