src: combine extended netlink error reporting with mispelling support
Pablo Neira Ayuso
maintainerPATCH 1/1 src: combine extended netlink error reporting with mispelling support
Preliminary support to combine extended netlink error reporting, 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 <[email protected]>
--- include/Makefile.am | 1 + src/cmd.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/libnftables.c | 23 +------- 3 files changed, 160 insertions(+), 21 deletions(-) create mode 100644 src/cmd.c
include/Makefile.am +1 -0
@@ -3,6 +3,7 @@ SUBDIRS = linux \ noinst_HEADERS = cli.h \ cache.h \ + cmd.h \ datatype.h \ expression.h \ fib.h \
src/cmd.c new file +157 -0
157 lines not on this page · raw message
src/libnftables.c +2 -21
@@ -12,30 +12,11 @@#include <parser.h> #include <utils.h> #include <iface.h> - +#include <cmd.h> #include <errno.h> #include <stdlib.h> #include <string.h> -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);
Signature · 1 line
2.11.0