<arg choice="opt">
<option>-s | --stateless</option>
</arg>
+ <arg choice="opt">
+ <option>-c | --check</option>
+ </arg>
<arg choice="opt">
<option>[-I | --includepath]</option>
<replaceable>directory</replaceable>
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-c, --check</option></term>
+ <listitem>
+ <para>
+ Check commands validity without actually applying the changes.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>-N</option></term>
<listitem>
enum opt_vals {
OPT_HELP = 'h',
OPT_VERSION = 'v',
+ OPT_CHECK = 'c',
OPT_FILE = 'f',
OPT_INTERACTIVE = 'i',
OPT_INCLUDEPATH = 'I',
OPT_INVALID = '?',
};
-#define OPTSTRING "hvf:iI:vnsNa"
+#define OPTSTRING "hvcf:iI:vnsNa"
static const struct option options[] = {
{
.name = "version",
.val = OPT_VERSION,
},
+ {
+ .name = "check",
+ .val = OPT_CHECK,
+ },
{
.name = "file",
.val = OPT_FILE,
" -h, --help Show this help\n"
" -v, --version Show version information\n"
"\n"
+" -c, --check Check commands validity without actually applying the changes.\n"
" -f, --file <filename> Read input from <filename>\n"
" -i, --interactive Read input from interactive CLI\n"
"\n"
if (ret < 0)
goto out;
}
- mnl_batch_end(batch);
+ if (!nft->check)
+ mnl_batch_end(batch);
if (!mnl_batch_ready(batch))
goto out;
printf("%s v%s (%s)\n",
PACKAGE_NAME, PACKAGE_VERSION, RELEASE_NAME);
exit(NFT_EXIT_SUCCESS);
+ case OPT_CHECK:
+ nft.check = true;
+ break;
case OPT_FILE:
filename = optarg;
break;