Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5c88f56 authored by Patrick McHardy's avatar Patrick McHardy
Browse files

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: default avatarPatrick McHardy <kaber@trash.net>
parent a992ca2a
Loading
Loading
Loading
Loading
+12 −17
Original line number Original line Diff line number Diff line
@@ -141,30 +141,25 @@ static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
#endif
#endif


#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
static u_int64_t ct_delta_time(u_int64_t time_now, const struct nf_conn *ct)
static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
{
{
	struct ct_iter_state *st = s->private;
	struct nf_conn_tstamp *tstamp;
	struct nf_conn_tstamp *tstamp;
	s64 delta_time;


	tstamp = nf_conn_tstamp_find(ct);
	tstamp = nf_conn_tstamp_find(ct);
	if (tstamp) {
	if (tstamp) {
		u_int64_t delta_time = time_now - tstamp->start;
		delta_time = st->time_now - tstamp->start;
		return delta_time > 0 ? div_s64(delta_time, NSEC_PER_SEC) : 0;
		if (delta_time > 0)
	}
			delta_time = div_s64(delta_time, NSEC_PER_SEC);
	return -1;
		else
}
			delta_time = 0;

static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
{
	struct ct_iter_state *st = s->private;
	u_int64_t delta_time;

	delta_time = ct_delta_time(st->time_now, ct);
	if (delta_time < 0)
		return 0;


		return seq_printf(s, "delta-time=%llu ",
		return seq_printf(s, "delta-time=%llu ",
				  (unsigned long long)delta_time);
				  (unsigned long long)delta_time);
	}
	}
	return 0;
}
#else
#else
static inline int
static inline int
ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)