Skip to content

Commit 3f31559

Browse files
Hugnegregkh
authored andcommitted
tipc: make dist queue pernet
commit 541726abe7daca64390c2ec34e6a203145f1686d upstream. Nametable updates received from the network that cannot be applied immediately are placed on a defer queue. This queue is global to the TIPC module, which might cause problems when using TIPC in containers. To prevent nametable updates from escaping into the wrong namespace, we make the queue pernet instead. Signed-off-by: Erik Hugne <erik.hugne@gmail.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 44b3b7e commit 3f31559

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

net/tipc/core.c

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 7 additions & 9 deletions
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;
@@ -340,9 +335,11 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
340335
* tipc_named_add_backlog - add a failed name table update to the backlog
341336
*
342337
*/
343-
static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
338+
static void tipc_named_add_backlog(struct net *net, struct distr_item *i,
339+
u32 type, u32 node)
344340
{
345341
struct distr_queue_item *e;
342+
struct tipc_net *tn = net_generic(net, tipc_net_id);
346343
unsigned long now = get_jiffies_64();
347344

348345
e = kzalloc(sizeof(*e), GFP_ATOMIC);
@@ -352,7 +349,7 @@ static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
352349
e->node = node;
353350
e->expires = now + msecs_to_jiffies(sysctl_tipc_named_timeout);
354351
memcpy(e, i, sizeof(*i));
355-
list_add_tail(&e->next, &tipc_dist_queue);
352+
list_add_tail(&e->next, &tn->dist_queue);
356353
}
357354

358355
/**
@@ -362,10 +359,11 @@ static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
362359
void tipc_named_process_backlog(struct net *net)
363360
{
364361
struct distr_queue_item *e, *tmp;
362+
struct tipc_net *tn = net_generic(net, tipc_net_id);
365363
char addr[16];
366364
unsigned long now = get_jiffies_64();
367365

368-
list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) {
366+
list_for_each_entry_safe(e, tmp, &tn->dist_queue, next) {
369367
if (time_after(e->expires, now)) {
370368
if (!tipc_update_nametbl(net, &e->i, e->node, e->dtype))
371369
continue;
@@ -405,7 +403,7 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *inputq)
405403
node = msg_orignode(msg);
406404
while (count--) {
407405
if (!tipc_update_nametbl(net, item, node, mtype))
408-
tipc_named_add_backlog(item, mtype, node);
406+
tipc_named_add_backlog(net, item, mtype, node);
409407
item++;
410408
}
411409
kfree_skb(skb);

0 commit comments

Comments
 (0)