Skip to content

Commit 8c2d45b

Browse files
committed
netfilter: nf_tables: Allow set back-ends to report partial overlaps on insertion
Currently, the -EEXIST return code of ->insert() callbacks is ambiguous: it might indicate that a given element (including intervals) already exists as such, or that the new element would clash with existing ones. If identical elements already exist, the front-end is ignoring this without returning error, in case NLM_F_EXCL is not set. However, if the new element can't be inserted due an overlap, we should report this to the user. To this purpose, allow set back-ends to return -ENOTEMPTY on collision with existing elements, translate that to -EEXIST, and return that to userspace, no matter if NLM_F_EXCL was set. Reported-by: Phil Sutter <[email protected]> Signed-off-by: Stefano Brivio <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 749f6f6 commit 8c2d45b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5082,6 +5082,11 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
50825082
err = -EBUSY;
50835083
else if (!(nlmsg_flags & NLM_F_EXCL))
50845084
err = 0;
5085+
} else if (err == -ENOTEMPTY) {
5086+
/* ENOTEMPTY reports overlapping between this element
5087+
* and an existing one.
5088+
*/
5089+
err = -EEXIST;
50855090
}
50865091
goto err_element_clash;
50875092
}

0 commit comments

Comments
 (0)