diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-04-11 12:31:39 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-02-16 19:30:21 +0100 |
commit | 933400b37d0966980d07d32b64403830429761ed (patch) | |
tree | a2540049b9e8c1d679bc2d8a096f0ffc629b9d36 /iptables/nft.h | |
parent | d13b60c9ddb48e651b92f13579e236c530658176 (diff) |
nft: xtables: add the infrastructure to translate from iptables to nft
This patch provides the infrastructure and two new utilities to
translate iptables commands to nft, they are:
1) iptables-restore-translate which basically takes a file that contains
the ruleset in iptables-restore format and converts it to the nft
syntax, eg.
% iptables-restore-translate -f ipt-ruleset > nft-ruleset
% cat nft-ruleset
# Translated by iptables-restore-translate v1.4.21 on Mon Apr 14 12:18:14 2014
add table ip filter
add chain ip filter INPUT { type filter hook input priority 0; }
add chain ip filter FORWARD { type filter hook forward priority 0; }
add chain ip filter OUTPUT { type filter hook output priority 0; }
add rule ip filter INPUT iifname lo counter accept
# -t filter -A INPUT -m state --state INVALID -j LOG --log-prefix invalid:
...
The rules that cannot be translated are left commented. Users should be able
to run this to track down the nft progress to see at what point it can fully
replace iptables and their filtering policy.
2) iptables-translate which suggests a translation for an iptables
command:
$ iptables-translate -I OUTPUT -p udp -d 8.8.8.8 -j ACCEPT
nft add rule filter OUTPUT ip protocol udp ip dst 8.8.8.8 counter accept
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/nft.h')
-rw-r--r-- | iptables/nft.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/iptables/nft.h b/iptables/nft.h index 2cf78fda..192050a4 100644 --- a/iptables/nft.h +++ b/iptables/nft.h @@ -156,6 +156,16 @@ enum { int nft_xtables_config_load(struct nft_handle *h, const char *filename, uint32_t flags); /* + * Translation from iptables to nft + */ +struct xt_buf; + +bool xlate_find_match(const struct iptables_command_state *cs, const char *p_name); +int xlate_matches(const struct iptables_command_state *cs, struct xt_buf *buf); +int xlate_action(const struct iptables_command_state *cs, bool goto_set, + struct xt_buf *buf); + +/* * ARP */ |