Skip to contentSkip to conversation

conntrackd: set default hashtable buckets and max entries if not specified

PATCH In review Pablo Neira Ayuso 2 participants 3 messages Mar 8, 2021 – Mar 9, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 conntrackd: set default hashtable buckets and max entries if not specified

Fall back to 65536 buckets and 262144 entries.

It would be probably good to add code to autoadjust by reading /proc/sys/net/netfilter/nf_conntrack_buckets and /proc/sys/net/nf_conntrack_max.

---
 src/read_config_yy.y | 6 ++++++
 1 file changed, 6 insertions(+)
src/read_config_yy.y +6 -0
index 31109c4de042..b215a729b716 100644
@@ -1780,5 +1780,11 @@ init_config(char *filename)
 					 NF_NETLINK_CONNTRACK_DESTROY;
 	}
 
+	/* default hashtable buckets and maximum number of entries */
+	if (!CONFIG(hashsize))
+		CONFIG(hashsize) = 65536;
+	if (!CONFIG(limit))
+		CONFIG(limit) = 262144;
+
 	return 0;
 }
Signature · 1 line
2.20.1
#1 lore raw
Quoted 6 lines · Pablo Neira Ayuso

Fall back to 65536 buckets and 262144 entries.

It would be probably good to add code to autoadjust by reading /proc/sys/net/netfilter/nf_conntrack_buckets and /proc/sys/net/nf_conntrack_max.

Quoted 6 lines
---
  src/read_config_yy.y | 6 ++++++
  1 file changed, 6 insertions(+)

Thanks for the patch!

Would it make sense to have all this logic in evaluate() in src/run.c?

author maintainer
#2 lore raw
Quoted 14 lines · Arturo Borrero Gonzalez
Quoted 6 lines · Pablo Neira Ayuso

Fall back to 65536 buckets and 262144 entries.

It would be probably good to add code to autoadjust by reading /proc/sys/net/netfilter/nf_conntrack_buckets and /proc/sys/net/nf_conntrack_max.

Quoted 6 lines
---
  src/read_config_yy.y | 6 ++++++
  1 file changed, 6 insertions(+)
Quoted 3 lines

Thanks for the patch!

Would it make sense to have all this logic in evaluate() in src/run.c?

I think so. A patch to move it there would be fine.

I suspect there might more missing sanity checks in the configuration file parser (options that are not set to default value, like hashsize and hashlimit).