From f27f032b8da584d4447dc03b3ccd3370433e2c0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=B0=A2=E8=87=B4=E9=82=A6=20=28XIE=20Zhibang=29?= Date: Wed, 21 Feb 2024 15:17:09 +0000 Subject: [PATCH] src: improve error reporting for destroy command MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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) Signed-off-by: Florian Westphal --- src/cmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd.c b/src/cmd.c index 68c476c69..21533e0ea 100644 --- 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)); } -- 2.47.2