diff options
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nf_conntrack_acct.c | 12 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 16 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 16 | ||||
-rw-r--r-- | net/netfilter/xt_connbytes.c | 6 |
4 files changed, 30 insertions, 20 deletions
diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c index 2d3030ab5b61..a4b5e2a435ac 100644 --- a/net/netfilter/nf_conntrack_acct.c +++ b/net/netfilter/nf_conntrack_acct.c | |||
@@ -39,21 +39,23 @@ static struct ctl_table acct_sysctl_table[] = { | |||
39 | unsigned int | 39 | unsigned int |
40 | seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir) | 40 | seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir) |
41 | { | 41 | { |
42 | struct nf_conn_counter *acct; | 42 | struct nf_conn_acct *acct; |
43 | struct nf_conn_counter *counter; | ||
43 | 44 | ||
44 | acct = nf_conn_acct_find(ct); | 45 | acct = nf_conn_acct_find(ct); |
45 | if (!acct) | 46 | if (!acct) |
46 | return 0; | 47 | return 0; |
47 | 48 | ||
49 | counter = acct->counter; | ||
48 | return seq_printf(s, "packets=%llu bytes=%llu ", | 50 | return seq_printf(s, "packets=%llu bytes=%llu ", |
49 | (unsigned long long)atomic64_read(&acct[dir].packets), | 51 | (unsigned long long)atomic64_read(&counter[dir].packets), |
50 | (unsigned long long)atomic64_read(&acct[dir].bytes)); | 52 | (unsigned long long)atomic64_read(&counter[dir].bytes)); |
51 | }; | 53 | }; |
52 | EXPORT_SYMBOL_GPL(seq_print_acct); | 54 | EXPORT_SYMBOL_GPL(seq_print_acct); |
53 | 55 | ||
54 | static struct nf_ct_ext_type acct_extend __read_mostly = { | 56 | static struct nf_ct_ext_type acct_extend __read_mostly = { |
55 | .len = sizeof(struct nf_conn_counter[IP_CT_DIR_MAX]), | 57 | .len = sizeof(struct nf_conn_acct), |
56 | .align = __alignof__(struct nf_conn_counter[IP_CT_DIR_MAX]), | 58 | .align = __alignof__(struct nf_conn_acct), |
57 | .id = NF_CT_EXT_ACCT, | 59 | .id = NF_CT_EXT_ACCT, |
58 | }; | 60 | }; |
59 | 61 | ||
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 5d892febd64c..e22d950c60b3 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -1109,12 +1109,14 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, | |||
1109 | 1109 | ||
1110 | acct: | 1110 | acct: |
1111 | if (do_acct) { | 1111 | if (do_acct) { |
1112 | struct nf_conn_counter *acct; | 1112 | struct nf_conn_acct *acct; |
1113 | 1113 | ||
1114 | acct = nf_conn_acct_find(ct); | 1114 | acct = nf_conn_acct_find(ct); |
1115 | if (acct) { | 1115 | if (acct) { |
1116 | atomic64_inc(&acct[CTINFO2DIR(ctinfo)].packets); | 1116 | struct nf_conn_counter *counter = acct->counter; |
1117 | atomic64_add(skb->len, &acct[CTINFO2DIR(ctinfo)].bytes); | 1117 | |
1118 | atomic64_inc(&counter[CTINFO2DIR(ctinfo)].packets); | ||
1119 | atomic64_add(skb->len, &counter[CTINFO2DIR(ctinfo)].bytes); | ||
1118 | } | 1120 | } |
1119 | } | 1121 | } |
1120 | } | 1122 | } |
@@ -1126,13 +1128,15 @@ bool __nf_ct_kill_acct(struct nf_conn *ct, | |||
1126 | int do_acct) | 1128 | int do_acct) |
1127 | { | 1129 | { |
1128 | if (do_acct) { | 1130 | if (do_acct) { |
1129 | struct nf_conn_counter *acct; | 1131 | struct nf_conn_acct *acct; |
1130 | 1132 | ||
1131 | acct = nf_conn_acct_find(ct); | 1133 | acct = nf_conn_acct_find(ct); |
1132 | if (acct) { | 1134 | if (acct) { |
1133 | atomic64_inc(&acct[CTINFO2DIR(ctinfo)].packets); | 1135 | struct nf_conn_counter *counter = acct->counter; |
1136 | |||
1137 | atomic64_inc(&counter[CTINFO2DIR(ctinfo)].packets); | ||
1134 | atomic64_add(skb->len - skb_network_offset(skb), | 1138 | atomic64_add(skb->len - skb_network_offset(skb), |
1135 | &acct[CTINFO2DIR(ctinfo)].bytes); | 1139 | &counter[CTINFO2DIR(ctinfo)].bytes); |
1136 | } | 1140 | } |
1137 | } | 1141 | } |
1138 | 1142 | ||
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index eea936b70d15..ddc3777d8340 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -237,19 +237,21 @@ static int | |||
237 | ctnetlink_dump_counters(struct sk_buff *skb, const struct nf_conn *ct, | 237 | ctnetlink_dump_counters(struct sk_buff *skb, const struct nf_conn *ct, |
238 | enum ip_conntrack_dir dir, int type) | 238 | enum ip_conntrack_dir dir, int type) |
239 | { | 239 | { |
240 | struct nf_conn_counter *acct; | 240 | struct nf_conn_acct *acct; |
241 | struct nf_conn_counter *counter; | ||
241 | u64 pkts, bytes; | 242 | u64 pkts, bytes; |
242 | 243 | ||
243 | acct = nf_conn_acct_find(ct); | 244 | acct = nf_conn_acct_find(ct); |
244 | if (!acct) | 245 | if (!acct) |
245 | return 0; | 246 | return 0; |
246 | 247 | ||
248 | counter = acct->counter; | ||
247 | if (type == IPCTNL_MSG_CT_GET_CTRZERO) { | 249 | if (type == IPCTNL_MSG_CT_GET_CTRZERO) { |
248 | pkts = atomic64_xchg(&acct[dir].packets, 0); | 250 | pkts = atomic64_xchg(&counter[dir].packets, 0); |
249 | bytes = atomic64_xchg(&acct[dir].bytes, 0); | 251 | bytes = atomic64_xchg(&counter[dir].bytes, 0); |
250 | } else { | 252 | } else { |
251 | pkts = atomic64_read(&acct[dir].packets); | 253 | pkts = atomic64_read(&counter[dir].packets); |
252 | bytes = atomic64_read(&acct[dir].bytes); | 254 | bytes = atomic64_read(&counter[dir].bytes); |
253 | } | 255 | } |
254 | return dump_counters(skb, pkts, bytes, dir); | 256 | return dump_counters(skb, pkts, bytes, dir); |
255 | } | 257 | } |
@@ -530,7 +532,7 @@ ctnetlink_proto_size(const struct nf_conn *ct) | |||
530 | } | 532 | } |
531 | 533 | ||
532 | static inline size_t | 534 | static inline size_t |
533 | ctnetlink_counters_size(const struct nf_conn *ct) | 535 | ctnetlink_acct_size(const struct nf_conn *ct) |
534 | { | 536 | { |
535 | if (!nf_ct_ext_exist(ct, NF_CT_EXT_ACCT)) | 537 | if (!nf_ct_ext_exist(ct, NF_CT_EXT_ACCT)) |
536 | return 0; | 538 | return 0; |
@@ -579,7 +581,7 @@ ctnetlink_nlmsg_size(const struct nf_conn *ct) | |||
579 | + 3 * nla_total_size(sizeof(u_int8_t)) /* CTA_PROTO_NUM */ | 581 | + 3 * nla_total_size(sizeof(u_int8_t)) /* CTA_PROTO_NUM */ |
580 | + nla_total_size(sizeof(u_int32_t)) /* CTA_ID */ | 582 | + nla_total_size(sizeof(u_int32_t)) /* CTA_ID */ |
581 | + nla_total_size(sizeof(u_int32_t)) /* CTA_STATUS */ | 583 | + nla_total_size(sizeof(u_int32_t)) /* CTA_STATUS */ |
582 | + ctnetlink_counters_size(ct) | 584 | + ctnetlink_acct_size(ct) |
583 | + ctnetlink_timestamp_size(ct) | 585 | + ctnetlink_timestamp_size(ct) |
584 | + nla_total_size(sizeof(u_int32_t)) /* CTA_TIMEOUT */ | 586 | + nla_total_size(sizeof(u_int32_t)) /* CTA_TIMEOUT */ |
585 | + nla_total_size(0) /* CTA_PROTOINFO */ | 587 | + nla_total_size(0) /* CTA_PROTOINFO */ |
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c index e595e07a759b..1e634615ab9d 100644 --- a/net/netfilter/xt_connbytes.c +++ b/net/netfilter/xt_connbytes.c | |||
@@ -26,16 +26,18 @@ connbytes_mt(const struct sk_buff *skb, struct xt_action_param *par) | |||
26 | u_int64_t what = 0; /* initialize to make gcc happy */ | 26 | u_int64_t what = 0; /* initialize to make gcc happy */ |
27 | u_int64_t bytes = 0; | 27 | u_int64_t bytes = 0; |
28 | u_int64_t pkts = 0; | 28 | u_int64_t pkts = 0; |
29 | const struct nf_conn_acct *acct; | ||
29 | const struct nf_conn_counter *counters; | 30 | const struct nf_conn_counter *counters; |
30 | 31 | ||
31 | ct = nf_ct_get(skb, &ctinfo); | 32 | ct = nf_ct_get(skb, &ctinfo); |
32 | if (!ct) | 33 | if (!ct) |
33 | return false; | 34 | return false; |
34 | 35 | ||
35 | counters = nf_conn_acct_find(ct); | 36 | acct = nf_conn_acct_find(ct); |
36 | if (!counters) | 37 | if (!acct) |
37 | return false; | 38 | return false; |
38 | 39 | ||
40 | counters = acct->counter; | ||
39 | switch (sinfo->what) { | 41 | switch (sinfo->what) { |
40 | case XT_CONNBYTES_PKTS: | 42 | case XT_CONNBYTES_PKTS: |
41 | switch (sinfo->direction) { | 43 | switch (sinfo->direction) { |