* [PATCH net v2 0/2] fix glitch in IPVS /proc handlers
@ 2018-07-31 16:03 Matteo Croce
2018-07-31 16:03 ` [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms Matteo Croce
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Matteo Croce @ 2018-07-31 16:03 UTC (permalink / raw)
To: Wensong Zhang, Simon Horman, Julian Anastasov, lvs-devel, netdev,
Jozsef Kadlecsik
Cc: Pablo Neira Ayuso, Florian Westphal, netfilter-devel, Eric Dumazet
Fix a bug which shows negative values in IPVS /proc handlers.
Also add an helper function to calculate a time delta
Matteo Croce (2):
jiffies: add utility function to calculate delta in ms
ipvs: don't show negative times in ip_vs_conn
include/linux/jiffies.h | 5 +++++
net/netfilter/ipvs/ip_vs_conn.c | 22 ++++++++++++++--------
2 files changed, 19 insertions(+), 8 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms
2018-07-31 16:03 [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Matteo Croce
@ 2018-07-31 16:03 ` Matteo Croce
2018-07-31 16:07 ` Eric Dumazet
2018-07-31 16:03 ` [PATCH net v2 2/2] ipvs: don't show negative times in ip_vs_conn Matteo Croce
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Matteo Croce @ 2018-07-31 16:03 UTC (permalink / raw)
To: Wensong Zhang, Simon Horman, Julian Anastasov, lvs-devel, netdev,
Jozsef Kadlecsik
Cc: Pablo Neira Ayuso, Florian Westphal, netfilter-devel, Eric Dumazet
add jiffies_delta_to_msecs() helper func to calculate the delta between
two times and eventually 0 if negative.
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
include/linux/jiffies.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index a27cf6652327..fa928242567d 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -447,6 +447,11 @@ static inline clock_t jiffies_delta_to_clock_t(long delta)
return jiffies_to_clock_t(max(0L, delta));
}
+static inline unsigned int jiffies_delta_to_msecs(long delta)
+{
+ return jiffies_to_msecs(max(0L, delta));
+}
+
extern unsigned long clock_t_to_jiffies(unsigned long x);
extern u64 jiffies_64_to_clock_t(u64 x);
extern u64 nsec_to_clock_t(u64 x);
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net v2 2/2] ipvs: don't show negative times in ip_vs_conn
2018-07-31 16:03 [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Matteo Croce
2018-07-31 16:03 ` [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms Matteo Croce
@ 2018-07-31 16:03 ` Matteo Croce
2018-07-31 16:28 ` [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Simon Horman
2019-01-28 10:17 ` Pablo Neira Ayuso
3 siblings, 0 replies; 7+ messages in thread
From: Matteo Croce @ 2018-07-31 16:03 UTC (permalink / raw)
To: Wensong Zhang, Simon Horman, Julian Anastasov, lvs-devel, netdev,
Jozsef Kadlecsik
Cc: Pablo Neira Ayuso, Florian Westphal, netfilter-devel, Eric Dumazet
Since commit 500462a9de65 ("timers: Switch to a non-cascading wheel"),
timers duration can last even 12.5% more than the scheduled interval.
IPVS has two handlers, /proc/net/ip_vs_conn and /proc/net/ip_vs_conn_sync,
which shows the remaining time before that a connection expires.
The default expire time for a connection is 60 seconds, and the
expiration timer can fire even 4 seconds later than the scheduled time.
The expiration time is calculated subtracting jiffies to the scheduled
expiration time, and it's shown as a huge number when the timer fires late,
since both values are unsigned.
This can confuse script and tools which relies on it, like ipvsadm:
root@mcroce-redhat:~# while ipvsadm -lc |grep SYN_RECV; do sleep 1 ; done
TCP 00:05 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 00:04 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 00:03 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 00:02 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 00:01 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 00:00 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 68719476:44 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 68719476:43 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 68719476:42 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 68719476:41 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 68719476:40 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
TCP 68719476:39 SYN_RECV [fc00:1::1]:55732 [fc00:1::2]:8000 [fc00:2000::1]:8000
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
net/netfilter/ipvs/ip_vs_conn.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 99e0aa350dc5..615286dcf4c0 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1102,24 +1102,28 @@ static int ip_vs_conn_seq_show(struct seq_file *seq, void *v)
#ifdef CONFIG_IP_VS_IPV6
if (cp->af == AF_INET6)
seq_printf(seq, "%-3s %pI6 %04X %pI6 %04X "
- "%s %04X %-11s %7lu%s\n",
+ "%s %04X %-11s %7u%s\n",
ip_vs_proto_name(cp->protocol),
&cp->caddr.in6, ntohs(cp->cport),
&cp->vaddr.in6, ntohs(cp->vport),
dbuf, ntohs(cp->dport),
ip_vs_state_name(cp->protocol, cp->state),
- (cp->timer.expires-jiffies)/HZ, pe_data);
+ jiffies_delta_to_msecs(cp->timer.expires -
+ jiffies) / 1000,
+ pe_data);
else
#endif
seq_printf(seq,
"%-3s %08X %04X %08X %04X"
- " %s %04X %-11s %7lu%s\n",
+ " %s %04X %-11s %7u%s\n",
ip_vs_proto_name(cp->protocol),
ntohl(cp->caddr.ip), ntohs(cp->cport),
ntohl(cp->vaddr.ip), ntohs(cp->vport),
dbuf, ntohs(cp->dport),
ip_vs_state_name(cp->protocol, cp->state),
- (cp->timer.expires-jiffies)/HZ, pe_data);
+ jiffies_delta_to_msecs(cp->timer.expires -
+ jiffies) / 1000,
+ pe_data);
}
return 0;
}
@@ -1164,26 +1168,28 @@ static int ip_vs_conn_sync_seq_show(struct seq_file *seq, void *v)
#ifdef CONFIG_IP_VS_IPV6
if (cp->af == AF_INET6)
seq_printf(seq, "%-3s %pI6 %04X %pI6 %04X "
- "%s %04X %-11s %-6s %7lu\n",
+ "%s %04X %-11s %-6s %7u\n",
ip_vs_proto_name(cp->protocol),
&cp->caddr.in6, ntohs(cp->cport),
&cp->vaddr.in6, ntohs(cp->vport),
dbuf, ntohs(cp->dport),
ip_vs_state_name(cp->protocol, cp->state),
ip_vs_origin_name(cp->flags),
- (cp->timer.expires-jiffies)/HZ);
+ jiffies_delta_to_msecs(cp->timer.expires -
+ jiffies) / 1000);
else
#endif
seq_printf(seq,
"%-3s %08X %04X %08X %04X "
- "%s %04X %-11s %-6s %7lu\n",
+ "%s %04X %-11s %-6s %7u\n",
ip_vs_proto_name(cp->protocol),
ntohl(cp->caddr.ip), ntohs(cp->cport),
ntohl(cp->vaddr.ip), ntohs(cp->vport),
dbuf, ntohs(cp->dport),
ip_vs_state_name(cp->protocol, cp->state),
ip_vs_origin_name(cp->flags),
- (cp->timer.expires-jiffies)/HZ);
+ jiffies_delta_to_msecs(cp->timer.expires -
+ jiffies) / 1000);
}
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms
2018-07-31 16:03 ` [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms Matteo Croce
@ 2018-07-31 16:07 ` Eric Dumazet
0 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2018-07-31 16:07 UTC (permalink / raw)
To: Matteo Croce, Wensong Zhang, Simon Horman, Julian Anastasov,
lvs-devel, netdev, Jozsef Kadlecsik
Cc: Pablo Neira Ayuso, Florian Westphal, netfilter-devel
On 07/31/2018 09:03 AM, Matteo Croce wrote:
> add jiffies_delta_to_msecs() helper func to calculate the delta between
> two times and eventually 0 if negative.
>
> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 0/2] fix glitch in IPVS /proc handlers
2018-07-31 16:03 [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Matteo Croce
2018-07-31 16:03 ` [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms Matteo Croce
2018-07-31 16:03 ` [PATCH net v2 2/2] ipvs: don't show negative times in ip_vs_conn Matteo Croce
@ 2018-07-31 16:28 ` Simon Horman
2018-08-03 10:40 ` Pablo Neira Ayuso
2019-01-28 10:17 ` Pablo Neira Ayuso
3 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2018-07-31 16:28 UTC (permalink / raw)
To: Matteo Croce, Pablo Neira Ayuso
Cc: Wensong Zhang, Julian Anastasov, lvs-devel, netdev,
Jozsef Kadlecsik, Pablo Neira Ayuso, Florian Westphal,
netfilter-devel, Eric Dumazet
On Tue, Jul 31, 2018 at 06:03:31PM +0200, Matteo Croce wrote:
> Fix a bug which shows negative values in IPVS /proc handlers.
> Also add an helper function to calculate a time delta
>
> Matteo Croce (2):
> jiffies: add utility function to calculate delta in ms
> ipvs: don't show negative times in ip_vs_conn
Acked-by: Simon Horman <horms@verge.net.au>
Pablo, please consider taking these via the nf tree.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 0/2] fix glitch in IPVS /proc handlers
2018-07-31 16:28 ` [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Simon Horman
@ 2018-08-03 10:40 ` Pablo Neira Ayuso
0 siblings, 0 replies; 7+ messages in thread
From: Pablo Neira Ayuso @ 2018-08-03 10:40 UTC (permalink / raw)
To: Simon Horman
Cc: Matteo Croce, Wensong Zhang, Julian Anastasov, lvs-devel, netdev,
Jozsef Kadlecsik, Florian Westphal, netfilter-devel,
Eric Dumazet
On Tue, Jul 31, 2018 at 06:28:22PM +0200, Simon Horman wrote:
> On Tue, Jul 31, 2018 at 06:03:31PM +0200, Matteo Croce wrote:
> > Fix a bug which shows negative values in IPVS /proc handlers.
> > Also add an helper function to calculate a time delta
> >
> > Matteo Croce (2):
> > jiffies: add utility function to calculate delta in ms
> > ipvs: don't show negative times in ip_vs_conn
>
> Acked-by: Simon Horman <horms@verge.net.au>
>
> Pablo, please consider taking these via the nf tree.
Applied, thanks Simon.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 0/2] fix glitch in IPVS /proc handlers
2018-07-31 16:03 [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Matteo Croce
` (2 preceding siblings ...)
2018-07-31 16:28 ` [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Simon Horman
@ 2019-01-28 10:17 ` Pablo Neira Ayuso
3 siblings, 0 replies; 7+ messages in thread
From: Pablo Neira Ayuso @ 2019-01-28 10:17 UTC (permalink / raw)
To: Matteo Croce
Cc: Wensong Zhang, Simon Horman, Julian Anastasov, lvs-devel, netdev,
Jozsef Kadlecsik, Florian Westphal, netfilter-devel,
Eric Dumazet
On Tue, Jul 31, 2018 at 06:03:31PM +0200, Matteo Croce wrote:
> Fix a bug which shows negative values in IPVS /proc handlers.
> Also add an helper function to calculate a time delta
Series applied, thanks Matteo.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-01-28 10:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 16:03 [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Matteo Croce
2018-07-31 16:03 ` [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms Matteo Croce
2018-07-31 16:07 ` Eric Dumazet
2018-07-31 16:03 ` [PATCH net v2 2/2] ipvs: don't show negative times in ip_vs_conn Matteo Croce
2018-07-31 16:28 ` [PATCH net v2 0/2] fix glitch in IPVS /proc handlers Simon Horman
2018-08-03 10:40 ` Pablo Neira Ayuso
2019-01-28 10:17 ` Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.