All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sctp: don't compare hb_timer expire date before starting it
@ 2019-02-22  8:45 ` kwiecienmaciek
  0 siblings, 0 replies; 8+ messages in thread
From: kwiecienmaciek @ 2019-02-22  8:45 UTC (permalink / raw)
  To: linux-sctp; +Cc: netdev, alexander.sverdlin, Maciej Kwiecien

From: Maciej Kwiecien <maciej.kwiecien@nokia.com>

hb_timer might not start at all for a particular transport because its
start is conditional. In a result a node is not sending heartbeats.

Function sctp_transport_reset_hb_timer has two roles:
    - initial start of hb_timer for a given transport,
    - update expire date of hb_timer for a given transport.
The function is optimized to update timer's expire only if it is before
a new calculated one but this comparison is invalid for a timer which
has not yet started. Such a timer has expire == 0 and if a new expire
value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will
fail and timer will not start resulting in no heartbeat packets send by
the node.

This was found when association was initialized within first 5 mins
after system boot due to jiffies init value which is near to MAX_JIFFIES.

Test kernel version: 4.9.154 (ARCH=arm)
hb_timer.expire = 0;                //initialized, not started timer
new_expire = MAX_JIFFIES / 2 + 2;   //or more
time_before(hb_timer.expire, new_expire) == false

Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
Reported-by: Marcin Stojek <marcin.stojek@nokia.com>
Tested-by: Marcin Stojek <marcin.stojek@nokia.com>
Signed-off-by: Maciej Kwiecien <maciej.kwiecien@nokia.com>
---
 net/sctp/transport.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 033696e6f74f..ad158d311ffa 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -207,7 +207,8 @@ void sctp_transport_reset_hb_timer(struct sctp_transport *transport)
 
 	/* When a data chunk is sent, reset the heartbeat interval.  */
 	expires = jiffies + sctp_transport_timeout(transport);
-	if (time_before(transport->hb_timer.expires, expires) &&
+	if ((time_before(transport->hb_timer.expires, expires) ||
+	     !timer_pending(&transport->hb_timer)) &&
 	    !mod_timer(&transport->hb_timer,
 		       expires + prandom_u32_max(transport->rto)))
 		sctp_transport_hold(transport);
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] sctp: don't compare hb_timer expire date before starting it
@ 2019-02-22  8:45 ` kwiecienmaciek
  0 siblings, 0 replies; 8+ messages in thread
From: kwiecienmaciek @ 2019-02-22  8:45 UTC (permalink / raw)
  To: linux-sctp; +Cc: netdev, alexander.sverdlin, Maciej Kwiecien

From: Maciej Kwiecien <maciej.kwiecien@nokia.com>

hb_timer might not start at all for a particular transport because its
start is conditional. In a result a node is not sending heartbeats.

Function sctp_transport_reset_hb_timer has two roles:
    - initial start of hb_timer for a given transport,
    - update expire date of hb_timer for a given transport.
The function is optimized to update timer's expire only if it is before
a new calculated one but this comparison is invalid for a timer which
has not yet started. Such a timer has expire = 0 and if a new expire
value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will
fail and timer will not start resulting in no heartbeat packets send by
the node.

This was found when association was initialized within first 5 mins
after system boot due to jiffies init value which is near to MAX_JIFFIES.

Test kernel version: 4.9.154 (ARCH=arm)
hb_timer.expire = 0;                //initialized, not started timer
new_expire = MAX_JIFFIES / 2 + 2;   //or more
time_before(hb_timer.expire, new_expire) = false

Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
Reported-by: Marcin Stojek <marcin.stojek@nokia.com>
Tested-by: Marcin Stojek <marcin.stojek@nokia.com>
Signed-off-by: Maciej Kwiecien <maciej.kwiecien@nokia.com>
---
 net/sctp/transport.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 033696e6f74f..ad158d311ffa 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -207,7 +207,8 @@ void sctp_transport_reset_hb_timer(struct sctp_transport *transport)
 
 	/* When a data chunk is sent, reset the heartbeat interval.  */
 	expires = jiffies + sctp_transport_timeout(transport);
-	if (time_before(transport->hb_timer.expires, expires) &&
+	if ((time_before(transport->hb_timer.expires, expires) ||
+	     !timer_pending(&transport->hb_timer)) &&
 	    !mod_timer(&transport->hb_timer,
 		       expires + prandom_u32_max(transport->rto)))
 		sctp_transport_hold(transport);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] sctp: don't compare hb_timer expire date before starting it
  2019-02-22  8:45 ` kwiecienmaciek
@ 2019-02-22 10:03   ` Sverdlin, Alexander (Nokia - DE/Ulm)
  -1 siblings, 0 replies; 8+ messages in thread
From: Sverdlin, Alexander (Nokia - DE/Ulm) @ 2019-02-22 10:03 UTC (permalink / raw)
  To: kwiecienmaciek, linux-sctp; +Cc: netdev, Kwiecien, Maciej (Nokia - PL/Wroclaw)

On 22/02/2019 09:45, kwiecienmaciek@gmail.com wrote:
> From: Maciej Kwiecien <maciej.kwiecien@nokia.com>
> 
> hb_timer might not start at all for a particular transport because its
> start is conditional. In a result a node is not sending heartbeats.
> 
> Function sctp_transport_reset_hb_timer has two roles:
>     - initial start of hb_timer for a given transport,
>     - update expire date of hb_timer for a given transport.
> The function is optimized to update timer's expire only if it is before
> a new calculated one but this comparison is invalid for a timer which
> has not yet started. Such a timer has expire == 0 and if a new expire
> value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will
> fail and timer will not start resulting in no heartbeat packets send by
> the node.
> 
> This was found when association was initialized within first 5 mins
> after system boot due to jiffies init value which is near to MAX_JIFFIES.
> 
> Test kernel version: 4.9.154 (ARCH=arm)
> hb_timer.expire = 0;                //initialized, not started timer
> new_expire = MAX_JIFFIES / 2 + 2;   //or more
> time_before(hb_timer.expire, new_expire) == false
> 
> Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
> Reported-by: Marcin Stojek <marcin.stojek@nokia.com>
> Tested-by: Marcin Stojek <marcin.stojek@nokia.com>

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>

> Signed-off-by: Maciej Kwiecien <maciej.kwiecien@nokia.com>
> ---
>  net/sctp/transport.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sctp/transport.c b/net/sctp/transport.c
> index 033696e6f74f..ad158d311ffa 100644
> --- a/net/sctp/transport.c
> +++ b/net/sctp/transport.c
> @@ -207,7 +207,8 @@ void sctp_transport_reset_hb_timer(struct sctp_transport *transport)
>  
>  	/* When a data chunk is sent, reset the heartbeat interval.  */
>  	expires = jiffies + sctp_transport_timeout(transport);
> -	if (time_before(transport->hb_timer.expires, expires) &&
> +	if ((time_before(transport->hb_timer.expires, expires) ||
> +	     !timer_pending(&transport->hb_timer)) &&
>  	    !mod_timer(&transport->hb_timer,
>  		       expires + prandom_u32_max(transport->rto)))
>  		sctp_transport_hold(transport);

-- 
Best regards,
Alexander Sverdlin.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sctp: don't compare hb_timer expire date before starting it
@ 2019-02-22 10:03   ` Sverdlin, Alexander (Nokia - DE/Ulm)
  0 siblings, 0 replies; 8+ messages in thread
From: Sverdlin, Alexander (Nokia - DE/Ulm) @ 2019-02-22 10:03 UTC (permalink / raw)
  To: kwiecienmaciek, linux-sctp; +Cc: netdev, Kwiecien, Maciej (Nokia - PL/Wroclaw)

T24gMjIvMDIvMjAxOSAwOTo0NSwga3dpZWNpZW5tYWNpZWtAZ21haWwuY29tIHdyb3RlOg0KPiBG
cm9tOiBNYWNpZWogS3dpZWNpZW4gPG1hY2llai5rd2llY2llbkBub2tpYS5jb20+DQo+IA0KPiBo
Yl90aW1lciBtaWdodCBub3Qgc3RhcnQgYXQgYWxsIGZvciBhIHBhcnRpY3VsYXIgdHJhbnNwb3J0
IGJlY2F1c2UgaXRzDQo+IHN0YXJ0IGlzIGNvbmRpdGlvbmFsLiBJbiBhIHJlc3VsdCBhIG5vZGUg
aXMgbm90IHNlbmRpbmcgaGVhcnRiZWF0cy4NCj4gDQo+IEZ1bmN0aW9uIHNjdHBfdHJhbnNw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nVjdCBzY3RwX3RyYW5zcG9ydCAqdHJhbnNwb3J0KQ0KPiAgDQo+ICAJLyogV2hl
biBhIGRhdGEgY2h1bmsgaXMgc2VudCwgcmVzZXQgdGhlIGhlYXJ0YmVhdCBpbnRlcnZhbC4gICov
DQo+ICAJZXhwaXJlcyA9IGppZmZpZXMgKyBzY3RwX3RyYW5zcG9ydF90aW1lb3V0KHRyYW5zcG9y
dCk7DQo+IC0JaWYgKHRpbWVfYmVmb3JlKHRyYW5zcG9ydC0+aGJfdGltZXIuZXhwaXJlcywgZXhw
aXJlcykgJiYNCj4gKwlpZiAoKHRpbWVfYmVmb3JlKHRyYW5zcG9ydC0+aGJfdGltZXIuZXhwaXJl
cywgZXhwaXJlcykgfHwNCj4gKwkgICAgICF0aW1lcl9wZW5kaW5nKCZ0cmFuc3BvcnQtPmhiX3Rp
bWVyKSkgJiYNCj4gIAkgICAgIW1vZF90aW1lcigmdHJhbnNwb3J0LT5oYl90aW1lciwNCj4gIAkJ
ICAgICAgIGV4cGlyZXMgKyBwcmFuZG9tX3UzMl9tYXgodHJhbnNwb3J0LT5ydG8pKSkNCj4gIAkJ
c2N0cF90cmFuc3BvcnRfaG9sZCh0cmFuc3BvcnQpOw0KDQotLSANCkJlc3QgcmVnYXJkcywNCkFs
ZXhhbmRlciBTdmVyZGxpbi4NCg=

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sctp: don't compare hb_timer expire date before starting it
  2019-02-22  8:45 ` kwiecienmaciek
@ 2019-02-22 12:49   ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 8+ messages in thread
From: Marcelo Ricardo Leitner @ 2019-02-22 12:49 UTC (permalink / raw)
  To: kwiecienmaciek; +Cc: linux-sctp, netdev, alexander.sverdlin, Maciej Kwiecien

On Fri, Feb 22, 2019 at 09:45:26AM +0100, kwiecienmaciek@gmail.com wrote:
> From: Maciej Kwiecien <maciej.kwiecien@nokia.com>
> 
> hb_timer might not start at all for a particular transport because its
> start is conditional. In a result a node is not sending heartbeats.
> 
> Function sctp_transport_reset_hb_timer has two roles:
>     - initial start of hb_timer for a given transport,
>     - update expire date of hb_timer for a given transport.
> The function is optimized to update timer's expire only if it is before
> a new calculated one but this comparison is invalid for a timer which
> has not yet started. Such a timer has expire == 0 and if a new expire
> value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will
> fail and timer will not start resulting in no heartbeat packets send by
> the node.
> 
> This was found when association was initialized within first 5 mins
> after system boot due to jiffies init value which is near to MAX_JIFFIES.
> 
> Test kernel version: 4.9.154 (ARCH=arm)
> hb_timer.expire = 0;                //initialized, not started timer
> new_expire = MAX_JIFFIES / 2 + 2;   //or more
> time_before(hb_timer.expire, new_expire) == false
> 
> Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
> Reported-by: Marcin Stojek <marcin.stojek@nokia.com>
> Tested-by: Marcin Stojek <marcin.stojek@nokia.com>
> Signed-off-by: Maciej Kwiecien <maciej.kwiecien@nokia.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  net/sctp/transport.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sctp/transport.c b/net/sctp/transport.c
> index 033696e6f74f..ad158d311ffa 100644
> --- a/net/sctp/transport.c
> +++ b/net/sctp/transport.c
> @@ -207,7 +207,8 @@ void sctp_transport_reset_hb_timer(struct sctp_transport *transport)
>  
>  	/* When a data chunk is sent, reset the heartbeat interval.  */
>  	expires = jiffies + sctp_transport_timeout(transport);
> -	if (time_before(transport->hb_timer.expires, expires) &&
> +	if ((time_before(transport->hb_timer.expires, expires) ||
> +	     !timer_pending(&transport->hb_timer)) &&
>  	    !mod_timer(&transport->hb_timer,
>  		       expires + prandom_u32_max(transport->rto)))
>  		sctp_transport_hold(transport);
> -- 
> 2.14.1
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sctp: don't compare hb_timer expire date before starting it
@ 2019-02-22 12:49   ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 8+ messages in thread
From: Marcelo Ricardo Leitner @ 2019-02-22 12:49 UTC (permalink / raw)
  To: kwiecienmaciek; +Cc: linux-sctp, netdev, alexander.sverdlin, Maciej Kwiecien

On Fri, Feb 22, 2019 at 09:45:26AM +0100, kwiecienmaciek@gmail.com wrote:
> From: Maciej Kwiecien <maciej.kwiecien@nokia.com>
> 
> hb_timer might not start at all for a particular transport because its
> start is conditional. In a result a node is not sending heartbeats.
> 
> Function sctp_transport_reset_hb_timer has two roles:
>     - initial start of hb_timer for a given transport,
>     - update expire date of hb_timer for a given transport.
> The function is optimized to update timer's expire only if it is before
> a new calculated one but this comparison is invalid for a timer which
> has not yet started. Such a timer has expire = 0 and if a new expire
> value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will
> fail and timer will not start resulting in no heartbeat packets send by
> the node.
> 
> This was found when association was initialized within first 5 mins
> after system boot due to jiffies init value which is near to MAX_JIFFIES.
> 
> Test kernel version: 4.9.154 (ARCH=arm)
> hb_timer.expire = 0;                //initialized, not started timer
> new_expire = MAX_JIFFIES / 2 + 2;   //or more
> time_before(hb_timer.expire, new_expire) = false
> 
> Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
> Reported-by: Marcin Stojek <marcin.stojek@nokia.com>
> Tested-by: Marcin Stojek <marcin.stojek@nokia.com>
> Signed-off-by: Maciej Kwiecien <maciej.kwiecien@nokia.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  net/sctp/transport.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sctp/transport.c b/net/sctp/transport.c
> index 033696e6f74f..ad158d311ffa 100644
> --- a/net/sctp/transport.c
> +++ b/net/sctp/transport.c
> @@ -207,7 +207,8 @@ void sctp_transport_reset_hb_timer(struct sctp_transport *transport)
>  
>  	/* When a data chunk is sent, reset the heartbeat interval.  */
>  	expires = jiffies + sctp_transport_timeout(transport);
> -	if (time_before(transport->hb_timer.expires, expires) &&
> +	if ((time_before(transport->hb_timer.expires, expires) ||
> +	     !timer_pending(&transport->hb_timer)) &&
>  	    !mod_timer(&transport->hb_timer,
>  		       expires + prandom_u32_max(transport->rto)))
>  		sctp_transport_hold(transport);
> -- 
> 2.14.1
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sctp: don't compare hb_timer expire date before starting it
  2019-02-22  8:45 ` kwiecienmaciek
@ 2019-02-22 19:22   ` David Miller
  -1 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2019-02-22 19:22 UTC (permalink / raw)
  To: kwiecienmaciek; +Cc: linux-sctp, netdev, alexander.sverdlin, maciej.kwiecien

From: kwiecienmaciek@gmail.com
Date: Fri, 22 Feb 2019 09:45:26 +0100

> From: Maciej Kwiecien <maciej.kwiecien@nokia.com>
> 
> hb_timer might not start at all for a particular transport because its
> start is conditional. In a result a node is not sending heartbeats.
> 
> Function sctp_transport_reset_hb_timer has two roles:
>     - initial start of hb_timer for a given transport,
>     - update expire date of hb_timer for a given transport.
> The function is optimized to update timer's expire only if it is before
> a new calculated one but this comparison is invalid for a timer which
> has not yet started. Such a timer has expire == 0 and if a new expire
> value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will
> fail and timer will not start resulting in no heartbeat packets send by
> the node.
> 
> This was found when association was initialized within first 5 mins
> after system boot due to jiffies init value which is near to MAX_JIFFIES.
> 
> Test kernel version: 4.9.154 (ARCH=arm)
> hb_timer.expire = 0;                //initialized, not started timer
> new_expire = MAX_JIFFIES / 2 + 2;   //or more
> time_before(hb_timer.expire, new_expire) == false
> 
> Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
> Reported-by: Marcin Stojek <marcin.stojek@nokia.com>
> Tested-by: Marcin Stojek <marcin.stojek@nokia.com>
> Signed-off-by: Maciej Kwiecien <maciej.kwiecien@nokia.com>

Applied and queued up for -stable, thank you.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sctp: don't compare hb_timer expire date before starting it
@ 2019-02-22 19:22   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2019-02-22 19:22 UTC (permalink / raw)
  To: kwiecienmaciek; +Cc: linux-sctp, netdev, alexander.sverdlin, maciej.kwiecien

From: kwiecienmaciek@gmail.com
Date: Fri, 22 Feb 2019 09:45:26 +0100

> From: Maciej Kwiecien <maciej.kwiecien@nokia.com>
> 
> hb_timer might not start at all for a particular transport because its
> start is conditional. In a result a node is not sending heartbeats.
> 
> Function sctp_transport_reset_hb_timer has two roles:
>     - initial start of hb_timer for a given transport,
>     - update expire date of hb_timer for a given transport.
> The function is optimized to update timer's expire only if it is before
> a new calculated one but this comparison is invalid for a timer which
> has not yet started. Such a timer has expire = 0 and if a new expire
> value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will
> fail and timer will not start resulting in no heartbeat packets send by
> the node.
> 
> This was found when association was initialized within first 5 mins
> after system boot due to jiffies init value which is near to MAX_JIFFIES.
> 
> Test kernel version: 4.9.154 (ARCH=arm)
> hb_timer.expire = 0;                //initialized, not started timer
> new_expire = MAX_JIFFIES / 2 + 2;   //or more
> time_before(hb_timer.expire, new_expire) = false
> 
> Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
> Reported-by: Marcin Stojek <marcin.stojek@nokia.com>
> Tested-by: Marcin Stojek <marcin.stojek@nokia.com>
> Signed-off-by: Maciej Kwiecien <maciej.kwiecien@nokia.com>

Applied and queued up for -stable, thank you.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-22 19:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22  8:45 [PATCH] sctp: don't compare hb_timer expire date before starting it kwiecienmaciek
2019-02-22  8:45 ` kwiecienmaciek
2019-02-22 10:03 ` Sverdlin, Alexander (Nokia - DE/Ulm)
2019-02-22 10:03   ` Sverdlin, Alexander (Nokia - DE/Ulm)
2019-02-22 12:49 ` Marcelo Ricardo Leitner
2019-02-22 12:49   ` Marcelo Ricardo Leitner
2019-02-22 19:22 ` David Miller
2019-02-22 19:22   ` David Miller

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.