]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Drop save_counters callback from family_ops
authorPhil Sutter <phil@nwl.cc>
Fri, 8 May 2020 13:40:52 +0000 (15:40 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 18 May 2020 15:40:41 +0000 (17:40 +0200)
All families use the same callback function, just fold it into the sole
place it's called.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft-arp.c
iptables/nft-bridge.c
iptables/nft-ipv4.c
iptables/nft-ipv6.c
iptables/nft-shared.c
iptables/nft-shared.h
iptables/nft.c

index 23ab73cba649e4d9a2a26394c128e7474daebfc9..67f4529d93652915e72f29ed2ac40556e53bf60e 100644 (file)
@@ -652,7 +652,6 @@ struct nft_family_ops nft_family_ops_arp = {
        .print_header           = nft_arp_print_header,
        .print_rule             = nft_arp_print_rule,
        .save_rule              = nft_arp_save_rule,
-       .save_counters          = save_counters,
        .save_chain             = nft_arp_save_chain,
        .post_parse             = NULL,
        .rule_to_cs             = nft_rule_to_iptables_command_state,
index 18f5e78f1b3a2588aa37b4ccda9a314bf2323ab7..dbf11eb5e1fa8a4974fc87d3e8c814abf9c5905f 100644 (file)
@@ -932,7 +932,6 @@ struct nft_family_ops nft_family_ops_bridge = {
        .print_header           = nft_bridge_print_header,
        .print_rule             = nft_bridge_print_rule,
        .save_rule              = nft_bridge_save_rule,
-       .save_counters          = save_counters,
        .save_chain             = nft_bridge_save_chain,
        .post_parse             = NULL,
        .rule_to_cs             = nft_rule_to_ebtables_command_state,
index ba789da0c5973a5c1d9962ddc73cd70ee6fc79e0..afdecf9711e647aa6e3d8a20c3eac54c6f24c928 100644 (file)
@@ -450,7 +450,6 @@ struct nft_family_ops nft_family_ops_ipv4 = {
        .print_header           = print_header,
        .print_rule             = nft_ipv4_print_rule,
        .save_rule              = nft_ipv4_save_rule,
-       .save_counters          = save_counters,
        .save_chain             = nft_ipv46_save_chain,
        .proto_parse            = nft_ipv4_proto_parse,
        .post_parse             = nft_ipv4_post_parse,
index 84bcf1c53f48c48b0dd23a9a7e479f3dabefb2b2..4008b7eab4f2a01dc56db7e726dacc68cd724d42 100644 (file)
@@ -402,7 +402,6 @@ struct nft_family_ops nft_family_ops_ipv6 = {
        .print_header           = print_header,
        .print_rule             = nft_ipv6_print_rule,
        .save_rule              = nft_ipv6_save_rule,
-       .save_counters          = save_counters,
        .save_chain             = nft_ipv46_save_chain,
        .proto_parse            = nft_ipv6_proto_parse,
        .post_parse             = nft_ipv6_post_parse,
index 53cd4cae9ef7c8fa4b16a6c091fd529de2bfbb9c..c5a8f3fcc051de8b9185c5ca354785e764cc00fe 100644 (file)
@@ -831,14 +831,6 @@ void save_rule_details(const struct iptables_command_state *cs,
        }
 }
 
-void save_counters(const void *data)
-{
-       const struct iptables_command_state *cs = data;
-
-       printf("[%llu:%llu] ", (unsigned long long)cs->counters.pcnt,
-                              (unsigned long long)cs->counters.bcnt);
-}
-
 void nft_ipv46_save_chain(const struct nftnl_chain *c, const char *policy)
 {
        const char *chain = nftnl_chain_get_str(c, NFTNL_CHAIN_NAME);
index cb60e685872dde5d1d91fe251102dbd5aa66cefc..94437ffe7990c1b5f74037b89a33ac5ef6cc80e6 100644 (file)
@@ -98,7 +98,6 @@ struct nft_family_ops {
        void (*print_rule)(struct nft_handle *h, struct nftnl_rule *r,
                           unsigned int num, unsigned int format);
        void (*save_rule)(const void *data, unsigned int format);
-       void (*save_counters)(const void *data);
        void (*save_chain)(const struct nftnl_chain *c, const char *policy);
        void (*proto_parse)(struct iptables_command_state *cs,
                            struct xtables_args *args);
@@ -160,7 +159,6 @@ void save_rule_details(const struct iptables_command_state *cs,
                       unsigned const char *iniface_mask,
                       const char *outiface,
                       unsigned const char *outiface_mask);
-void save_counters(const void *data);
 void nft_ipv46_save_chain(const struct nftnl_chain *c, const char *policy);
 void save_matches_and_target(const struct iptables_command_state *cs,
                             bool goto_flag, const void *fw,
index e65eb91c1c504e0bc9e2fd15b1ee4974844b63fa..0c5a74fc232c68350fd10f6765499c70cff1dc5d 100644 (file)
@@ -1453,8 +1453,9 @@ nft_rule_print_save(struct nft_handle *h, const struct nftnl_rule *r,
 
        ops->rule_to_cs(h, r, &cs);
 
-       if (!(format & (FMT_NOCOUNTS | FMT_C_COUNTS)) && ops->save_counters)
-               ops->save_counters(&cs);
+       if (!(format & (FMT_NOCOUNTS | FMT_C_COUNTS)))
+               printf("[%llu:%llu] ", (unsigned long long)cs.counters.pcnt,
+                                      (unsigned long long)cs.counters.bcnt);
 
        /* print chain name */
        switch(type) {