Skip to content

Commit

Permalink
Added safety margin to hash table sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueCZ committed Sep 18, 2023
1 parent 7e026be commit 827421a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions include/dp_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
extern "C" {
#endif

#define FLOW_MAX (1*1024*1024UL)
// arbitrary big number
#define FLOW_MAX 850000

#define DP_FLOW_VAL_AGE_CTX_CAPACITY 5

Expand All @@ -32,11 +33,11 @@ extern "C" {
#define DP_IS_FLOW_STATUS_FLAG_NONE(flag) (!(flag))
#define DP_IS_FLOW_STATUS_FLAG_SRC_NAT(flag) ((flag) & DP_FLOW_STATUS_FLAG_SRC_NAT)
#define DP_IS_FLOW_STATUS_FLAG_DST_NAT(flag) ((flag) & DP_FLOW_STATUS_FLAG_DST_NAT)
#define DP_IS_FLOW_STATUS_FLAG_DST_LB(flag) ((flag) & DP_FLOW_STATUS_FLAG_DST_LB)
#define DP_IS_FLOW_STATUS_FLAG_DST_LB(flag) ((flag) & DP_FLOW_STATUS_FLAG_DST_LB)
#define DP_IS_FLOW_STATUS_FLAG_FIREWALL(flag) ((flag) & DP_FLOW_STATUS_FLAG_FIREWALL)
#define DP_IS_FLOW_STATUS_FLAG_DEFAULT(flag) ((flag) & DP_FLOW_STATUS_FLAG_DEFAULT)

#define DP_IS_FLOW_STATUS_FLAG_NF(flag) ((flag) & DP_FLOW_STATUS_FLAG_NF)
#define DP_IS_FLOW_STATUS_FLAG_NF(flag) ((flag) & DP_FLOW_STATUS_FLAG_NF)


enum {
Expand Down
5 changes: 4 additions & 1 deletion src/dp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#define DP_SYSFS_SUFFIX_MLX_VF_COUNT "/device/sriov_numvfs"
#define DP_SYSFS_MAX_PATH 256

// makes sure there is enough space to prevent collisions
#define DP_JHASH_MARGIN_COEF(ENTRIES) ((ENTRIES)*1.20)

int dp_get_dev_info(uint16_t port_id, struct rte_eth_dev_info *dev_info, char ifname[IFNAMSIZ])
{
int ret;
Expand Down Expand Up @@ -148,7 +151,7 @@ struct rte_hash *dp_create_jhash_table(int entries, size_t key_len, const char *

struct rte_hash_parameters params = {
.name = full_name,
.entries = entries,
.entries = DP_JHASH_MARGIN_COEF(entries),
.key_len = key_len,
.hash_func = hash_func,
.hash_func_init_val = 0xfee1900d, // "random" IV
Expand Down

0 comments on commit 827421a

Please sign in to comment.