diff mbox series

hsr: fix don't prune the master node from the node_db

Message ID 20190521105241.16234-1-andreas.oetken@siemens.com
State Changes Requested
Delegated to: David Miller
Headers show
Series hsr: fix don't prune the master node from the node_db | expand

Commit Message

Andreas Oetken May 21, 2019, 10:52 a.m. UTC
Don't prune master node in the hsr_prune_nodes function.
Neither time_in[HSR_PT_SLAVE_A], nor time_in[HSR_PT_SLAVE_B],
will ever be updated by hsr_register_frame_in for the master port.
Thus the master node will be repeatedly pruned leading to
repeated packet loss.
This bug never appeared because the hsr_prune_nodes function
was only called once. Since commit 5150b45fd355
("net: hsr: Fix node prune function for forget time expiry") this issue
is fixed unvealing the issue described above.

Signed-off-by: Andreas Oetken <andreas.oetken@siemens.com>
---
 net/hsr/hsr_framereg.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Murali Karicheri May 21, 2019, 3:46 p.m. UTC | #1
Hi Andreas,

On 05/21/2019 06:52 AM, Andreas Oetken wrote:
> Don't prune master node in the hsr_prune_nodes function.
> Neither time_in[HSR_PT_SLAVE_A], nor time_in[HSR_PT_SLAVE_B],
> will ever be updated by hsr_register_frame_in for the master port.
> Thus the master node will be repeatedly pruned leading to
> repeated packet loss.
> This bug never appeared because the hsr_prune_nodes function
> was only called once. Since commit 5150b45fd355
> ("net: hsr: Fix node prune function for forget time expiry") this issue
> is fixed unvealing the issue described above.
> 
> Signed-off-by: Andreas Oetken <andreas.oetken@siemens.com>
> ---
>   net/hsr/hsr_framereg.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
> index 9af16cb68f76..317cddda494e 100644
> --- a/net/hsr/hsr_framereg.c
> +++ b/net/hsr/hsr_framereg.c
> @@ -387,6 +387,14 @@ void hsr_prune_nodes(struct timer_list *t)
>   
>   	rcu_read_lock();
>   	list_for_each_entry_rcu(node, &hsr->node_db, mac_list) {
> +		/* Don't prune own node. Neither time_in[HSR_PT_SLAVE_A]
> +		 * nor time_in[HSR_PT_SLAVE_B], will ever be updated for
> +		 * the master port. Thus the master node will be repeatedly
> +		 * pruned leading to packet loss.
> +		 */
> +		if (hsr_addr_is_self(hsr, node->MacAddressA))
This gives me a compilation issue in the latest master branch

   AR      drivers/base/regmap/built-in.a
   AR      drivers/base/built-in.a
net/hsr/hsr_framereg.c: In function ‘hsr_prune_nodes’:
net/hsr/hsr_framereg.c:373:35: error: ‘struct hsr_node’ has no member 
named ‘MacAddressA’; did you mean ‘macaddress_A’?
    if (hsr_addr_is_self(hsr, node->MacAddressA))
                                    ^~~~~~~~~~~
                                    macaddress_A
   CC      net/core/gen_stats.o
scripts/Makefile.build:278: recipe for target 'net/hsr/hsr_framereg.o' 
failed

Could you address it and re-send?

Thanks

Murali
> +			continue;
> +
>   		/* Shorthand */
>   		time_a = node->time_in[HSR_PT_SLAVE_A];
>   		time_b = node->time_in[HSR_PT_SLAVE_B];
>
diff mbox series

Patch

diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index 9af16cb68f76..317cddda494e 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -387,6 +387,14 @@  void hsr_prune_nodes(struct timer_list *t)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(node, &hsr->node_db, mac_list) {
+		/* Don't prune own node. Neither time_in[HSR_PT_SLAVE_A]
+		 * nor time_in[HSR_PT_SLAVE_B], will ever be updated for
+		 * the master port. Thus the master node will be repeatedly
+		 * pruned leading to packet loss.
+		 */
+		if (hsr_addr_is_self(hsr, node->MacAddressA))
+			continue;
+
 		/* Shorthand */
 		time_a = node->time_in[HSR_PT_SLAVE_A];
 		time_b = node->time_in[HSR_PT_SLAVE_B];