]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tipc: update mon's self addr when node addr generated
authorHoang Le <hoang.h.le@dektech.com.au>
Tue, 12 Nov 2019 00:40:04 +0000 (07:40 +0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:49:52 +0000 (14:49 +0100)
commit 46cb01eeeb86fca6afe24dda1167b0cb95424e29 upstream.

In commit 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address
hash values"), the 32-bit node address only generated after one second
trial period expired. However the self's addr in struct tipc_monitor do
not update according to node address generated. This lead to it is
always zero as initial value. As result, sorting algorithm using this
value does not work as expected, neither neighbor monitoring framework.

In this commit, we add a fix to update self's addr when 32-bit node
address generated.

Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values")
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/tipc/monitor.c
net/tipc/monitor.h
net/tipc/net.c

index 67f69389ec179bff3518b35c9d546685d9d2bc41..23706ee166074ffdd838c7f7a483d4e2fd186018 100644 (file)
@@ -665,6 +665,21 @@ void tipc_mon_delete(struct net *net, int bearer_id)
        kfree(mon);
 }
 
+void tipc_mon_reinit_self(struct net *net)
+{
+       struct tipc_monitor *mon;
+       int bearer_id;
+
+       for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) {
+               mon = tipc_monitor(net, bearer_id);
+               if (!mon)
+                       continue;
+               write_lock_bh(&mon->lock);
+               mon->self->addr = tipc_own_addr(net);
+               write_unlock_bh(&mon->lock);
+       }
+}
+
 int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size)
 {
        struct tipc_net *tn = tipc_net(net);
index 2a21b93e0d04a204d4f6375647e2dfc9ea94a4f2..ed63d2e650b08309da785bd5d26ac6d4a0f8157d 100644 (file)
@@ -77,6 +77,7 @@ int __tipc_nl_add_monitor(struct net *net, struct tipc_nl_msg *msg,
                          u32 bearer_id);
 int tipc_nl_add_monitor_peer(struct net *net, struct tipc_nl_msg *msg,
                             u32 bearer_id, u32 *prev_node);
+void tipc_mon_reinit_self(struct net *net);
 
 extern const int tipc_max_domain_size;
 #endif
index 7ce1e86b024f09cb7345840d4a4d8e3949c5107d..2e2e938fe4b7b1f43747f7599d8dc582eadfce99 100644 (file)
@@ -42,6 +42,7 @@
 #include "node.h"
 #include "bcast.h"
 #include "netlink.h"
+#include "monitor.h"
 
 /*
  * The TIPC locking policy is designed to ensure a very fine locking
@@ -136,6 +137,7 @@ static void tipc_net_finalize(struct net *net, u32 addr)
        tipc_set_node_addr(net, addr);
        tipc_named_reinit(net);
        tipc_sk_reinit(net);
+       tipc_mon_reinit_self(net);
        tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
                             TIPC_CLUSTER_SCOPE, 0, addr);
 }