]> git.ipfire.org Git - thirdparty/iptables.git/commit
nft: Set socket receive buffer
authorPhil Sutter <phil@nwl.cc>
Tue, 2 Jul 2019 18:30:49 +0000 (20:30 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 2 Jul 2019 22:53:09 +0000 (00:53 +0200)
commitd3e39e9c457f452540359e42fb58d64a28fe3e18
tree8c2511a459bb300332edb3d0f0acc5ad437ad269
parent886b00b230fae965a104afb1d3b6677d5f17df4a
nft: Set socket receive buffer

When trying to delete user-defined chains in a large ruleset,
iptables-nft aborts with "No buffer space available". This can be
reproduced using the following script:

| #! /bin/bash
| iptables-nft-restore <(
|
| echo "*filter"
| for i in $(seq 0 200000);do
|         printf ":chain_%06x - [0:0]\n" $i
| done
| for i in $(seq 0 200000);do
|         printf -- "-A INPUT -j chain_%06x\n" $i
|         printf -- "-A INPUT -j chain_%06x\n" $i
| done
| echo COMMIT
|
| )
| iptables-nft -X

The problem seems to be the sheer amount of netlink error messages sent
back to user space (one EBUSY for each chain). To solve this, set
receive buffer size depending on number of commands sent to kernel.

Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft.c