Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tipc: update mon's self addr when node addr generated

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>

authored by

Hoang Le and committed by
David S. Miller
46cb01ee 0320d1e7

+18
+15
net/tipc/monitor.c
··· 665 665 kfree(mon); 666 666 } 667 667 668 + void tipc_mon_reinit_self(struct net *net) 669 + { 670 + struct tipc_monitor *mon; 671 + int bearer_id; 672 + 673 + for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) { 674 + mon = tipc_monitor(net, bearer_id); 675 + if (!mon) 676 + continue; 677 + write_lock_bh(&mon->lock); 678 + mon->self->addr = tipc_own_addr(net); 679 + write_unlock_bh(&mon->lock); 680 + } 681 + } 682 + 668 683 int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size) 669 684 { 670 685 struct tipc_net *tn = tipc_net(net);
+1
net/tipc/monitor.h
··· 77 77 u32 bearer_id); 78 78 int tipc_nl_add_monitor_peer(struct net *net, struct tipc_nl_msg *msg, 79 79 u32 bearer_id, u32 *prev_node); 80 + void tipc_mon_reinit_self(struct net *net); 80 81 81 82 extern const int tipc_max_domain_size; 82 83 #endif
+2
net/tipc/net.c
··· 42 42 #include "node.h" 43 43 #include "bcast.h" 44 44 #include "netlink.h" 45 + #include "monitor.h" 45 46 46 47 /* 47 48 * The TIPC locking policy is designed to ensure a very fine locking ··· 137 136 tipc_set_node_addr(net, addr); 138 137 tipc_named_reinit(net); 139 138 tipc_sk_reinit(net); 139 + tipc_mon_reinit_self(net); 140 140 tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr, 141 141 TIPC_CLUSTER_SCOPE, 0, addr); 142 142 }