hsr: fix don’t prune the master node from the node_db [Linux 5.2]

hsr: fix don’t prune the master node from the node_db [Linux 5.2]

This Linux kernel change "hsr: fix don’t prune the master node from the node_db" is included in the Linux 5.2 release. This change is authored by Andreas Oetken <andreas.oetken [at] siemens.com> on Thu May 23 13:57:14 2019 +0200. The commit for this change in Linux stable tree is d2daa12 (patch).

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

Don't prune the 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 unveiling the issue described above.

Fixes: 5150b45fd355 ("net: hsr: Fix node prune function for forget time expiry")
Signed-off-by: Andreas Oetken <[email protected]>
Tested-by: Murali Karicheri <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 9fa9abd..2d7a197 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -365,6 +365,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->macaddress_A))
+           continue;
+
        /* Shorthand */
        time_a = node->time_in[HSR_PT_SLAVE_A];
        time_b = node->time_in[HSR_PT_SLAVE_B];

Leave a Reply

Your email address will not be published. Required fields are marked *