aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2011-01-19 13:10:49 -0500
committerPatrick McHardy <kaber@trash.net>2011-01-19 13:10:49 -0500
commitf5c88f56b35599ab9ff2d3398e0153e4cd4a4c82 (patch)
treefd2cb178044db9a256638b2e6565795b91cb3c26
parenta992ca2a0498edd22a88ac8c41570f536de29c9e (diff)
netfilter: nf_conntrack: fix lifetime display for disabled connections
When no tstamp extension exists, ct_delta_time() returns -1, which is then assigned to an u64 and tested for negative values to decide whether to display the lifetime. This obviously doesn't work, use a s64 and merge the two minor functions into one. Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--net/netfilter/nf_conntrack_standalone.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 69107fd78d3e..0ae142825881 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -141,29 +141,24 @@ static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
141#endif 141#endif
142 142
143#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP 143#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
144static u_int64_t ct_delta_time(u_int64_t time_now, const struct nf_conn *ct) 144static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
145{ 145{
146 struct ct_iter_state *st = s->private;
146 struct nf_conn_tstamp *tstamp; 147 struct nf_conn_tstamp *tstamp;
148 s64 delta_time;
147 149
148 tstamp = nf_conn_tstamp_find(ct); 150 tstamp = nf_conn_tstamp_find(ct);
149 if (tstamp) { 151 if (tstamp) {
150 u_int64_t delta_time = time_now - tstamp->start; 152 delta_time = st->time_now - tstamp->start;
151 return delta_time > 0 ? div_s64(delta_time, NSEC_PER_SEC) : 0; 153 if (delta_time > 0)
154 delta_time = div_s64(delta_time, NSEC_PER_SEC);
155 else
156 delta_time = 0;
157
158 return seq_printf(s, "delta-time=%llu ",
159 (unsigned long long)delta_time);
152 } 160 }
153 return -1; 161 return 0;
154}
155
156static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
157{
158 struct ct_iter_state *st = s->private;
159 u_int64_t delta_time;
160
161 delta_time = ct_delta_time(st->time_now, ct);
162 if (delta_time < 0)
163 return 0;
164
165 return seq_printf(s, "delta-time=%llu ",
166 (unsigned long long)delta_time);
167} 162}
168#else 163#else
169static inline int 164static inline int