Update session timeouts
This commit is contained in:
@@ -112,7 +112,6 @@ struct ip_reassembly
|
||||
bool enable;
|
||||
uint32_t timeout;
|
||||
uint32_t bucket_entries;
|
||||
uint32_t bucket_num;
|
||||
|
||||
// runtime
|
||||
uint32_t entry_used;
|
||||
@@ -187,7 +186,7 @@ static inline int is_power_of_2(uint32_t n)
|
||||
return n && !(n & (n - 1));
|
||||
}
|
||||
|
||||
static inline int ip_reassembly_check_options(const struct ip_reassembly_options *opts)
|
||||
static int check_options(const struct ip_reassembly_options *opts)
|
||||
{
|
||||
if (opts == NULL)
|
||||
{
|
||||
@@ -197,21 +196,21 @@ static inline int ip_reassembly_check_options(const struct ip_reassembly_options
|
||||
|
||||
if (opts->enable)
|
||||
{
|
||||
if (opts->timeout == 0)
|
||||
if (opts->timeout < 1 || opts->timeout > 60000)
|
||||
{
|
||||
IP_REASSEMBLE_DEBUG("invalid timeout");
|
||||
IP_REASSEMBLE_DEBUG("invalid timeout: %u, supported range: [1, 60000]", opts->timeout);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (opts->bucket_entries == 0 || is_power_of_2(opts->bucket_entries) == 0)
|
||||
if (opts->bucket_entries < 1 || opts->bucket_entries > 256 || is_power_of_2(opts->bucket_entries) == 0)
|
||||
{
|
||||
IP_REASSEMBLE_DEBUG("invalid bucket entries, must be power of 2");
|
||||
IP_REASSEMBLE_DEBUG("invalid bucket_entries: %u, supported range: [1, 256] (must be power of 2)", opts->bucket_entries);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (opts->bucket_num == 0)
|
||||
{
|
||||
IP_REASSEMBLE_DEBUG("invalid bucket num");
|
||||
IP_REASSEMBLE_DEBUG("invalid bucket_num: %u, supported range: [1, 4294967295]", opts->bucket_num);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -751,7 +750,7 @@ error_out_overlap:
|
||||
|
||||
struct ip_reassembly *ip_reassembly_new(const struct ip_reassembly_options *opts)
|
||||
{
|
||||
if (ip_reassembly_check_options(opts) != 0)
|
||||
if (check_options(opts) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -765,14 +764,13 @@ struct ip_reassembly *ip_reassembly_new(const struct ip_reassembly_options *opts
|
||||
assy->enable = opts->enable;
|
||||
assy->timeout = opts->timeout;
|
||||
assy->bucket_entries = opts->bucket_entries;
|
||||
assy->bucket_num = opts->bucket_num;
|
||||
|
||||
if (!assy->enable)
|
||||
{
|
||||
return assy;
|
||||
}
|
||||
|
||||
uint64_t entry_total = align32pow2(assy->bucket_num) * assy->bucket_entries * IP_FRAG_HASH_FNUM;
|
||||
uint64_t entry_total = align32pow2(opts->bucket_num) * assy->bucket_entries * IP_FRAG_HASH_FNUM;
|
||||
if (entry_total > UINT32_MAX)
|
||||
{
|
||||
IP_REASSEMBLE_ERROR("bucket_num * bucket_entries is too large");
|
||||
|
||||
Reference in New Issue
Block a user