Skip to contentSkip to conversation

netfilter: conntrack: document sparse hash table eviction

PATCH Superseded Vikash SS 2 participants 4 messages Nov 6 – Nov 15 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Vikash SS

author
#0 lore raw

PATCH 1/1 netfilter: conntrack: document sparse hash table eviction

When nf_conntrack_max is significantly smaller than nf_conntrack_buckets, the hash table can become sparsely populated.

The early_drop() path examines at most 8 consecutive hash buckets when searching for eviction candidates. Under table exhaustion, this bounded search may fail to find an eligible entry even when evictable connections exist elsewhere in the table.

Document this limitation to clarify the implications of configuring nf_conntrack_max significantly below nf_conntrack_buckets.

---
 Documentation/networking/nf_conntrack-sysctl.rst | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/networking/nf_conntrack-sysctl.rst +4 -0
index 4426cce2a..fc07a950b 100644
@@ -99,6 +99,10 @@ nf_conntrack_max - INTEGER
         the reversed address). This means that with default settings a maxed-out
         table will have a average hash chain length of 2, not 1.
 
+        Setting nf_conntrack_max much lower than nf_conntrack_buckets
+        may cause early eviction to fail under table exhaustion, as
+        the eviction search may not find entries in sparse hash tables.
+
 nf_conntrack_tcp_be_liberal - BOOLEAN
 	- 0 - disabled (default)
 	- not 0 - enabled
Signature · 1 line
2.34.1
#1 lore raw
Quoted 21 lines · Vikash SS

When nf_conntrack_max is significantly smaller than nf_conntrack_buckets, the hash table can become sparsely populated.

The early_drop() path examines at most 8 consecutive hash buckets when searching for eviction candidates. Under table exhaustion, this bounded search may fail to find an eligible entry even when evictable connections exist elsewhere in the table.

Document this limitation to clarify the implications of configuring nf_conntrack_max significantly below nf_conntrack_buckets.

---
 Documentation/networking/nf_conntrack-sysctl.rst | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/networking/nf_conntrack-sysctl.rst +0 -0
index 4426cce2a..fc07a950b 100644

Documentation/networking/nf_conntrack-sysctl.rst nf_conntrack_max - INTEGER · line 104

Quoted 6 lines
Documentation/networking/nf_conntrack-sysctl.rst +3 -0
@@ -99,6 +99,10 @@ nf_conntrack_max - INTEGER
         the reversed address). This means that with default settings a maxed-out
         table will have a average hash chain length of 2, not 1.
 
+        Setting nf_conntrack_max much lower than nf_conntrack_buckets
+        may cause early eviction to fail under table exhaustion, as
+        the eviction search may not find entries in sparse hash tables.

Maybe provide a positive hint:

+        Make sure nf_conntrack_max is equal to or larger than
+        nf_conntrack_buckets, otherwise early drop may fail to evict
+        entries when it gets full.
Quoted 6 lines
Documentation/networking/nf_conntrack-sysctl.rst +0 -0
 nf_conntrack_tcp_be_liberal - BOOLEAN
 	- 0 - disabled (default)
 	- not 0 - enabled
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v2 1/1 netfilter: conntrack: document sparse hash table eviction

In reply to Vikash SS

When nf_conntrack_max is significantly smaller than nf_conntrack_buckets, the hash table can become sparsely populated.

The early_drop() path examines at most 8 consecutive hash buckets when searching for eviction candidates. Under table exhaustion, this bounded search may fail to find an eligible entry even when evictable connections exist elsewhere in the table.

Document this limitation to clarify the implications of configuring nf_conntrack_max significantly below nf_conntrack_buckets.

---
Changes in v2:
- Reword documentation to provide configuration guidance, as suggested by Pablo Neira Ayuso.

 Documentation/networking/nf_conntrack-sysctl.rst | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/networking/nf_conntrack-sysctl.rst +4 -0
index 4426cce2a..c7e9016ac 100644
@@ -99,6 +99,10 @@ nf_conntrack_max - INTEGER
         the reversed address). This means that with default settings a maxed-out
         table will have a average hash chain length of 2, not 1.
 
+        Make sure nf_conntrack_max is equal to or larger than
+        nf_conntrack_buckets, otherwise early drop may fail to evict
+        entries when it gets full.
+
 nf_conntrack_tcp_be_liberal - BOOLEAN
 	- 0 - disabled (default)
 	- not 0 - enabled
Signature · 1 line
2.34.1

A message that is not in the archive (sent off-list or not yet received): CABkQbGJYRCts2h+U-7NxrY1+k6_Wo_bStnt8heJHL18b7yg_wg@mail.gmail.com

author
#4 lore raw

Hi Pablo,

Just following up on the v2 patch submitted on November 6, which incorporates your suggested wording.

Would you have any further comments, or is there anything else needed from my side?

Quoted 49 lines · ss vikash

Hi Pablo,

Just following up on the v2 patch submitted on November 6, which incorporates your suggested wording.

Would you have any further comments, or is there anything else needed from my side?

Quoted 39 lines · Vikash SS

When nf_conntrack_max is significantly smaller than nf_conntrack_buckets, the hash table can become sparsely populated.

The early_drop() path examines at most 8 consecutive hash buckets when searching for eviction candidates. Under table exhaustion, this bounded search may fail to find an eligible entry even when evictable connections exist elsewhere in the table.

Document this limitation to clarify the implications of configuring nf_conntrack_max significantly below nf_conntrack_buckets.

---
Changes in v2:
- Reword documentation to provide configuration guidance, as suggested by Pablo Neira Ayuso.

 Documentation/networking/nf_conntrack-sysctl.rst | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/networking/nf_conntrack-sysctl.rst +4 -1
index 4426cce2a..c7e9016ac 100644
@@ -99,6 +99,10 @@ nf_conntrack_max - INTEGER
         the reversed address). This means that with default settings a maxed-out
         table will have a average hash chain length of 2, not 1.
 
+        Make sure nf_conntrack_max is equal to or larger than
+        nf_conntrack_buckets, otherwise early drop may fail to evict
+        entries when it gets full.
+
 nf_conntrack_tcp_be_liberal - BOOLEAN
        - 0 - disabled (default)
        - not 0 - enabled
--

2.34.1