* [PATCH nftables] cmd: incorrect table location in error reporting
@ 2021-06-29 12:26 Pablo Neira Ayuso
0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2021-06-29 12:26 UTC (permalink / raw)
To: netfilter-devel
If the command refers to an inexisting table, then use the table location.
ruleset.nft:3:12-12: Error: No such file or directory; did you mean table ‘filter’ in family ip?
add rule x x ip saddr @x log prefix "Anti SSH-Bruteforce: " drop
^
before this patch location is not correct:
ruleset.nft:3:12-12: Error: No such file or directory; did you mean table ‘filter’ in family ip?
add rule x x ip saddr @x log prefix "Anti SSH-Bruteforce: " drop
^
Fixes: 0276c2fee939 ("cmd: check for table mismatch first in error reporting")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/cmd.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/cmd.c b/src/cmd.c
index a69767c551fe..8d4bf8bc13aa 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -28,12 +28,12 @@ static int nft_cmd_enoent_table(struct netlink_ctx *ctx, const struct cmd *cmd,
}
static int table_fuzzy_check(struct netlink_ctx *ctx, const struct cmd *cmd,
- const struct table *table,
- const struct location *loc)
+ const struct table *table)
{
if (strcmp(cmd->handle.table.name, table->handle.table.name) ||
cmd->handle.family != table->handle.family) {
- netlink_io_error(ctx, loc, "%s; did you mean table ‘%s’ in family %s?",
+ netlink_io_error(ctx, &cmd->handle.table.location,
+ "%s; did you mean table ‘%s’ in family %s?",
strerror(ENOENT), table->handle.table.name,
family2str(table->handle.family));
return 1;
@@ -56,7 +56,7 @@ static int nft_cmd_enoent_chain(struct netlink_ctx *ctx, const struct cmd *cmd,
if (!table)
return 0;
- if (table_fuzzy_check(ctx, cmd, table, loc))
+ if (table_fuzzy_check(ctx, cmd, table))
return 1;
if (!chain)
@@ -85,7 +85,7 @@ static int nft_cmd_enoent_rule(struct netlink_ctx *ctx, const struct cmd *cmd,
if (!table)
return 0;
- if (table_fuzzy_check(ctx, cmd, table, loc))
+ if (table_fuzzy_check(ctx, cmd, table))
return 1;
if (!chain)
@@ -117,7 +117,7 @@ static int nft_cmd_enoent_set(struct netlink_ctx *ctx, const struct cmd *cmd,
if (!table)
return 0;
- if (table_fuzzy_check(ctx, cmd, table, loc))
+ if (table_fuzzy_check(ctx, cmd, table))
return 1;
if (!set)
@@ -146,7 +146,7 @@ static int nft_cmd_enoent_obj(struct netlink_ctx *ctx, const struct cmd *cmd,
if (!table)
return 0;
- if (table_fuzzy_check(ctx, cmd, table, loc))
+ if (table_fuzzy_check(ctx, cmd, table))
return 1;
if (!obj)
@@ -175,7 +175,7 @@ static int nft_cmd_enoent_flowtable(struct netlink_ctx *ctx,
if (!table)
return 0;
- if (table_fuzzy_check(ctx, cmd, table, loc))
+ if (table_fuzzy_check(ctx, cmd, table))
return 1;
if (!ft)
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-29 12:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 12:26 [PATCH nftables] cmd: incorrect table location in error reporting Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).