Commit 4ac1c8d0 authored by Ying Xue's avatar Ying Xue Committed by David S. Miller

tipc: name tipc name table support net namespace

TIPC name table is used to store the mapping relationship between
TIPC service name and socket port ID. When tipc supports namespace,
it allows users to publish service names only owned by a certain
namespace. Therefore, every namespace must have its private name
table to prevent service names published to one namespace from being
contaminated by other service names in another namespace. Therefore,
The name table global variable (ie, nametbl) and its lock must be
moved to tipc_net structure, and a parameter of namespace must be
added for necessary functions so that they can obtain name table
variable defined in tipc_net structure.
Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
Tested-by: default avatarTero Aho <Tero.Aho@coriant.com>
Reviewed-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e05b31f4
...@@ -248,7 +248,8 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, ...@@ -248,7 +248,8 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
req_tlv_space); req_tlv_space);
break; break;
case TIPC_CMD_SHOW_NAME_TABLE: case TIPC_CMD_SHOW_NAME_TABLE:
rep_tlv_buf = tipc_nametbl_get(req_tlv_area, req_tlv_space); rep_tlv_buf = tipc_nametbl_get(net, req_tlv_area,
req_tlv_space);
break; break;
case TIPC_CMD_GET_BEARER_NAMES: case TIPC_CMD_GET_BEARER_NAMES:
rep_tlv_buf = tipc_bearer_get_names(net); rep_tlv_buf = tipc_bearer_get_names(net);
......
...@@ -62,12 +62,24 @@ static int __net_init tipc_init_net(struct net *net) ...@@ -62,12 +62,24 @@ static int __net_init tipc_init_net(struct net *net)
spin_lock_init(&tn->node_list_lock); spin_lock_init(&tn->node_list_lock);
err = tipc_sk_rht_init(net); err = tipc_sk_rht_init(net);
if (err)
goto out_sk_rht;
err = tipc_nametbl_init(net);
if (err)
goto out_nametbl;
return 0;
out_nametbl:
tipc_sk_rht_destroy(net);
out_sk_rht:
return err; return err;
} }
static void __net_exit tipc_exit_net(struct net *net) static void __net_exit tipc_exit_net(struct net *net)
{ {
tipc_net_stop(net); tipc_net_stop(net);
tipc_nametbl_stop(net);
tipc_sk_rht_destroy(net); tipc_sk_rht_destroy(net);
} }
...@@ -98,10 +110,6 @@ static int __init tipc_init(void) ...@@ -98,10 +110,6 @@ static int __init tipc_init(void)
if (err) if (err)
goto out_pernet; goto out_pernet;
err = tipc_nametbl_init();
if (err)
goto out_nametbl;
err = tipc_netlink_start(); err = tipc_netlink_start();
if (err) if (err)
goto out_netlink; goto out_netlink;
...@@ -133,8 +141,6 @@ static int __init tipc_init(void) ...@@ -133,8 +141,6 @@ static int __init tipc_init(void)
out_socket: out_socket:
tipc_netlink_stop(); tipc_netlink_stop();
out_netlink: out_netlink:
tipc_nametbl_stop();
out_nametbl:
unregister_pernet_subsys(&tipc_net_ops); unregister_pernet_subsys(&tipc_net_ops);
out_pernet: out_pernet:
pr_err("Unable to start in single node mode\n"); pr_err("Unable to start in single node mode\n");
...@@ -147,7 +153,6 @@ static void __exit tipc_exit(void) ...@@ -147,7 +153,6 @@ static void __exit tipc_exit(void)
tipc_bearer_cleanup(); tipc_bearer_cleanup();
tipc_netlink_stop(); tipc_netlink_stop();
tipc_subscr_stop(); tipc_subscr_stop();
tipc_nametbl_stop();
tipc_socket_stop(); tipc_socket_stop();
tipc_unregister_sysctl(); tipc_unregister_sysctl();
......
...@@ -105,6 +105,10 @@ struct tipc_net { ...@@ -105,6 +105,10 @@ struct tipc_net {
/* Socket hash table */ /* Socket hash table */
struct rhashtable sk_rht; struct rhashtable sk_rht;
/* Name table */
spinlock_t nametbl_lock;
struct name_table *nametbl;
}; };
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
...@@ -426,7 +426,7 @@ bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err) ...@@ -426,7 +426,7 @@ bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err)
* Returns 0 (TIPC_OK) if message ok and we can try again, -TIPC error * Returns 0 (TIPC_OK) if message ok and we can try again, -TIPC error
* code if message to be rejected * code if message to be rejected
*/ */
int tipc_msg_eval(struct sk_buff *buf, u32 *dnode) int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode)
{ {
struct tipc_msg *msg = buf_msg(buf); struct tipc_msg *msg = buf_msg(buf);
u32 dport; u32 dport;
...@@ -441,7 +441,7 @@ int tipc_msg_eval(struct sk_buff *buf, u32 *dnode) ...@@ -441,7 +441,7 @@ int tipc_msg_eval(struct sk_buff *buf, u32 *dnode)
return -TIPC_ERR_NO_NAME; return -TIPC_ERR_NO_NAME;
*dnode = addr_domain(msg_lookup_scope(msg)); *dnode = addr_domain(msg_lookup_scope(msg));
dport = tipc_nametbl_translate(msg_nametype(msg), dport = tipc_nametbl_translate(net, msg_nametype(msg),
msg_nameinst(msg), msg_nameinst(msg),
dnode); dnode);
if (!dport) if (!dport)
......
...@@ -749,7 +749,7 @@ static inline u32 msg_tot_origport(struct tipc_msg *m) ...@@ -749,7 +749,7 @@ static inline u32 msg_tot_origport(struct tipc_msg *m)
struct sk_buff *tipc_buf_acquire(u32 size); struct sk_buff *tipc_buf_acquire(u32 size);
bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err); bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err);
int tipc_msg_eval(struct sk_buff *buf, u32 *dnode); int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode);
void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize, void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize,
u32 destnode); u32 destnode);
struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz, struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
......
...@@ -109,13 +109,14 @@ void named_cluster_distribute(struct net *net, struct sk_buff *skb) ...@@ -109,13 +109,14 @@ void named_cluster_distribute(struct net *net, struct sk_buff *skb)
/** /**
* tipc_named_publish - tell other nodes about a new publication by this node * tipc_named_publish - tell other nodes about a new publication by this node
*/ */
struct sk_buff *tipc_named_publish(struct publication *publ) struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct sk_buff *buf; struct sk_buff *buf;
struct distr_item *item; struct distr_item *item;
list_add_tail_rcu(&publ->local_list, list_add_tail_rcu(&publ->local_list,
&tipc_nametbl->publ_list[publ->scope]); &tn->nametbl->publ_list[publ->scope]);
if (publ->scope == TIPC_NODE_SCOPE) if (publ->scope == TIPC_NODE_SCOPE)
return NULL; return NULL;
...@@ -206,15 +207,16 @@ static void named_distribute(struct net *net, struct sk_buff_head *list, ...@@ -206,15 +207,16 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
*/ */
void tipc_named_node_up(struct net *net, u32 dnode) void tipc_named_node_up(struct net *net, u32 dnode)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct sk_buff_head head; struct sk_buff_head head;
__skb_queue_head_init(&head); __skb_queue_head_init(&head);
rcu_read_lock(); rcu_read_lock();
named_distribute(net, &head, dnode, named_distribute(net, &head, dnode,
&tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]); &tn->nametbl->publ_list[TIPC_CLUSTER_SCOPE]);
named_distribute(net, &head, dnode, named_distribute(net, &head, dnode,
&tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]); &tn->nametbl->publ_list[TIPC_ZONE_SCOPE]);
rcu_read_unlock(); rcu_read_unlock();
tipc_link_xmit(net, &head, dnode, dnode); tipc_link_xmit(net, &head, dnode, dnode);
...@@ -262,14 +264,15 @@ static void tipc_publ_unsubscribe(struct net *net, struct publication *publ, ...@@ -262,14 +264,15 @@ static void tipc_publ_unsubscribe(struct net *net, struct publication *publ,
*/ */
static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr) static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct publication *p; struct publication *p;
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
p = tipc_nametbl_remove_publ(publ->type, publ->lower, p = tipc_nametbl_remove_publ(net, publ->type, publ->lower,
publ->node, publ->ref, publ->key); publ->node, publ->ref, publ->key);
if (p) if (p)
tipc_publ_unsubscribe(net, p, addr); tipc_publ_unsubscribe(net, p, addr);
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
if (p != publ) { if (p != publ) {
pr_err("Unable to remove publication from failed node\n" pr_err("Unable to remove publication from failed node\n"
...@@ -302,7 +305,8 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i, ...@@ -302,7 +305,8 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
struct publication *publ = NULL; struct publication *publ = NULL;
if (dtype == PUBLICATION) { if (dtype == PUBLICATION) {
publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower), publ = tipc_nametbl_insert_publ(net, ntohl(i->type),
ntohl(i->lower),
ntohl(i->upper), ntohl(i->upper),
TIPC_CLUSTER_SCOPE, node, TIPC_CLUSTER_SCOPE, node,
ntohl(i->ref), ntohl(i->key)); ntohl(i->ref), ntohl(i->key));
...@@ -311,7 +315,8 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i, ...@@ -311,7 +315,8 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
return true; return true;
} }
} else if (dtype == WITHDRAWAL) { } else if (dtype == WITHDRAWAL) {
publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower), publ = tipc_nametbl_remove_publ(net, ntohl(i->type),
ntohl(i->lower),
node, ntohl(i->ref), node, ntohl(i->ref),
ntohl(i->key)); ntohl(i->key));
if (publ) { if (publ) {
...@@ -376,19 +381,20 @@ void tipc_named_process_backlog(struct net *net) ...@@ -376,19 +381,20 @@ void tipc_named_process_backlog(struct net *net)
*/ */
void tipc_named_rcv(struct net *net, struct sk_buff *buf) void tipc_named_rcv(struct net *net, struct sk_buff *buf)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct tipc_msg *msg = buf_msg(buf); struct tipc_msg *msg = buf_msg(buf);
struct distr_item *item = (struct distr_item *)msg_data(msg); struct distr_item *item = (struct distr_item *)msg_data(msg);
u32 count = msg_data_sz(msg) / ITEM_SIZE; u32 count = msg_data_sz(msg) / ITEM_SIZE;
u32 node = msg_orignode(msg); u32 node = msg_orignode(msg);
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
while (count--) { while (count--) {
if (!tipc_update_nametbl(net, item, node, msg_type(msg))) if (!tipc_update_nametbl(net, item, node, msg_type(msg)))
tipc_named_add_backlog(item, msg_type(msg), node); tipc_named_add_backlog(item, msg_type(msg), node);
item++; item++;
} }
tipc_named_process_backlog(net); tipc_named_process_backlog(net);
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
kfree_skb(buf); kfree_skb(buf);
} }
...@@ -399,17 +405,18 @@ void tipc_named_rcv(struct net *net, struct sk_buff *buf) ...@@ -399,17 +405,18 @@ void tipc_named_rcv(struct net *net, struct sk_buff *buf)
* All name table entries published by this node are updated to reflect * All name table entries published by this node are updated to reflect
* the node's new network address. * the node's new network address.
*/ */
void tipc_named_reinit(void) void tipc_named_reinit(struct net *net)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct publication *publ; struct publication *publ;
int scope; int scope;
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++) for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++)
list_for_each_entry_rcu(publ, &tipc_nametbl->publ_list[scope], list_for_each_entry_rcu(publ, &tn->nametbl->publ_list[scope],
local_list) local_list)
publ->node = tipc_own_addr; publ->node = tipc_own_addr;
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
} }
...@@ -67,12 +67,12 @@ struct distr_item { ...@@ -67,12 +67,12 @@ struct distr_item {
__be32 key; __be32 key;
}; };
struct sk_buff *tipc_named_publish(struct publication *publ); struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ);
struct sk_buff *tipc_named_withdraw(struct publication *publ); struct sk_buff *tipc_named_withdraw(struct publication *publ);
void named_cluster_distribute(struct net *net, struct sk_buff *buf); void named_cluster_distribute(struct net *net, struct sk_buff *buf);
void tipc_named_node_up(struct net *net, u32 dnode); void tipc_named_node_up(struct net *net, u32 dnode);
void tipc_named_rcv(struct net *net, struct sk_buff *buf); void tipc_named_rcv(struct net *net, struct sk_buff *buf);
void tipc_named_reinit(void); void tipc_named_reinit(struct net *net);
void tipc_named_process_backlog(struct net *net); void tipc_named_process_backlog(struct net *net);
void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr); void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <net/sock.h>
#include "core.h" #include "core.h"
#include "config.h" #include "config.h"
#include "name_table.h" #include "name_table.h"
...@@ -106,9 +107,6 @@ struct name_seq { ...@@ -106,9 +107,6 @@ struct name_seq {
struct rcu_head rcu; struct rcu_head rcu;
}; };
struct name_table *tipc_nametbl;
DEFINE_SPINLOCK(tipc_nametbl_lock);
static int hash(int x) static int hash(int x)
{ {
return x & (TIPC_NAMETBL_SIZE - 1); return x & (TIPC_NAMETBL_SIZE - 1);
...@@ -448,12 +446,13 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq, ...@@ -448,12 +446,13 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq,
} }
} }
static struct name_seq *nametbl_find_seq(u32 type) static struct name_seq *nametbl_find_seq(struct net *net, u32 type)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct hlist_head *seq_head; struct hlist_head *seq_head;
struct name_seq *ns; struct name_seq *ns;
seq_head = &tipc_nametbl->seq_hlist[hash(type)]; seq_head = &tn->nametbl->seq_hlist[hash(type)];
hlist_for_each_entry_rcu(ns, seq_head, ns_list) { hlist_for_each_entry_rcu(ns, seq_head, ns_list) {
if (ns->type == type) if (ns->type == type)
return ns; return ns;
...@@ -462,11 +461,13 @@ static struct name_seq *nametbl_find_seq(u32 type) ...@@ -462,11 +461,13 @@ static struct name_seq *nametbl_find_seq(u32 type)
return NULL; return NULL;
}; };
struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type,
u32 scope, u32 node, u32 port, u32 key) u32 lower, u32 upper, u32 scope,
u32 node, u32 port, u32 key)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct publication *publ; struct publication *publ;
struct name_seq *seq = nametbl_find_seq(type); struct name_seq *seq = nametbl_find_seq(net, type);
int index = hash(type); int index = hash(type);
if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) || if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) ||
...@@ -477,8 +478,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, ...@@ -477,8 +478,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
} }
if (!seq) if (!seq)
seq = tipc_nameseq_create(type, seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]);
&tipc_nametbl->seq_hlist[index]);
if (!seq) if (!seq)
return NULL; return NULL;
...@@ -489,11 +489,12 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, ...@@ -489,11 +489,12 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
return publ; return publ;
} }
struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
u32 node, u32 ref, u32 key) u32 lower, u32 node, u32 ref,
u32 key)
{ {
struct publication *publ; struct publication *publ;
struct name_seq *seq = nametbl_find_seq(type); struct name_seq *seq = nametbl_find_seq(net, type);
if (!seq) if (!seq)
return NULL; return NULL;
...@@ -524,7 +525,8 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, ...@@ -524,7 +525,8 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
* - if name translation is attempted and fails, sets 'destnode' to 0 * - if name translation is attempted and fails, sets 'destnode' to 0
* and returns 0 * and returns 0
*/ */
u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance,
u32 *destnode)
{ {
struct sub_seq *sseq; struct sub_seq *sseq;
struct name_info *info; struct name_info *info;
...@@ -537,7 +539,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) ...@@ -537,7 +539,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
return 0; return 0;
rcu_read_lock(); rcu_read_lock();
seq = nametbl_find_seq(type); seq = nametbl_find_seq(net, type);
if (unlikely(!seq)) if (unlikely(!seq))
goto not_found; goto not_found;
spin_lock_bh(&seq->lock); spin_lock_bh(&seq->lock);
...@@ -610,8 +612,8 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) ...@@ -610,8 +612,8 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
* *
* Returns non-zero if any off-node ports overlap * Returns non-zero if any off-node ports overlap
*/ */
int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, int tipc_nametbl_mc_translate(struct net *net, u32 type, u32 lower, u32 upper,
struct tipc_port_list *dports) u32 limit, struct tipc_port_list *dports)
{ {
struct name_seq *seq; struct name_seq *seq;
struct sub_seq *sseq; struct sub_seq *sseq;
...@@ -620,7 +622,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, ...@@ -620,7 +622,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
int res = 0; int res = 0;
rcu_read_lock(); rcu_read_lock();
seq = nametbl_find_seq(type); seq = nametbl_find_seq(net, type);
if (!seq) if (!seq)
goto exit; goto exit;
...@@ -657,24 +659,25 @@ struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, ...@@ -657,24 +659,25 @@ struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower,
{ {
struct publication *publ; struct publication *publ;
struct sk_buff *buf = NULL; struct sk_buff *buf = NULL;
struct tipc_net *tn = net_generic(net, tipc_net_id);
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
if (tipc_nametbl->local_publ_count >= TIPC_MAX_PUBLICATIONS) { if (tn->nametbl->local_publ_count >= TIPC_MAX_PUBLICATIONS) {
pr_warn("Publication failed, local publication limit reached (%u)\n", pr_warn("Publication failed, local publication limit reached (%u)\n",
TIPC_MAX_PUBLICATIONS); TIPC_MAX_PUBLICATIONS);
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
return NULL; return NULL;
} }
publ = tipc_nametbl_insert_publ(type, lower, upper, scope, publ = tipc_nametbl_insert_publ(net, type, lower, upper, scope,
tipc_own_addr, port_ref, key); tipc_own_addr, port_ref, key);
if (likely(publ)) { if (likely(publ)) {
tipc_nametbl->local_publ_count++; tn->nametbl->local_publ_count++;
buf = tipc_named_publish(publ); buf = tipc_named_publish(net, publ);
/* Any pending external events? */ /* Any pending external events? */
tipc_named_process_backlog(net); tipc_named_process_backlog(net);
} }
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
if (buf) if (buf)
named_cluster_distribute(net, buf); named_cluster_distribute(net, buf);
...@@ -689,11 +692,13 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, ...@@ -689,11 +692,13 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
{ {
struct publication *publ; struct publication *publ;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct tipc_net *tn = net_generic(net, tipc_net_id);
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); publ = tipc_nametbl_remove_publ(net, type, lower, tipc_own_addr,
ref, key);
if (likely(publ)) { if (likely(publ)) {
tipc_nametbl->local_publ_count--; tn->nametbl->local_publ_count--;
skb = tipc_named_withdraw(publ); skb = tipc_named_withdraw(publ);
/* Any pending external events? */ /* Any pending external events? */
tipc_named_process_backlog(net); tipc_named_process_backlog(net);
...@@ -704,7 +709,7 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, ...@@ -704,7 +709,7 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
"(type=%u, lower=%u, ref=%u, key=%u)\n", "(type=%u, lower=%u, ref=%u, key=%u)\n",
type, lower, ref, key); type, lower, ref, key);
} }
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
if (skb) { if (skb) {
named_cluster_distribute(net, skb); named_cluster_distribute(net, skb);
...@@ -718,15 +723,15 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, ...@@ -718,15 +723,15 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
*/ */
void tipc_nametbl_subscribe(struct tipc_subscription *s) void tipc_nametbl_subscribe(struct tipc_subscription *s)
{ {
struct tipc_net *tn = net_generic(s->net, tipc_net_id);
u32 type = s->seq.type; u32 type = s->seq.type;
int index = hash(type); int index = hash(type);
struct name_seq *seq; struct name_seq *seq;
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
seq = nametbl_find_seq(type); seq = nametbl_find_seq(s->net, type);
if (!seq) if (!seq)
seq = tipc_nameseq_create(type, seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]);
&tipc_nametbl->seq_hlist[index]);
if (seq) { if (seq) {
spin_lock_bh(&seq->lock); spin_lock_bh(&seq->lock);
tipc_nameseq_subscribe(seq, s); tipc_nameseq_subscribe(seq, s);
...@@ -735,7 +740,7 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s) ...@@ -735,7 +740,7 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
pr_warn("Failed to create subscription for {%u,%u,%u}\n", pr_warn("Failed to create subscription for {%u,%u,%u}\n",
s->seq.type, s->seq.lower, s->seq.upper); s->seq.type, s->seq.lower, s->seq.upper);
} }
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
} }
/** /**
...@@ -743,10 +748,11 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s) ...@@ -743,10 +748,11 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
*/ */
void tipc_nametbl_unsubscribe(struct tipc_subscription *s) void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
{ {
struct tipc_net *tn = net_generic(s->net, tipc_net_id);
struct name_seq *seq; struct name_seq *seq;
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
seq = nametbl_find_seq(s->seq.type); seq = nametbl_find_seq(s->net, s->seq.type);
if (seq != NULL) { if (seq != NULL) {
spin_lock_bh(&seq->lock); spin_lock_bh(&seq->lock);
list_del_init(&s->nameseq_list); list_del_init(&s->nameseq_list);
...@@ -759,7 +765,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s) ...@@ -759,7 +765,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
spin_unlock_bh(&seq->lock); spin_unlock_bh(&seq->lock);
} }
} }
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
} }
/** /**
...@@ -861,9 +867,10 @@ static int nametbl_header(char *buf, int len, u32 depth) ...@@ -861,9 +867,10 @@ static int nametbl_header(char *buf, int len, u32 depth)
/** /**
* nametbl_list - print specified name table contents into the given buffer * nametbl_list - print specified name table contents into the given buffer
*/ */
static int nametbl_list(char *buf, int len, u32 depth_info, static int nametbl_list(struct net *net, char *buf, int len, u32 depth_info,
u32 type, u32 lowbound, u32 upbound) u32 type, u32 lowbound, u32 upbound)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct hlist_head *seq_head; struct hlist_head *seq_head;
struct name_seq *seq; struct name_seq *seq;
int all_types; int all_types;
...@@ -883,7 +890,7 @@ static int nametbl_list(char *buf, int len, u32 depth_info, ...@@ -883,7 +890,7 @@ static int nametbl_list(char *buf, int len, u32 depth_info,
lowbound = 0; lowbound = 0;
upbound = ~0; upbound = ~0;
for (i = 0; i < TIPC_NAMETBL_SIZE; i++) { for (i = 0; i < TIPC_NAMETBL_SIZE; i++) {
seq_head = &tipc_nametbl->seq_hlist[i]; seq_head = &tn->nametbl->seq_hlist[i];
hlist_for_each_entry_rcu(seq, seq_head, ns_list) { hlist_for_each_entry_rcu(seq, seq_head, ns_list) {
ret += nameseq_list(seq, buf + ret, len - ret, ret += nameseq_list(seq, buf + ret, len - ret,
depth, seq->type, depth, seq->type,
...@@ -899,7 +906,7 @@ static int nametbl_list(char *buf, int len, u32 depth_info, ...@@ -899,7 +906,7 @@ static int nametbl_list(char *buf, int len, u32 depth_info,
} }
ret += nametbl_header(buf + ret, len - ret, depth); ret += nametbl_header(buf + ret, len - ret, depth);
i = hash(type); i = hash(type);
seq_head = &tipc_nametbl->seq_hlist[i]; seq_head = &tn->nametbl->seq_hlist[i];
hlist_for_each_entry_rcu(seq, seq_head, ns_list) { hlist_for_each_entry_rcu(seq, seq_head, ns_list) {
if (seq->type == type) { if (seq->type == type) {
ret += nameseq_list(seq, buf + ret, len - ret, ret += nameseq_list(seq, buf + ret, len - ret,
...@@ -912,7 +919,8 @@ static int nametbl_list(char *buf, int len, u32 depth_info, ...@@ -912,7 +919,8 @@ static int nametbl_list(char *buf, int len, u32 depth_info,
return ret; return ret;
} }
struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) struct sk_buff *tipc_nametbl_get(struct net *net, const void *req_tlv_area,
int req_tlv_space)
{ {
struct sk_buff *buf; struct sk_buff *buf;
struct tipc_name_table_query *argv; struct tipc_name_table_query *argv;
...@@ -933,7 +941,7 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) ...@@ -933,7 +941,7 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
pb_len = ULTRA_STRING_MAX_LEN; pb_len = ULTRA_STRING_MAX_LEN;
argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area); argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area);
rcu_read_lock(); rcu_read_lock();
str_len = nametbl_list(pb, pb_len, ntohl(argv->depth), str_len = nametbl_list(net, pb, pb_len, ntohl(argv->depth),
ntohl(argv->type), ntohl(argv->type),
ntohl(argv->lowbound), ntohl(argv->upbound)); ntohl(argv->lowbound), ntohl(argv->upbound));
rcu_read_unlock(); rcu_read_unlock();
...@@ -944,8 +952,10 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) ...@@ -944,8 +952,10 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
return buf; return buf;
} }
int tipc_nametbl_init(void) int tipc_nametbl_init(struct net *net)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct name_table *tipc_nametbl;
int i; int i;
tipc_nametbl = kzalloc(sizeof(*tipc_nametbl), GFP_ATOMIC); tipc_nametbl = kzalloc(sizeof(*tipc_nametbl), GFP_ATOMIC);
...@@ -958,6 +968,8 @@ int tipc_nametbl_init(void) ...@@ -958,6 +968,8 @@ int tipc_nametbl_init(void)
INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]); INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]);
INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]); INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]);
INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_NODE_SCOPE]); INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_NODE_SCOPE]);
tn->nametbl = tipc_nametbl;
spin_lock_init(&tn->nametbl_lock);
return 0; return 0;
} }
...@@ -966,7 +978,7 @@ int tipc_nametbl_init(void) ...@@ -966,7 +978,7 @@ int tipc_nametbl_init(void)
* *
* tipc_nametbl_lock must be held when calling this function * tipc_nametbl_lock must be held when calling this function
*/ */
static void tipc_purge_publications(struct name_seq *seq) static void tipc_purge_publications(struct net *net, struct name_seq *seq)
{ {
struct publication *publ, *safe; struct publication *publ, *safe;
struct sub_seq *sseq; struct sub_seq *sseq;
...@@ -976,8 +988,8 @@ static void tipc_purge_publications(struct name_seq *seq) ...@@ -976,8 +988,8 @@ static void tipc_purge_publications(struct name_seq *seq)
sseq = seq->sseqs; sseq = seq->sseqs;
info = sseq->info; info = sseq->info;
list_for_each_entry_safe(publ, safe, &info->zone_list, zone_list) { list_for_each_entry_safe(publ, safe, &info->zone_list, zone_list) {
tipc_nametbl_remove_publ(publ->type, publ->lower, publ->node, tipc_nametbl_remove_publ(net, publ->type, publ->lower,
publ->ref, publ->key); publ->node, publ->ref, publ->key);
kfree_rcu(publ, rcu); kfree_rcu(publ, rcu);
} }
hlist_del_init_rcu(&seq->ns_list); hlist_del_init_rcu(&seq->ns_list);
...@@ -987,25 +999,27 @@ static void tipc_purge_publications(struct name_seq *seq) ...@@ -987,25 +999,27 @@ static void tipc_purge_publications(struct name_seq *seq)
kfree_rcu(seq, rcu); kfree_rcu(seq, rcu);
} }
void tipc_nametbl_stop(void) void tipc_nametbl_stop(struct net *net)
{ {
u32 i; u32 i;
struct name_seq *seq; struct name_seq *seq;
struct hlist_head *seq_head; struct hlist_head *seq_head;
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct name_table *tipc_nametbl = tn->nametbl;
/* Verify name table is empty and purge any lingering /* Verify name table is empty and purge any lingering
* publications, then release the name table * publications, then release the name table
*/ */
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tn->nametbl_lock);
for (i = 0; i < TIPC_NAMETBL_SIZE; i++) { for (i = 0; i < TIPC_NAMETBL_SIZE; i++) {
if (hlist_empty(&tipc_nametbl->seq_hlist[i])) if (hlist_empty(&tipc_nametbl->seq_hlist[i]))
continue; continue;
seq_head = &tipc_nametbl->seq_hlist[i]; seq_head = &tipc_nametbl->seq_hlist[i];
hlist_for_each_entry_rcu(seq, seq_head, ns_list) { hlist_for_each_entry_rcu(seq, seq_head, ns_list) {
tipc_purge_publications(seq); tipc_purge_publications(net, seq);
} }
} }
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tn->nametbl_lock);
synchronize_net(); synchronize_net();
kfree(tipc_nametbl); kfree(tipc_nametbl);
...@@ -1109,9 +1123,10 @@ static int __tipc_nl_subseq_list(struct tipc_nl_msg *msg, struct name_seq *seq, ...@@ -1109,9 +1123,10 @@ static int __tipc_nl_subseq_list(struct tipc_nl_msg *msg, struct name_seq *seq,
return 0; return 0;
} }
static int __tipc_nl_seq_list(struct tipc_nl_msg *msg, u32 *last_type, static int tipc_nl_seq_list(struct net *net, struct tipc_nl_msg *msg,
u32 *last_lower, u32 *last_publ) u32 *last_type, u32 *last_lower, u32 *last_publ)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct hlist_head *seq_head; struct hlist_head *seq_head;
struct name_seq *seq = NULL; struct name_seq *seq = NULL;
int err; int err;
...@@ -1123,10 +1138,10 @@ static int __tipc_nl_seq_list(struct tipc_nl_msg *msg, u32 *last_type, ...@@ -1123,10 +1138,10 @@ static int __tipc_nl_seq_list(struct tipc_nl_msg *msg, u32 *last_type,
i = 0; i = 0;
for (; i < TIPC_NAMETBL_SIZE; i++) { for (; i < TIPC_NAMETBL_SIZE; i++) {
seq_head = &tipc_nametbl->seq_hlist[i]; seq_head = &tn->nametbl->seq_hlist[i];
if (*last_type) { if (*last_type) {
seq = nametbl_find_seq(*last_type); seq = nametbl_find_seq(net, *last_type);
if (!seq) if (!seq)
return -EPIPE; return -EPIPE;
} else { } else {
...@@ -1160,6 +1175,7 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1160,6 +1175,7 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb)
u32 last_type = cb->args[0]; u32 last_type = cb->args[0];
u32 last_lower = cb->args[1]; u32 last_lower = cb->args[1];
u32 last_publ = cb->args[2]; u32 last_publ = cb->args[2];
struct net *net = sock_net(skb->sk);
struct tipc_nl_msg msg; struct tipc_nl_msg msg;
if (done) if (done)
...@@ -1170,7 +1186,7 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1170,7 +1186,7 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb)
msg.seq = cb->nlh->nlmsg_seq; msg.seq = cb->nlh->nlmsg_seq;
rcu_read_lock(); rcu_read_lock();
err = __tipc_nl_seq_list(&msg, &last_type, &last_lower, &last_publ); err = tipc_nl_seq_list(net, &msg, &last_type, &last_lower, &last_publ);
if (!err) { if (!err) {
done = 1; done = 1;
} else if (err != -EMSGSIZE) { } else if (err != -EMSGSIZE) {
......
...@@ -95,28 +95,27 @@ struct name_table { ...@@ -95,28 +95,27 @@ struct name_table {
u32 local_publ_count; u32 local_publ_count;
}; };
extern spinlock_t tipc_nametbl_lock;
extern struct name_table *tipc_nametbl;
int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb); int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb);
struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); struct sk_buff *tipc_nametbl_get(struct net *net, const void *req_tlv_area,
u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); int req_tlv_space);
int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node);
struct tipc_port_list *dports); int tipc_nametbl_mc_translate(struct net *net, u32 type, u32 lower, u32 upper,
u32 limit, struct tipc_port_list *dports);
struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower,
u32 upper, u32 scope, u32 port_ref, u32 upper, u32 scope, u32 port_ref,
u32 key); u32 key);
int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
u32 key); u32 key);
struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type,
u32 scope, u32 node, u32 ref, u32 lower, u32 upper, u32 scope,
u32 node, u32 ref, u32 key);
struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
u32 lower, u32 node, u32 ref,
u32 key); u32 key);
struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, u32 node,
u32 ref, u32 key);
void tipc_nametbl_subscribe(struct tipc_subscription *s); void tipc_nametbl_subscribe(struct tipc_subscription *s);
void tipc_nametbl_unsubscribe(struct tipc_subscription *s); void tipc_nametbl_unsubscribe(struct tipc_subscription *s);
int tipc_nametbl_init(void); int tipc_nametbl_init(struct net *net);
void tipc_nametbl_stop(void); void tipc_nametbl_stop(struct net *net);
#endif #endif
...@@ -116,7 +116,7 @@ int tipc_net_start(struct net *net, u32 addr) ...@@ -116,7 +116,7 @@ int tipc_net_start(struct net *net, u32 addr)
int res; int res;
tipc_own_addr = addr; tipc_own_addr = addr;
tipc_named_reinit(); tipc_named_reinit(net);
tipc_sk_reinit(net); tipc_sk_reinit(net);
res = tipc_bclink_init(net); res = tipc_bclink_init(net);
if (res) if (res)
......
...@@ -256,7 +256,8 @@ static int tipc_receive_from_sock(struct tipc_conn *con) ...@@ -256,7 +256,8 @@ static int tipc_receive_from_sock(struct tipc_conn *con)
goto out_close; goto out_close;
} }
s->tipc_conn_recvmsg(con->conid, &addr, con->usr_data, buf, ret); s->tipc_conn_recvmsg(sock_net(con->sock->sk), con->conid, &addr,
con->usr_data, buf, ret);
kmem_cache_free(s->rcvbuf_cache, buf); kmem_cache_free(s->rcvbuf_cache, buf);
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/tipc.h> #include <linux/tipc.h>
#include <net/net_namespace.h>
#define TIPC_SERVER_NAME_LEN 32 #define TIPC_SERVER_NAME_LEN 32
...@@ -66,10 +67,11 @@ struct tipc_server { ...@@ -66,10 +67,11 @@ struct tipc_server {
struct workqueue_struct *rcv_wq; struct workqueue_struct *rcv_wq;
struct workqueue_struct *send_wq; struct workqueue_struct *send_wq;
int max_rcvbuf_size; int max_rcvbuf_size;
void *(*tipc_conn_new) (int conid); void *(*tipc_conn_new)(int conid);
void (*tipc_conn_shutdown) (int conid, void *usr_data); void (*tipc_conn_shutdown)(int conid, void *usr_data);
void (*tipc_conn_recvmsg) (int conid, struct sockaddr_tipc *addr, void (*tipc_conn_recvmsg)(struct net *net, int conid,
void *usr_data, void *buf, size_t len); struct sockaddr_tipc *addr, void *usr_data,
void *buf, size_t len);
struct sockaddr_tipc *saddr; struct sockaddr_tipc *saddr;
const char name[TIPC_SERVER_NAME_LEN]; const char name[TIPC_SERVER_NAME_LEN];
int imp; int imp;
......
...@@ -778,11 +778,8 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff *buf) ...@@ -778,11 +778,8 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff *buf)
scope = TIPC_NODE_SCOPE; scope = TIPC_NODE_SCOPE;
/* Create destination port list: */ /* Create destination port list: */
tipc_nametbl_mc_translate(msg_nametype(msg), tipc_nametbl_mc_translate(net, msg_nametype(msg), msg_namelower(msg),
msg_namelower(msg), msg_nameupper(msg), scope, &dports);
msg_nameupper(msg),
scope,
&dports);
last = dports.count; last = dports.count;
if (!last) { if (!last) {
kfree_skb(buf); kfree_skb(buf);
...@@ -943,7 +940,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -943,7 +940,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock,
msg_set_nametype(mhdr, type); msg_set_nametype(mhdr, type);
msg_set_nameinst(mhdr, inst); msg_set_nameinst(mhdr, inst);
msg_set_lookup_scope(mhdr, tipc_addr_scope(domain)); msg_set_lookup_scope(mhdr, tipc_addr_scope(domain));
dport = tipc_nametbl_translate(type, inst, &dnode); dport = tipc_nametbl_translate(net, type, inst, &dnode);
msg_set_destnode(mhdr, dnode); msg_set_destnode(mhdr, dnode);
msg_set_destport(mhdr, dport); msg_set_destport(mhdr, dport);
if (unlikely(!dport && !dnode)) { if (unlikely(!dport && !dnode)) {
...@@ -1765,7 +1762,7 @@ int tipc_sk_rcv(struct net *net, struct sk_buff *skb) ...@@ -1765,7 +1762,7 @@ int tipc_sk_rcv(struct net *net, struct sk_buff *skb)
/* Validate destination and message */ /* Validate destination and message */
tsk = tipc_sk_lookup(net, dport); tsk = tipc_sk_lookup(net, dport);
if (unlikely(!tsk)) { if (unlikely(!tsk)) {
rc = tipc_msg_eval(skb, &dnode); rc = tipc_msg_eval(net, skb, &dnode);
goto exit; goto exit;
} }
sk = &tsk->sk; sk = &tsk->sk;
......
...@@ -50,8 +50,9 @@ struct tipc_subscriber { ...@@ -50,8 +50,9 @@ struct tipc_subscriber {
struct list_head subscription_list; struct list_head subscription_list;
}; };
static void subscr_conn_msg_event(int conid, struct sockaddr_tipc *addr, static void subscr_conn_msg_event(struct net *net, int conid,
void *usr_data, void *buf, size_t len); struct sockaddr_tipc *addr, void *usr_data,
void *buf, size_t len);
static void *subscr_named_msg_event(int conid); static void *subscr_named_msg_event(int conid);
static void subscr_conn_shutdown_event(int conid, void *usr_data); static void subscr_conn_shutdown_event(int conid, void *usr_data);
...@@ -260,7 +261,7 @@ static void subscr_cancel(struct tipc_subscr *s, ...@@ -260,7 +261,7 @@ static void subscr_cancel(struct tipc_subscr *s,
* *
* Called with subscriber lock held. * Called with subscriber lock held.
*/ */
static int subscr_subscribe(struct tipc_subscr *s, static int subscr_subscribe(struct net *net, struct tipc_subscr *s,
struct tipc_subscriber *subscriber, struct tipc_subscriber *subscriber,
struct tipc_subscription **sub_p) { struct tipc_subscription **sub_p) {
struct tipc_subscription *sub; struct tipc_subscription *sub;
...@@ -291,6 +292,7 @@ static int subscr_subscribe(struct tipc_subscr *s, ...@@ -291,6 +292,7 @@ static int subscr_subscribe(struct tipc_subscr *s,
} }
/* Initialize subscription object */ /* Initialize subscription object */
sub->net = net;
sub->seq.type = htohl(s->seq.type, swap); sub->seq.type = htohl(s->seq.type, swap);
sub->seq.lower = htohl(s->seq.lower, swap); sub->seq.lower = htohl(s->seq.lower, swap);
sub->seq.upper = htohl(s->seq.upper, swap); sub->seq.upper = htohl(s->seq.upper, swap);
...@@ -323,14 +325,16 @@ static void subscr_conn_shutdown_event(int conid, void *usr_data) ...@@ -323,14 +325,16 @@ static void subscr_conn_shutdown_event(int conid, void *usr_data)
} }
/* Handle one request to create a new subscription for the subscriber */ /* Handle one request to create a new subscription for the subscriber */
static void subscr_conn_msg_event(int conid, struct sockaddr_tipc *addr, static void subscr_conn_msg_event(struct net *net, int conid,
void *usr_data, void *buf, size_t len) struct sockaddr_tipc *addr, void *usr_data,
void *buf, size_t len)
{ {
struct tipc_subscriber *subscriber = usr_data; struct tipc_subscriber *subscriber = usr_data;
struct tipc_subscription *sub = NULL; struct tipc_subscription *sub = NULL;
spin_lock_bh(&subscriber->lock); spin_lock_bh(&subscriber->lock);
if (subscr_subscribe((struct tipc_subscr *)buf, subscriber, &sub) < 0) { if (subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber,
&sub) < 0) {
spin_unlock_bh(&subscriber->lock); spin_unlock_bh(&subscriber->lock);
subscr_terminate(subscriber); subscr_terminate(subscriber);
return; return;
......
...@@ -49,6 +49,7 @@ struct tipc_subscriber; ...@@ -49,6 +49,7 @@ struct tipc_subscriber;
* struct tipc_subscription - TIPC network topology subscription object * struct tipc_subscription - TIPC network topology subscription object
* @subscriber: pointer to its subscriber * @subscriber: pointer to its subscriber
* @seq: name sequence associated with subscription * @seq: name sequence associated with subscription
* @net: point to network namespace
* @timeout: duration of subscription (in ms) * @timeout: duration of subscription (in ms)
* @filter: event filtering to be done for subscription * @filter: event filtering to be done for subscription
* @timer: timer governing subscription duration (optional) * @timer: timer governing subscription duration (optional)
...@@ -61,6 +62,7 @@ struct tipc_subscriber; ...@@ -61,6 +62,7 @@ struct tipc_subscriber;
struct tipc_subscription { struct tipc_subscription {
struct tipc_subscriber *subscriber; struct tipc_subscriber *subscriber;
struct tipc_name_seq seq; struct tipc_name_seq seq;
struct net *net;
unsigned long timeout; unsigned long timeout;
u32 filter; u32 filter;
struct timer_list timer; struct timer_list timer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment