Revert "netfilter: xt_qtaguid: fix crash on non-full sks"
[firefly-linux-kernel-4.4.55.git] / net / netfilter / xt_qtaguid_internal.h
index 02479d6d317d5167fa0ed33127ca6d4ff37aa696..6dc14a9c688966addc6ef949209fa70a70d00024 100644 (file)
@@ -179,6 +179,25 @@ struct data_counters {
        struct byte_packet_counters bpc[IFS_MAX_COUNTER_SETS][IFS_MAX_DIRECTIONS][IFS_MAX_PROTOS];
 };
 
+static inline uint64_t dc_sum_bytes(struct data_counters *counters,
+                                   int set,
+                                   enum ifs_tx_rx direction)
+{
+       return counters->bpc[set][direction][IFS_TCP].bytes
+               + counters->bpc[set][direction][IFS_UDP].bytes
+               + counters->bpc[set][direction][IFS_PROTO_OTHER].bytes;
+}
+
+static inline uint64_t dc_sum_packets(struct data_counters *counters,
+                                     int set,
+                                     enum ifs_tx_rx direction)
+{
+       return counters->bpc[set][direction][IFS_TCP].packets
+               + counters->bpc[set][direction][IFS_UDP].packets
+               + counters->bpc[set][direction][IFS_PROTO_OTHER].packets;
+}
+
+
 /* Generic X based nodes used as a base for rb_tree ops */
 struct tag_node {
        struct rb_node node;
@@ -202,7 +221,8 @@ struct iface_stat {
        /* net_dev is only valid for active iface_stat */
        struct net_device *net_dev;
 
-       struct byte_packet_counters totals[IFS_MAX_DIRECTIONS];
+       struct byte_packet_counters totals_via_dev[IFS_MAX_DIRECTIONS];
+       struct data_counters totals_via_skb;
        /*
         * We keep the last_known, because some devices reset their counters
         * just before NETDEV_UP, while some will reset just before
@@ -254,6 +274,8 @@ struct qtaguid_event_counts {
        atomic64_t iface_events;  /* Number of NETDEV_* events handled */
 
        atomic64_t match_calls;   /* Number of times iptables called mt */
+       /* Number of times iptables called mt from pre or post routing hooks */
+       atomic64_t match_calls_prepost;
        /*
         * match_found_sk_*: numbers related to the netfilter matching
         * function finding a sock for the sk_buff.