]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: remove deprecated code for export/import commands
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 27 Dec 2018 20:19:08 +0000 (21:19 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 27 Dec 2018 20:21:52 +0000 (21:21 +0100)
Update parser to display this error message:

 # nft export json
 Error: JSON export is no longer supported, use 'nft -j list ruleset' instead
 export json
 ^^^^^^^^^^^^

Just like:

 # nft export vm json
 Error: JSON export is no longer supported, use 'nft -j list ruleset' instead
 export vm json
 ^^^^^^^^^^^^^^^

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/mnl.h
include/netlink.h
src/evaluate.c
src/mnl.c
src/netlink.c
src/parser_bison.y
src/rule.c

index 1784b3aa89b6be84e0c8300f3b02db57da150c0f..c63a7e7fd73aba62f06b7bf39c6b420718d89b38 100644 (file)
@@ -81,8 +81,6 @@ int mnl_nft_flowtable_add(struct netlink_ctx *ctx, const struct cmd *cmd,
                          unsigned int flags);
 int mnl_nft_flowtable_del(struct netlink_ctx *ctx, const struct cmd *cmd);
 
-struct nftnl_ruleset *mnl_nft_ruleset_dump(struct netlink_ctx *ctx,
-                                          uint32_t family);
 int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask,
                           struct output_ctx *octx,
                           int (*cb)(const struct nlmsghdr *nlh, void *data),
index a8528d5983a86ed8801ba0078c7d66cc22797871..a20ebbe4740c693208fcfa9c5705353df73a89ea 100644 (file)
@@ -163,9 +163,6 @@ extern int netlink_io_error(struct netlink_ctx *ctx,
        __netlink_init_error(__FILE__, __LINE__, strerror(errno));
 extern void __noreturn __netlink_init_error(const char *file, int line, const char *reason);
 
-extern struct nftnl_ruleset *netlink_dump_ruleset(struct netlink_ctx *ctx,
-                                               const struct handle *h,
-                                               const struct location *loc);
 struct netlink_mon_handler {
        uint32_t                monitor_flags;
        uint32_t                format;
@@ -187,8 +184,6 @@ struct ruleset_parse {
 
 struct nftnl_parse_ctx;
 
-int netlink_markup_parse_cb(const struct nftnl_parse_ctx *ctx);
-
 int netlink_events_trace_cb(const struct nlmsghdr *nlh, int type,
                            struct netlink_mon_handler *monh);
 
index bd25d9ab56805f533d7e06c05ce0e321823deec5..0bda431d5a165cb72fdbbff32a9868fb8b58faae 100644 (file)
@@ -3802,7 +3802,7 @@ static int cmd_evaluate_export(struct eval_ctx *ctx, struct cmd *cmd)
 {
        if (cmd->markup->format == __NFT_OUTPUT_NOTSUPP)
                return cmd_error(ctx, &cmd->location,
-                                "this output type is not supported");
+                                "this output type is not supported, use nft -j list ruleset for JSON support instead");
        else if (cmd->markup->format == NFTNL_OUTPUT_JSON)
                return cmd_error(ctx, &cmd->location,
                                 "JSON export is no longer supported, use 'nft -j list ruleset' instead");
index 455e2d4729a69bf58ab7565313e8f1e4a5bea70c..c3d16774f71f6208f6c15416e34976d762569a8f 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -1376,66 +1376,6 @@ int mnl_nft_flowtable_del(struct netlink_ctx *ctx, const struct cmd *cmd)
        return 0;
 }
 
-/*
- * ruleset
- */
-struct nftnl_ruleset *mnl_nft_ruleset_dump(struct netlink_ctx *ctx,
-                                          uint32_t family)
-{
-       struct nftnl_ruleset *rs;
-       struct nftnl_table_list *t;
-       struct nftnl_chain_list *c;
-       struct nftnl_set_list *sl;
-       struct nftnl_set_list_iter *i;
-       struct nftnl_set *s;
-       struct nftnl_rule_list *r;
-       int ret = 0;
-
-       rs = nftnl_ruleset_alloc();
-       if (rs == NULL)
-               memory_allocation_error();
-
-       t = mnl_nft_table_dump(ctx, family);
-       if (t == NULL)
-               goto err;
-
-       nftnl_ruleset_set(rs, NFTNL_RULESET_TABLELIST, t);
-
-       c = mnl_nft_chain_dump(ctx, family);
-       if (c == NULL)
-               goto err;
-
-       nftnl_ruleset_set(rs, NFTNL_RULESET_CHAINLIST, c);
-
-       sl = mnl_nft_set_dump(ctx, family, NULL);
-       if (sl == NULL)
-               goto err;
-
-       i = nftnl_set_list_iter_create(sl);
-       s = nftnl_set_list_iter_next(i);
-       while (s != NULL) {
-               ret = mnl_nft_setelem_get(ctx, s);
-               if (ret < 0)
-                       goto err;
-
-               s = nftnl_set_list_iter_next(i);
-       }
-       nftnl_set_list_iter_destroy(i);
-
-       nftnl_ruleset_set(rs, NFTNL_RULESET_SETLIST, sl);
-
-       r = mnl_nft_rule_dump(ctx, family);
-       if (r == NULL)
-               goto err;
-
-       nftnl_ruleset_set(rs, NFTNL_RULESET_RULELIST, r);
-
-       return rs;
-err:
-       nftnl_ruleset_free(rs);
-       return NULL;
-}
-
 /*
  * events
  */
index fc9aeeff05b37cc71c9430dfb29c46b80de9dbc1..f67f639070756d05b152e89190c586a673fd45af 100644 (file)
@@ -1117,13 +1117,6 @@ int netlink_list_flowtables(struct netlink_ctx *ctx, const struct handle *h)
        return err;
 }
 
-struct nftnl_ruleset *netlink_dump_ruleset(struct netlink_ctx *ctx,
-                                        const struct handle *h,
-                                        const struct location *loc)
-{
-       return mnl_nft_ruleset_dump(ctx, h->family);
-}
-
 static void trace_print_hdr(const struct nftnl_trace *nlt,
                            struct output_ctx *octx)
 {
@@ -1434,9 +1427,3 @@ int netlink_events_trace_cb(const struct nlmsghdr *nlh, int type,
        nftnl_trace_free(nlt);
        return MNL_CB_OK;
 }
-
-int netlink_markup_parse_cb(const struct nftnl_parse_ctx *ctx)
-{
-       errno = EOPNOTSUPP;
-       return -1;
-}
index 34202b0415ecdc2bd5a1a22873ec06c6c314e71b..01f5be9563eb481baa691209a30e52b6c72421ff 100644 (file)
@@ -1422,7 +1422,7 @@ monitor_format            :       /* empty */     { $$ = NFTNL_OUTPUT_DEFAULT; }
                        ;
 
 markup_format          :       XML             { $$ = __NFT_OUTPUT_NOTSUPP; }
-                       |       JSON            { $$ = __NFT_OUTPUT_NOTSUPP; }
+                       |       JSON            { $$ = NFTNL_OUTPUT_JSON; }
                        |       VM JSON         { $$ = NFTNL_OUTPUT_JSON; }
                        ;
 
index ad3001294c65e0f951d8d05339c16287fc86a20f..a815850d6eaeb5607252ad894cac387e3df14d69 100644 (file)
@@ -1597,47 +1597,6 @@ static int do_command_delete(struct netlink_ctx *ctx, struct cmd *cmd)
        }
 }
 
-static int do_command_export(struct netlink_ctx *ctx, struct cmd *cmd)
-{
-       struct nftnl_ruleset *rs;
-       FILE *fp = ctx->nft->output.output_fp;
-
-       do {
-               rs = netlink_dump_ruleset(ctx, &cmd->handle, &cmd->location);
-               if (rs == NULL && errno != EINTR)
-                       return -1;
-       } while (rs == NULL);
-
-       nftnl_ruleset_fprintf(fp, rs, cmd->markup->format, NFTNL_OF_EVENT_NEW);
-
-       nft_print(&ctx->nft->output, "\n");
-
-       nftnl_ruleset_free(rs);
-       return 0;
-}
-
-static int do_command_import(struct netlink_ctx *ctx, struct cmd *cmd)
-{
-       int ret;
-       struct nftnl_parse_err *err;
-       struct ruleset_parse rp = {
-               .nl_ctx = ctx,
-               .cmd    = cmd
-       };
-
-       err = nftnl_parse_err_alloc();
-       if (err == NULL)
-               return -1;
-
-       ret = nftnl_ruleset_parse_file_cb(cmd->markup->format, stdin, err, &rp,
-                                         netlink_markup_parse_cb);
-       if (ret < 0)
-               nftnl_parse_perror("unable to import: parsing failed", err);
-
-       nftnl_parse_err_free(err);
-       return ret;
-}
-
 static int do_list_table(struct netlink_ctx *ctx, struct cmd *cmd,
                         struct table *table)
 {
@@ -2527,9 +2486,9 @@ int do_command(struct netlink_ctx *ctx, struct cmd *cmd)
        case CMD_RENAME:
                return do_command_rename(ctx, cmd);
        case CMD_IMPORT:
-               return do_command_import(ctx, cmd);
        case CMD_EXPORT:
-               return do_command_export(ctx, cmd);
+               errno = EOPNOTSUPP;
+               return -1;
        case CMD_MONITOR:
                return do_command_monitor(ctx, cmd);
        case CMD_DESCRIBE: