]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
lib: Detach restore routine from parser
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 25 Jun 2021 20:30:41 +0000 (22:30 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Sat, 26 Jun 2021 21:07:08 +0000 (23:07 +0200)
Do not call restore() from ipset_parser(). Instead, ipset_parser()
returns the IPSET_CMD_RESTORE command and the caller invokes restore().

This patch comes in preparation for the ipset to nftables translation
infrastructure.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
lib/ipset.c

index 3077f9793f841b9b4ff2f1ba2ddae40b37e61164..5232d8b76c46f92ba31af9ca81afb1aa140cdff5 100644 (file)
@@ -1231,7 +1231,7 @@ ipset_parser(struct ipset *ipset, int oargc, char *oargv[])
                        return ipset->custom_error(ipset,
                                p, IPSET_PARAMETER_PROBLEM,
                                "Unknown argument %s", argv[1]);
-               return restore(ipset);
+               return IPSET_CMD_RESTORE;
        case IPSET_CMD_ADD:
        case IPSET_CMD_DEL:
        case IPSET_CMD_TEST:
@@ -1296,6 +1296,9 @@ ipset_parse_argv(struct ipset *ipset, int oargc, char *oargv[])
        if (cmd < 0)
                return cmd;
 
+       if (cmd == IPSET_CMD_RESTORE)
+               return restore(ipset);
+
        ret = ipset_cmd(session, cmd, ipset->restore_line);
        D("ret %d", ret);
        /* In the case of warning, the return code is success */