Skip to contentSkip to conversation

nfct: helper: Extend error message for EEXIST

PATCH Superseded Phil Sutter 2 participants 5 messages Aug 15, 2025 – Aug 28, 2025 1 message not in the archive netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 nfct: helper: Extend error message for EEXIST

Users may be not aware the user space helpers conflict with kernel space ones, so add a hint about the possible cause of the EEXIST code returned by the kernel.

---
 src/nfct-extensions/helper.c | 3 +++
 1 file changed, 3 insertions(+)
src/nfct-extensions/helper.c +3 -0
index 894bf269ad2bb..5592dc1340bea 100644
@@ -229,6 +229,9 @@ static int nfct_cmd_helper_add(struct mnl_socket *nl, int argc, char *argv[])
 	portid = mnl_socket_get_portid(nl);
 	if (nfct_mnl_talk(nl, nlh, seq, portid, NULL, NULL) < 0) {
 		nfct_perror("netlink error");
+		if (errno == EEXIST)
+			fprintf(stderr,
+				"Maybe unload nf_conntrack_%s.ko first?\n", argv[3]);
 		return -1;
 	}
 
Signature · 1 line
2.49.0

A message that is not in the archive (sent off-list or not yet received): CAJsUoE2zCJYSvm9_=784BtH26GsRDJGBTn8930wW4ZSU8nTjYA@mail.gmail.com

#2 lore raw
Quoted 8 lines · Yi Chen

This patch adds a hint when:

# modprobe nf_conntrack_ftp
# nfct helper del ftp inet tcp
# nfct helper add ftp inet tcp
*nfct v1.4.8: netlink error: File exists*

or other type of helper.

This patch changes EEXIST by EBUSY:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

This userspace patch is not very useful after this.

So maybe a follow up fix to retain EEXIST for nfnetlink_cthelper in the kernel is needed?

I mean, return EEXIST in nfnetlink_cthelper but EBUSY in case of insmod, ie. add a bool insmod flag to the helper register/unregister functions to return EBUSY for insmod and EEXIST for nfnetlink_cthelper.

author reviewer
#3 lore raw
Quoted 8 lines · Pablo Neira Ayuso
Quoted 7 lines · Yi Chen

This patch adds a hint when:

# modprobe nf_conntrack_ftp
# nfct helper del ftp inet tcp
# nfct helper add ftp inet tcp
*nfct v1.4.8: netlink error: File exists*
Quoted 7 lines
Quoted 1 line

or other type of helper.

This patch changes EEXIST by EBUSY:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

This userspace patch is not very useful after this.

Oh! I missed that nfnl_cthelper_create() also just passes through the return code from nf_conntrack_helper_register().

Quoted 7 lines

So maybe a follow up fix to retain EEXIST for nfnetlink_cthelper in the kernel is needed?

I mean, return EEXIST in nfnetlink_cthelper but EBUSY in case of insmod, ie. add a bool insmod flag to the helper register/unregister functions to return EBUSY for insmod and EEXIST for nfnetlink_cthelper.

Do we need to retain the old return code? I would just update the patch to print the message for EBUSY instead of EEXIST.

Cheers, Phil

#4 lore raw
Quoted 23 lines · Phil Sutter
Quoted 8 lines · Pablo Neira Ayuso
Quoted 7 lines · Yi Chen

This patch adds a hint when:

# modprobe nf_conntrack_ftp
# nfct helper del ftp inet tcp
# nfct helper add ftp inet tcp
*nfct v1.4.8: netlink error: File exists*
Quoted 7 lines
Quoted 1 line

or other type of helper.

This patch changes EEXIST by EBUSY:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

This userspace patch is not very useful after this.

Oh! I missed that nfnl_cthelper_create() also just passes through the return code from nf_conntrack_helper_register().

Quoted 3 lines

So maybe a follow up fix to retain EEXIST for nfnetlink_cthelper in the kernel is needed?

Quoted 6 lines
Quoted 4 lines

I mean, return EEXIST in nfnetlink_cthelper but EBUSY in case of insmod, ie. add a bool insmod flag to the helper register/unregister functions to return EBUSY for insmod and EEXIST for nfnetlink_cthelper.

Do we need to retain the old return code?

I have change return codes in the past myself, when I considered error reported to userspace was misleading, but I heard once it is a good practise not to change them as a general rule.

Quoted 2 lines

I would just update the patch to print the message for EBUSY instead of EEXIST.

It is OK, I could not find any code in conntrackd running in helper mode than relies on this error code. The only case that I can think of is combining old kernel with new userspace defeats the purpose of this patch.

Maybe it is not worth the effort to bother about this, judge yourself.

author reviewer
#5 lore raw
Quoted 35 lines · Pablo Neira Ayuso
Quoted 23 lines · Phil Sutter
Quoted 8 lines · Pablo Neira Ayuso
Quoted 7 lines · Yi Chen

This patch adds a hint when:

# modprobe nf_conntrack_ftp
# nfct helper del ftp inet tcp
# nfct helper add ftp inet tcp
*nfct v1.4.8: netlink error: File exists*
Quoted 7 lines
Quoted 1 line

or other type of helper.

This patch changes EEXIST by EBUSY:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

This userspace patch is not very useful after this.

Oh! I missed that nfnl_cthelper_create() also just passes through the return code from nf_conntrack_helper_register().

Quoted 3 lines

So maybe a follow up fix to retain EEXIST for nfnetlink_cthelper in the kernel is needed?

Quoted 6 lines
Quoted 4 lines

I mean, return EEXIST in nfnetlink_cthelper but EBUSY in case of insmod, ie. add a bool insmod flag to the helper register/unregister functions to return EBUSY for insmod and EEXIST for nfnetlink_cthelper.

Do we need to retain the old return code?

I have change return codes in the past myself, when I considered error reported to userspace was misleading, but I heard once it is a good practise not to change them as a general rule.

Quoted 7 lines
Quoted 2 lines

I would just update the patch to print the message for EBUSY instead of EEXIST.

It is OK, I could not find any code in conntrackd running in helper mode than relies on this error code. The only case that I can think of is combining old kernel with new userspace defeats the purpose of this patch.

Yes, with old kernels new user space behaviour is same as old user space (so at least not a degradation).

Quoted 1 line

Maybe it is not worth the effort to bother about this, judge yourself.

The EBUSY return is consistent with insmod/modprobe return code, so I'd keep it like this.

Thanks, Phil