diff mbox series

[nft] src: improve error reporting for destroy command

Message ID tencent_C3F5D0594FFF293E6BB4DFFD3004D6D2860A@qq.com
State Accepted, archived
Headers show
Series [nft] src: improve error reporting for destroy command | expand

Commit Message

谢致邦 (XIE Zhibang) Feb. 21, 2024, 3:17 p.m. UTC
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>
---
 src/cmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/src/cmd.c b/src/cmd.c
index 68c476c6..21533e0e 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));
 }