Skip to content

Commit 10c3c02

Browse files
committed
Merge branch 'tipc-fixes'
Jon Maloy says: ==================== tipc: name distributor pernet queue Commit rib#1 fixes a potential issue with deferred binding table updates being pushed to the wrong namespace. Commit rib#2 solves a problem with deferred binding table updates remaining in the the defer queue after the issuing node has gone down. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ebf4dc2 + ddb1d33 commit 10c3c02

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

net/tipc/core.c

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static int __net_init tipc_init_net(struct net *net)
6969
if (err)
7070
goto out_nametbl;
7171

72+
INIT_LIST_HEAD(&tn->dist_queue);
7273
err = tipc_topsrv_start(net);
7374
if (err)
7475
goto out_subscr;

net/tipc/core.h

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ struct tipc_net {
103103
spinlock_t nametbl_lock;
104104
struct name_table *nametbl;
105105

106+
/* Name dist queue */
107+
struct list_head dist_queue;
108+
106109
/* Topology subscription server */
107110
struct tipc_server *topsrv;
108111
atomic_t subscription_count;

net/tipc/name_distr.c

+26-9
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@
4040

4141
int sysctl_tipc_named_timeout __read_mostly = 2000;
4242

43-
/**
44-
* struct tipc_dist_queue - queue holding deferred name table updates
45-
*/
46-
static struct list_head tipc_dist_queue = LIST_HEAD_INIT(tipc_dist_queue);
47-
4843
struct distr_queue_item {
4944
struct distr_item i;
5045
u32 dtype;
@@ -229,12 +224,31 @@ static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr)
229224
kfree_rcu(p, rcu);
230225
}
231226

227+
/**
228+
* tipc_dist_queue_purge - remove deferred updates from a node that went down
229+
*/
230+
static void tipc_dist_queue_purge(struct net *net, u32 addr)
231+
{
232+
struct tipc_net *tn = net_generic(net, tipc_net_id);
233+
struct distr_queue_item *e, *tmp;
234+
235+
spin_lock_bh(&tn->nametbl_lock);
236+
list_for_each_entry_safe(e, tmp, &tn->dist_queue, next) {
237+
if (e->node != addr)
238+
continue;
239+
list_del(&e->next);
240+
kfree(e);
241+
}
242+
spin_unlock_bh(&tn->nametbl_lock);
243+
}
244+
232245
void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr)
233246
{
234247
struct publication *publ, *tmp;
235248

236249
list_for_each_entry_safe(publ, tmp, nsub_list, nodesub_list)
237250
tipc_publ_purge(net, publ, addr);
251+
tipc_dist_queue_purge(net, addr);
238252
}
239253

240254
/**
@@ -279,9 +293,11 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
279293
* tipc_named_add_backlog - add a failed name table update to the backlog
280294
*
281295
*/
282-
static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
296+
static void tipc_named_add_backlog(struct net *net, struct distr_item *i,
297+
u32 type, u32 node)
283298
{
284299
struct distr_queue_item *e;
300+
struct tipc_net *tn = net_generic(net, tipc_net_id);
285301
unsigned long now = get_jiffies_64();
286302

287303
e = kzalloc(sizeof(*e), GFP_ATOMIC);
@@ -291,7 +307,7 @@ static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
291307
e->node = node;
292308
e->expires = now + msecs_to_jiffies(sysctl_tipc_named_timeout);
293309
memcpy(e, i, sizeof(*i));
294-
list_add_tail(&e->next, &tipc_dist_queue);
310+
list_add_tail(&e->next, &tn->dist_queue);
295311
}
296312

297313
/**
@@ -301,10 +317,11 @@ static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
301317
void tipc_named_process_backlog(struct net *net)
302318
{
303319
struct distr_queue_item *e, *tmp;
320+
struct tipc_net *tn = net_generic(net, tipc_net_id);
304321
char addr[16];
305322
unsigned long now = get_jiffies_64();
306323

307-
list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) {
324+
list_for_each_entry_safe(e, tmp, &tn->dist_queue, next) {
308325
if (time_after(e->expires, now)) {
309326
if (!tipc_update_nametbl(net, &e->i, e->node, e->dtype))
310327
continue;
@@ -344,7 +361,7 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *inputq)
344361
node = msg_orignode(msg);
345362
while (count--) {
346363
if (!tipc_update_nametbl(net, item, node, mtype))
347-
tipc_named_add_backlog(item, mtype, node);
364+
tipc_named_add_backlog(net, item, mtype, node);
348365
item++;
349366
}
350367
kfree_skb(skb);

0 commit comments

Comments
 (0)