Skip to content

Commit 46cb01e

Browse files
Hoang Ledavem330
Hoang Le
authored andcommitted
tipc: update mon's self addr when node addr generated
In commit 25b0b9c ("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: 25b0b9c ("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>
1 parent 0320d1e commit 46cb01e

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

net/tipc/monitor.c

+15
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,21 @@ void tipc_mon_delete(struct net *net, int bearer_id)
665665
kfree(mon);
666666
}
667667

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+
668683
int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size)
669684
{
670685
struct tipc_net *tn = tipc_net(net);

net/tipc/monitor.h

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ int __tipc_nl_add_monitor(struct net *net, struct tipc_nl_msg *msg,
7777
u32 bearer_id);
7878
int tipc_nl_add_monitor_peer(struct net *net, struct tipc_nl_msg *msg,
7979
u32 bearer_id, u32 *prev_node);
80+
void tipc_mon_reinit_self(struct net *net);
8081

8182
extern const int tipc_max_domain_size;
8283
#endif

net/tipc/net.c

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "node.h"
4343
#include "bcast.h"
4444
#include "netlink.h"
45+
#include "monitor.h"
4546

4647
/*
4748
* 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)
136137
tipc_set_node_addr(net, addr);
137138
tipc_named_reinit(net);
138139
tipc_sk_reinit(net);
140+
tipc_mon_reinit_self(net);
139141
tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
140142
TIPC_CLUSTER_SCOPE, 0, addr);
141143
}

0 commit comments

Comments
 (0)