]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables-compat: ebtables: split match/target print from nft_bridge_print_firewall
authorFlorian Westphal <fw@strlen.de>
Tue, 8 May 2018 08:43:45 +0000 (10:43 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 10 May 2018 00:31:05 +0000 (02:31 +0200)
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/nft-bridge.c

index 1887586c842890c3c7dbcd78ad26816ecf7e4039..5f9a02c297cb6cf048604d9e1371c6d4c104013b 100644 (file)
@@ -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 ");