From 564862d0cfcd9c241e8410c8f9416c88764aefec Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Tue, 8 May 2018 10:43:45 +0200 Subject: xtables-compat: ebtables: split match/target print from nft_bridge_print_firewall Signed-off-by: Florian Westphal --- iptables/nft-bridge.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'iptables/nft-bridge.c') diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c index 1887586c..5f9a02c2 100644 --- a/iptables/nft-bridge.c +++ b/iptables/nft-bridge.c @@ -413,12 +413,34 @@ static void nft_bridge_print_header(unsigned int format, const char *chain, chain, refs, basechain ? pol : "RETURN"); } -static void nft_bridge_print_firewall(struct nftnl_rule *r, unsigned int num, - unsigned int format) +static void print_matches_and_watchers(const struct iptables_command_state *cs, + unsigned int format) { - struct xtables_match *matchp; struct xtables_target *watcherp; + struct xtables_match *matchp; struct ebt_match *m; + + for (m = cs->match_list; m; m = m->next) { + if (m->ismatch) { + matchp = m->u.match; + if (matchp->print != NULL) { + matchp->print(&cs->eb, matchp->m, + format & FMT_NUMERIC); + } + } else { + watcherp = m->u.watcher; + if (watcherp->print != NULL) { + watcherp->print(&cs->eb, watcherp->t, + format & FMT_NUMERIC); + } + } + } +} + + +static void nft_bridge_print_firewall(struct nftnl_rule *r, unsigned int num, + unsigned int format) +{ struct iptables_command_state cs = {}; char *addr; @@ -492,21 +514,7 @@ static void nft_bridge_print_firewall(struct nftnl_rule *r, unsigned int num, print_iface(cs.eb.out); } - for (m = cs.match_list; m; m = m->next) { - if (m->ismatch) { - matchp = m->u.match; - if (matchp->print != NULL) { - matchp->print(&cs.fw, matchp->m, - format & FMT_NUMERIC); - } - } else { - watcherp = m->u.watcher; - if (watcherp->print != NULL) { - watcherp->print(&cs.fw, watcherp->t, - format & FMT_NUMERIC); - } - } - } + print_matches_and_watchers(&cs, format); printf("-j "); -- cgit v1.2.3