From 3a0e07106f666df82925aa3fb2eb5937245c9819 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 18 Feb 2020 12:59:24 +0100 Subject: src: combine extended netlink error reporting with mispelling support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preliminary support: only for the deletion command, e.g. # nft delete table twst Error: No such file or directory; did you mean table ‘test’ in family ip? delete table twst ^^^^ Signed-off-by: Pablo Neira Ayuso --- src/libnftables.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'src/libnftables.c') diff --git a/src/libnftables.c b/src/libnftables.c index eaa4736c..32da0a29 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -12,30 +12,11 @@ #include #include #include - +#include #include #include #include -static void nft_error(struct netlink_ctx *ctx, struct cmd *cmd, - struct mnl_err *err) -{ - struct location *loc = NULL; - int i; - - for (i = 0; i < cmd->num_attrs; i++) { - if (!cmd->attr[i].offset) - break; - if (cmd->attr[i].offset == err->offset) - loc = cmd->attr[i].location; - } - if (!loc) - loc = &cmd->location; - - netlink_io_error(ctx, loc, "Could not process rule: %s", - strerror(err->err)); -} - static int nft_netlink(struct nft_ctx *nft, struct list_head *cmds, struct list_head *msgs, struct mnl_socket *nf_sock) @@ -87,7 +68,7 @@ static int nft_netlink(struct nft_ctx *nft, list_for_each_entry(cmd, cmds, list) { if (err->seqnum == cmd->seqnum || err->seqnum == batch_seqnum) { - nft_error(&ctx, cmd, err); + nft_cmd_error(&ctx, cmd, err); errno = err->err; if (err->seqnum == cmd->seqnum) { mnl_err_list_free(err); -- cgit v1.2.3