]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: improve error reporting for destroy command
author谢致邦 (XIE Zhibang) <Yeking@Red54.com>
Wed, 21 Feb 2024 15:17:09 +0000 (15:17 +0000)
committerFlorian Westphal <fw@strlen.de>
Tue, 27 Feb 2024 23:21:42 +0000 (00:21 +0100)
Example for older kernels (<6.3):
nft destroy table ip missingtable

Before:
Error: Could not process rule: Invalid argument

After:
Error: "destroy" command is not supported, perhaps kernel support is
missing?

Fixes: e1dfd5cc4c46 ("src: add support to command "destroy"")
Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/cmd.c

index 68c476c693675878dbea71bb528ed21583b4824b..21533e0eaaad603c0a964d8b974c74fe5d500c09 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -311,6 +311,12 @@ void nft_cmd_error(struct netlink_ctx *ctx, struct cmd *cmd,
                break;
        }
 
+       if (cmd->op == CMD_DESTROY && err->err == EINVAL) {
+               netlink_io_error(ctx, loc,
+                                "\"destroy\" command is not supported, perhaps kernel support is missing?");
+               return;
+       }
+
        netlink_io_error(ctx, loc, "Could not process rule: %s",
                         strerror(err->err));
 }