summaryrefslogtreecommitdiffstats
path: root/iptables/xtables-eb.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2018-07-19 18:32:08 +0200
committerFlorian Westphal <fw@strlen.de>2018-07-19 23:12:37 +0200
commit25ef90814a991e80384d4369565c6decadfcd409 (patch)
treeb74a58fb55ca89941d93180e21d4ee5b2e9c692c /iptables/xtables-eb.c
parentde8574ac79c83d4575e2613472c1978a5154bdb7 (diff)
xtables: introduce nft_init_eb()
This wraps nft_init(), adding required things needed for ebtables. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/xtables-eb.c')
-rw-r--r--iptables/xtables-eb.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
index f4b39095..44235347 100644
--- a/iptables/xtables-eb.c
+++ b/iptables/xtables-eb.c
@@ -732,6 +732,40 @@ void ebt_add_watcher(struct xtables_target *watcher,
cs->match_list->next = newnode;
}
+int nft_init_eb(struct nft_handle *h)
+{
+ ebtables_globals.program_name = "ebtables";
+ if (xtables_init_all(&ebtables_globals, NFPROTO_BRIDGE) < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize ebtables-compat\n",
+ ebtables_globals.program_name,
+ ebtables_globals.program_version);
+ exit(1);
+ }
+
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
+ init_extensionsb();
+#endif
+
+ memset(h, 0, sizeof(*h));
+
+ h->family = NFPROTO_BRIDGE;
+
+ if (nft_init(h, xtables_bridge) < 0)
+ xtables_error(OTHER_PROBLEM,
+ "Could not initialize nftables layer.");
+ h->ops = nft_family_ops_lookup(h->family);
+ if (!h->ops)
+ xtables_error(PARAMETER_PROBLEM, "Unknown family");
+
+ /* manually registering ebt matches, given the original ebtables parser
+ * don't use '-m matchname' and the match can't be loaded dynamically when
+ * the user calls it.
+ */
+ ebt_load_match_extensions();
+
+ return 0;
+}
+
int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table)
{
char *buffer;