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

tipc: make tipc node table aware of net namespace

Global variables associated with node table are below:
- node table list (node_htable)
- node hash table list (tipc_node_list)
- node table lock (node_list_lock)
- node number counter (tipc_num_nodes)
- node link number counter (tipc_num_links)

To make node table support namespace, above global variables must be
moved to tipc_net structure in order to keep secret for different
namespaces. As a consequence, these variables are allocated and
initialized when namespace is created, and deallocated when namespace
is destroyed. After the change, functions associated with these
variables have to utilize a namespace pointer to access them. So
adding namespace pointer as a parameter of these functions is the
major change made in the commit.
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 c93d3baa
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#define TIPC_ZONE_MASK 0xff000000u #define TIPC_ZONE_MASK 0xff000000u
#define TIPC_CLUSTER_MASK 0xfffff000u #define TIPC_CLUSTER_MASK 0xfffff000u
extern u32 tipc_own_addr __read_mostly;
static inline u32 tipc_zone_mask(u32 addr) static inline u32 tipc_zone_mask(u32 addr)
{ {
return addr & TIPC_ZONE_MASK; return addr & TIPC_ZONE_MASK;
......
...@@ -232,13 +232,12 @@ static void bclink_retransmit_pkt(u32 after, u32 to) ...@@ -232,13 +232,12 @@ static void bclink_retransmit_pkt(u32 after, u32 to)
* *
* Called with no locks taken * Called with no locks taken
*/ */
void tipc_bclink_wakeup_users(void) void tipc_bclink_wakeup_users(struct net *net)
{ {
struct sk_buff *skb; struct sk_buff *skb;
while ((skb = skb_dequeue(&bclink->link.waiting_sks))) while ((skb = skb_dequeue(&bclink->link.waiting_sks)))
tipc_sk_rcv(skb); tipc_sk_rcv(net, skb);
} }
/** /**
...@@ -385,9 +384,9 @@ void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr, ...@@ -385,9 +384,9 @@ void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr,
* Delay any upcoming NACK by this node if another node has already * Delay any upcoming NACK by this node if another node has already
* requested the first message this node is going to ask for. * requested the first message this node is going to ask for.
*/ */
static void bclink_peek_nack(struct tipc_msg *msg) static void bclink_peek_nack(struct net *net, struct tipc_msg *msg)
{ {
struct tipc_node *n_ptr = tipc_node_find(msg_destnode(msg)); struct tipc_node *n_ptr = tipc_node_find(net, msg_destnode(msg));
if (unlikely(!n_ptr)) if (unlikely(!n_ptr))
return; return;
...@@ -404,11 +403,12 @@ static void bclink_peek_nack(struct tipc_msg *msg) ...@@ -404,11 +403,12 @@ static void bclink_peek_nack(struct tipc_msg *msg)
/* tipc_bclink_xmit - broadcast buffer chain to all nodes in cluster /* tipc_bclink_xmit - broadcast buffer chain to all nodes in cluster
* and to identified node local sockets * and to identified node local sockets
* @net: the applicable net namespace
* @list: chain of buffers containing message * @list: chain of buffers containing message
* Consumes the buffer chain, except when returning -ELINKCONG * Consumes the buffer chain, except when returning -ELINKCONG
* Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE
*/ */
int tipc_bclink_xmit(struct sk_buff_head *list) int tipc_bclink_xmit(struct net *net, struct sk_buff_head *list)
{ {
int rc = 0; int rc = 0;
int bc = 0; int bc = 0;
...@@ -443,7 +443,7 @@ int tipc_bclink_xmit(struct sk_buff_head *list) ...@@ -443,7 +443,7 @@ int tipc_bclink_xmit(struct sk_buff_head *list)
/* Deliver message clone */ /* Deliver message clone */
if (likely(!rc)) if (likely(!rc))
tipc_sk_mcast_rcv(skb); tipc_sk_mcast_rcv(net, skb);
else else
kfree_skb(skb); kfree_skb(skb);
...@@ -491,7 +491,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) ...@@ -491,7 +491,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf)
if (msg_mc_netid(msg) != tn->net_id) if (msg_mc_netid(msg) != tn->net_id)
goto exit; goto exit;
node = tipc_node_find(msg_prevnode(msg)); node = tipc_node_find(net, msg_prevnode(msg));
if (unlikely(!node)) if (unlikely(!node))
goto exit; goto exit;
...@@ -514,7 +514,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) ...@@ -514,7 +514,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf)
tipc_bclink_unlock(); tipc_bclink_unlock();
} else { } else {
tipc_node_unlock(node); tipc_node_unlock(node);
bclink_peek_nack(msg); bclink_peek_nack(net, msg);
} }
goto exit; goto exit;
} }
...@@ -532,7 +532,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) ...@@ -532,7 +532,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf)
tipc_bclink_unlock(); tipc_bclink_unlock();
tipc_node_unlock(node); tipc_node_unlock(node);
if (likely(msg_mcast(msg))) if (likely(msg_mcast(msg)))
tipc_sk_mcast_rcv(buf); tipc_sk_mcast_rcv(net, buf);
else else
kfree_skb(buf); kfree_skb(buf);
} else if (msg_user(msg) == MSG_BUNDLER) { } else if (msg_user(msg) == MSG_BUNDLER) {
...@@ -542,7 +542,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) ...@@ -542,7 +542,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf)
bcl->stats.recv_bundled += msg_msgcnt(msg); bcl->stats.recv_bundled += msg_msgcnt(msg);
tipc_bclink_unlock(); tipc_bclink_unlock();
tipc_node_unlock(node); tipc_node_unlock(node);
tipc_link_bundle_rcv(buf); tipc_link_bundle_rcv(net, buf);
} else if (msg_user(msg) == MSG_FRAGMENTER) { } else if (msg_user(msg) == MSG_FRAGMENTER) {
tipc_buf_append(&node->bclink.reasm_buf, &buf); tipc_buf_append(&node->bclink.reasm_buf, &buf);
if (unlikely(!buf && !node->bclink.reasm_buf)) if (unlikely(!buf && !node->bclink.reasm_buf))
...@@ -563,7 +563,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) ...@@ -563,7 +563,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf)
bclink_accept_pkt(node, seqno); bclink_accept_pkt(node, seqno);
tipc_bclink_unlock(); tipc_bclink_unlock();
tipc_node_unlock(node); tipc_node_unlock(node);
tipc_named_rcv(buf); tipc_named_rcv(net, buf);
} else { } else {
tipc_bclink_lock(); tipc_bclink_lock();
bclink_accept_pkt(node, seqno); bclink_accept_pkt(node, seqno);
......
...@@ -101,8 +101,8 @@ int tipc_bclink_reset_stats(void); ...@@ -101,8 +101,8 @@ int tipc_bclink_reset_stats(void);
int tipc_bclink_set_queue_limits(u32 limit); int tipc_bclink_set_queue_limits(u32 limit);
void tipc_bcbearer_sort(struct tipc_node_map *nm_ptr, u32 node, bool action); void tipc_bcbearer_sort(struct tipc_node_map *nm_ptr, u32 node, bool action);
uint tipc_bclink_get_mtu(void); uint tipc_bclink_get_mtu(void);
int tipc_bclink_xmit(struct sk_buff_head *list); int tipc_bclink_xmit(struct net *net, struct sk_buff_head *list);
void tipc_bclink_wakeup_users(void); void tipc_bclink_wakeup_users(struct net *net);
int tipc_nl_add_bc_link(struct tipc_nl_msg *msg); int tipc_nl_add_bc_link(struct tipc_nl_msg *msg);
#endif #endif
...@@ -69,7 +69,8 @@ static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = { ...@@ -69,7 +69,8 @@ static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = {
struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1]; struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1];
static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down); static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr,
bool shutting_down);
/** /**
* tipc_media_find - locates specified media object by name * tipc_media_find - locates specified media object by name
...@@ -364,7 +365,7 @@ int tipc_enable_bearer(struct net *net, const char *name, u32 disc_domain, ...@@ -364,7 +365,7 @@ int tipc_enable_bearer(struct net *net, const char *name, u32 disc_domain,
res = tipc_disc_create(net, b_ptr, &b_ptr->bcast_addr); res = tipc_disc_create(net, b_ptr, &b_ptr->bcast_addr);
if (res) { if (res) {
bearer_disable(b_ptr, false); bearer_disable(net, b_ptr, false);
pr_warn("Bearer <%s> rejected, discovery object creation failed\n", pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
name); name);
return -EINVAL; return -EINVAL;
...@@ -384,7 +385,7 @@ int tipc_enable_bearer(struct net *net, const char *name, u32 disc_domain, ...@@ -384,7 +385,7 @@ int tipc_enable_bearer(struct net *net, const char *name, u32 disc_domain,
static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr) static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr)
{ {
pr_info("Resetting bearer <%s>\n", b_ptr->name); pr_info("Resetting bearer <%s>\n", b_ptr->name);
tipc_link_reset_list(b_ptr->identity); tipc_link_reset_list(net, b_ptr->identity);
tipc_disc_reset(net, b_ptr); tipc_disc_reset(net, b_ptr);
return 0; return 0;
} }
...@@ -394,14 +395,15 @@ static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr) ...@@ -394,14 +395,15 @@ static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr)
* *
* Note: This routine assumes caller holds RTNL lock. * Note: This routine assumes caller holds RTNL lock.
*/ */
static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down) static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr,
bool shutting_down)
{ {
u32 i; u32 i;
pr_info("Disabling bearer <%s>\n", b_ptr->name); pr_info("Disabling bearer <%s>\n", b_ptr->name);
b_ptr->media->disable_media(b_ptr); b_ptr->media->disable_media(b_ptr);
tipc_link_delete_list(b_ptr->identity, shutting_down); tipc_link_delete_list(net, b_ptr->identity, shutting_down);
if (b_ptr->link_req) if (b_ptr->link_req)
tipc_disc_delete(b_ptr->link_req); tipc_disc_delete(b_ptr->link_req);
...@@ -414,7 +416,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down) ...@@ -414,7 +416,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down)
kfree_rcu(b_ptr, rcu); kfree_rcu(b_ptr, rcu);
} }
int tipc_disable_bearer(const char *name) int tipc_disable_bearer(struct net *net, const char *name)
{ {
struct tipc_bearer *b_ptr; struct tipc_bearer *b_ptr;
int res; int res;
...@@ -424,7 +426,7 @@ int tipc_disable_bearer(const char *name) ...@@ -424,7 +426,7 @@ int tipc_disable_bearer(const char *name)
pr_warn("Attempt to disable unknown bearer <%s>\n", name); pr_warn("Attempt to disable unknown bearer <%s>\n", name);
res = -EINVAL; res = -EINVAL;
} else { } else {
bearer_disable(b_ptr, false); bearer_disable(net, b_ptr, false);
res = 0; res = 0;
} }
return res; return res;
...@@ -593,7 +595,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, ...@@ -593,7 +595,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
bearer_disable(b_ptr, false); bearer_disable(dev_net(dev), b_ptr, false);
break; break;
} }
return NOTIFY_OK; return NOTIFY_OK;
...@@ -626,7 +628,7 @@ void tipc_bearer_cleanup(void) ...@@ -626,7 +628,7 @@ void tipc_bearer_cleanup(void)
dev_remove_pack(&tipc_packet_type); dev_remove_pack(&tipc_packet_type);
} }
void tipc_bearer_stop(void) void tipc_bearer_stop(struct net *net)
{ {
struct tipc_bearer *b_ptr; struct tipc_bearer *b_ptr;
u32 i; u32 i;
...@@ -634,7 +636,7 @@ void tipc_bearer_stop(void) ...@@ -634,7 +636,7 @@ void tipc_bearer_stop(void)
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
b_ptr = rtnl_dereference(bearer_list[i]); b_ptr = rtnl_dereference(bearer_list[i]);
if (b_ptr) { if (b_ptr) {
bearer_disable(b_ptr, true); bearer_disable(net, b_ptr, true);
bearer_list[i] = NULL; bearer_list[i] = NULL;
} }
} }
...@@ -772,6 +774,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) ...@@ -772,6 +774,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
char *name; char *name;
struct tipc_bearer *bearer; struct tipc_bearer *bearer;
struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1];
struct net *net = genl_info_net(info);
if (!info->attrs[TIPC_NLA_BEARER]) if (!info->attrs[TIPC_NLA_BEARER])
return -EINVAL; return -EINVAL;
...@@ -794,7 +797,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) ...@@ -794,7 +797,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
return -EINVAL; return -EINVAL;
} }
bearer_disable(bearer, false); bearer_disable(net, bearer, false);
rtnl_unlock(); rtnl_unlock();
return 0; return 0;
......
...@@ -168,7 +168,7 @@ extern struct tipc_bearer __rcu *bearer_list[]; ...@@ -168,7 +168,7 @@ extern struct tipc_bearer __rcu *bearer_list[];
void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr); void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr);
int tipc_enable_bearer(struct net *net, const char *bearer_name, int tipc_enable_bearer(struct net *net, const char *bearer_name,
u32 disc_domain, u32 priority); u32 disc_domain, u32 priority);
int tipc_disable_bearer(const char *name); int tipc_disable_bearer(struct net *net, const char *name);
/* /*
* Routines made available to TIPC by supported media types * Routines made available to TIPC by supported media types
...@@ -205,7 +205,7 @@ struct tipc_bearer *tipc_bearer_find(const char *name); ...@@ -205,7 +205,7 @@ struct tipc_bearer *tipc_bearer_find(const char *name);
struct tipc_media *tipc_media_find(const char *name); struct tipc_media *tipc_media_find(const char *name);
int tipc_bearer_setup(void); int tipc_bearer_setup(void);
void tipc_bearer_cleanup(void); void tipc_bearer_cleanup(void);
void tipc_bearer_stop(void); void tipc_bearer_stop(struct net *net);
void tipc_bearer_send(u32 bearer_id, struct sk_buff *buf, void tipc_bearer_send(u32 bearer_id, struct sk_buff *buf,
struct tipc_media_addr *dest); struct tipc_media_addr *dest);
......
...@@ -150,12 +150,12 @@ static struct sk_buff *cfg_enable_bearer(struct net *net) ...@@ -150,12 +150,12 @@ static struct sk_buff *cfg_enable_bearer(struct net *net)
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
} }
static struct sk_buff *cfg_disable_bearer(void) static struct sk_buff *cfg_disable_bearer(struct net *net)
{ {
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_BEARER_NAME)) if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_BEARER_NAME))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
if (tipc_disable_bearer((char *)TLV_DATA(req_tlv_area))) if (tipc_disable_bearer(net, (char *)TLV_DATA(req_tlv_area)))
return tipc_cfg_reply_error_string("unable to disable bearer"); return tipc_cfg_reply_error_string("unable to disable bearer");
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
...@@ -232,16 +232,20 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, ...@@ -232,16 +232,20 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
rep_tlv_buf = tipc_cfg_reply_none(); rep_tlv_buf = tipc_cfg_reply_none();
break; break;
case TIPC_CMD_GET_NODES: case TIPC_CMD_GET_NODES:
rep_tlv_buf = tipc_node_get_nodes(req_tlv_area, req_tlv_space); rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area,
req_tlv_space);
break; break;
case TIPC_CMD_GET_LINKS: case TIPC_CMD_GET_LINKS:
rep_tlv_buf = tipc_node_get_links(req_tlv_area, req_tlv_space); rep_tlv_buf = tipc_node_get_links(net, req_tlv_area,
req_tlv_space);
break; break;
case TIPC_CMD_SHOW_LINK_STATS: case TIPC_CMD_SHOW_LINK_STATS:
rep_tlv_buf = tipc_link_cmd_show_stats(req_tlv_area, req_tlv_space); rep_tlv_buf = tipc_link_cmd_show_stats(net, req_tlv_area,
req_tlv_space);
break; break;
case TIPC_CMD_RESET_LINK_STATS: case TIPC_CMD_RESET_LINK_STATS:
rep_tlv_buf = tipc_link_cmd_reset_stats(req_tlv_area, req_tlv_space); rep_tlv_buf = tipc_link_cmd_reset_stats(net, req_tlv_area,
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(req_tlv_area, req_tlv_space);
...@@ -261,13 +265,14 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, ...@@ -261,13 +265,14 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
case TIPC_CMD_SET_LINK_TOL: case TIPC_CMD_SET_LINK_TOL:
case TIPC_CMD_SET_LINK_PRI: case TIPC_CMD_SET_LINK_PRI:
case TIPC_CMD_SET_LINK_WINDOW: case TIPC_CMD_SET_LINK_WINDOW:
rep_tlv_buf = tipc_link_cmd_config(req_tlv_area, req_tlv_space, cmd); rep_tlv_buf = tipc_link_cmd_config(net, req_tlv_area,
req_tlv_space, cmd);
break; break;
case TIPC_CMD_ENABLE_BEARER: case TIPC_CMD_ENABLE_BEARER:
rep_tlv_buf = cfg_enable_bearer(net); rep_tlv_buf = cfg_enable_bearer(net);
break; break;
case TIPC_CMD_DISABLE_BEARER: case TIPC_CMD_DISABLE_BEARER:
rep_tlv_buf = cfg_disable_bearer(); rep_tlv_buf = cfg_disable_bearer(net);
break; break;
case TIPC_CMD_SET_NODE_ADDR: case TIPC_CMD_SET_NODE_ADDR:
rep_tlv_buf = cfg_set_own_addr(net); rep_tlv_buf = cfg_set_own_addr(net);
......
...@@ -57,12 +57,15 @@ static int __net_init tipc_init_net(struct net *net) ...@@ -57,12 +57,15 @@ static int __net_init tipc_init_net(struct net *net)
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
tn->net_id = 4711; tn->net_id = 4711;
INIT_LIST_HEAD(&tn->node_list);
spin_lock_init(&tn->node_list_lock);
return 0; return 0;
} }
static void __net_exit tipc_exit_net(struct net *net) static void __net_exit tipc_exit_net(struct net *net)
{ {
tipc_net_stop(net);
} }
static struct pernet_operations tipc_net_ops = { static struct pernet_operations tipc_net_ops = {
...@@ -144,7 +147,6 @@ static int __init tipc_init(void) ...@@ -144,7 +147,6 @@ static int __init tipc_init(void)
static void __exit tipc_exit(void) static void __exit tipc_exit(void)
{ {
unregister_pernet_subsys(&tipc_net_ops); unregister_pernet_subsys(&tipc_net_ops);
tipc_net_stop();
tipc_bearer_cleanup(); tipc_bearer_cleanup();
tipc_netlink_stop(); tipc_netlink_stop();
tipc_subscr_stop(); tipc_subscr_stop();
......
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include "node.h"
#define TIPC_MOD_VER "2.0.0" #define TIPC_MOD_VER "2.0.0"
int tipc_snprintf(char *buf, int len, const char *fmt, ...); int tipc_snprintf(char *buf, int len, const char *fmt, ...);
...@@ -78,6 +80,13 @@ extern int tipc_random __read_mostly; ...@@ -78,6 +80,13 @@ extern int tipc_random __read_mostly;
struct tipc_net { struct tipc_net {
int net_id; int net_id;
/* Node table and node list */
spinlock_t node_list_lock;
struct hlist_head node_htable[NODE_HTABLE_SIZE];
struct list_head node_list;
u32 num_nodes;
u32 num_links;
}; };
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
...@@ -162,9 +162,9 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf, ...@@ -162,9 +162,9 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
return; return;
/* Locate, or if necessary, create, node: */ /* Locate, or if necessary, create, node: */
node = tipc_node_find(onode); node = tipc_node_find(net, onode);
if (!node) if (!node)
node = tipc_node_create(onode); node = tipc_node_create(net, onode);
if (!node) if (!node)
return; return;
......
This diff is collapsed.
...@@ -200,27 +200,31 @@ struct tipc_port; ...@@ -200,27 +200,31 @@ struct tipc_port;
struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
struct tipc_bearer *b_ptr, struct tipc_bearer *b_ptr,
const struct tipc_media_addr *media_addr); const struct tipc_media_addr *media_addr);
void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down); void tipc_link_delete_list(struct net *net, unsigned int bearer_id,
bool shutting_down);
void tipc_link_failover_send_queue(struct tipc_link *l_ptr); void tipc_link_failover_send_queue(struct tipc_link *l_ptr);
void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, struct tipc_link *dest); void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, struct tipc_link *dest);
void tipc_link_reset_fragments(struct tipc_link *l_ptr); void tipc_link_reset_fragments(struct tipc_link *l_ptr);
int tipc_link_is_up(struct tipc_link *l_ptr); int tipc_link_is_up(struct tipc_link *l_ptr);
int tipc_link_is_active(struct tipc_link *l_ptr); int tipc_link_is_active(struct tipc_link *l_ptr);
void tipc_link_purge_queues(struct tipc_link *l_ptr); void tipc_link_purge_queues(struct tipc_link *l_ptr);
struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, struct sk_buff *tipc_link_cmd_config(struct net *net, const void *req_tlv_area,
int req_tlv_space, int req_tlv_space, u16 cmd);
u16 cmd); struct sk_buff *tipc_link_cmd_show_stats(struct net *net,
struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, const void *req_tlv_area,
int req_tlv_space); int req_tlv_space);
struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, struct sk_buff *tipc_link_cmd_reset_stats(struct net *net,
const void *req_tlv_area,
int req_tlv_space); int req_tlv_space);
void tipc_link_reset_all(struct tipc_node *node); void tipc_link_reset_all(struct tipc_node *node);
void tipc_link_reset(struct tipc_link *l_ptr); void tipc_link_reset(struct tipc_link *l_ptr);
void tipc_link_reset_list(unsigned int bearer_id); void tipc_link_reset_list(struct net *net, unsigned int bearer_id);
int tipc_link_xmit_skb(struct sk_buff *skb, u32 dest, u32 selector); int tipc_link_xmit_skb(struct net *net, struct sk_buff *skb, u32 dest,
int tipc_link_xmit(struct sk_buff_head *list, u32 dest, u32 selector); u32 selector);
int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dest,
u32 selector);
int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list); int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list);
void tipc_link_bundle_rcv(struct sk_buff *buf); void tipc_link_bundle_rcv(struct net *net, struct sk_buff *buf);
void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int prob, void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int prob,
u32 gap, u32 tolerance, u32 priority, u32 acked_mtu); u32 gap, u32 tolerance, u32 priority, u32 acked_mtu);
void tipc_link_push_packets(struct tipc_link *l_ptr); void tipc_link_push_packets(struct tipc_link *l_ptr);
......
...@@ -81,14 +81,15 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) ...@@ -81,14 +81,15 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
return buf; return buf;
} }
void named_cluster_distribute(struct sk_buff *skb) void named_cluster_distribute(struct net *net, struct sk_buff *skb)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct sk_buff *oskb; struct sk_buff *oskb;
struct tipc_node *node; struct tipc_node *node;
u32 dnode; u32 dnode;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(node, &tipc_node_list, list) { list_for_each_entry_rcu(node, &tn->node_list, list) {
dnode = node->addr; dnode = node->addr;
if (in_own_node(dnode)) if (in_own_node(dnode))
continue; continue;
...@@ -98,7 +99,7 @@ void named_cluster_distribute(struct sk_buff *skb) ...@@ -98,7 +99,7 @@ void named_cluster_distribute(struct sk_buff *skb)
if (!oskb) if (!oskb)
break; break;
msg_set_destnode(buf_msg(oskb), dnode); msg_set_destnode(buf_msg(oskb), dnode);
tipc_link_xmit_skb(oskb, dnode, dnode); tipc_link_xmit_skb(net, oskb, dnode, dnode);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -160,13 +161,14 @@ struct sk_buff *tipc_named_withdraw(struct publication *publ) ...@@ -160,13 +161,14 @@ struct sk_buff *tipc_named_withdraw(struct publication *publ)
* @dnode: node to be updated * @dnode: node to be updated
* @pls: linked list of publication items to be packed into buffer chain * @pls: linked list of publication items to be packed into buffer chain
*/ */
static void named_distribute(struct sk_buff_head *list, u32 dnode, static void named_distribute(struct net *net, struct sk_buff_head *list,
struct list_head *pls) u32 dnode, struct list_head *pls)
{ {
struct publication *publ; struct publication *publ;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct distr_item *item = NULL; struct distr_item *item = NULL;
uint msg_dsz = (tipc_node_get_mtu(dnode, 0) / ITEM_SIZE) * ITEM_SIZE; uint msg_dsz = (tipc_node_get_mtu(net, dnode, 0) / ITEM_SIZE) *
ITEM_SIZE;
uint msg_rem = msg_dsz; uint msg_rem = msg_dsz;
list_for_each_entry(publ, pls, local_list) { list_for_each_entry(publ, pls, local_list) {
...@@ -202,30 +204,31 @@ static void named_distribute(struct sk_buff_head *list, u32 dnode, ...@@ -202,30 +204,31 @@ static void named_distribute(struct sk_buff_head *list, u32 dnode,
/** /**
* tipc_named_node_up - tell specified node about all publications by this node * tipc_named_node_up - tell specified node about all publications by this node
*/ */
void tipc_named_node_up(u32 dnode) void tipc_named_node_up(struct net *net, u32 dnode)
{ {
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(&head, dnode, named_distribute(net, &head, dnode,
&tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]); &tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]);
named_distribute(&head, dnode, named_distribute(net, &head, dnode,
&tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]); &tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]);
rcu_read_unlock(); rcu_read_unlock();
tipc_link_xmit(&head, dnode, dnode); tipc_link_xmit(net, &head, dnode, dnode);
} }
static void tipc_publ_subscribe(struct publication *publ, u32 addr) static void tipc_publ_subscribe(struct net *net, struct publication *publ,
u32 addr)
{ {
struct tipc_node *node; struct tipc_node *node;
if (in_own_node(addr)) if (in_own_node(addr))
return; return;
node = tipc_node_find(addr); node = tipc_node_find(net, addr);
if (!node) { if (!node) {
pr_warn("Node subscription rejected, unknown node 0x%x\n", pr_warn("Node subscription rejected, unknown node 0x%x\n",
addr); addr);
...@@ -237,11 +240,12 @@ static void tipc_publ_subscribe(struct publication *publ, u32 addr) ...@@ -237,11 +240,12 @@ static void tipc_publ_subscribe(struct publication *publ, u32 addr)
tipc_node_unlock(node); tipc_node_unlock(node);
} }
static void tipc_publ_unsubscribe(struct publication *publ, u32 addr) static void tipc_publ_unsubscribe(struct net *net, struct publication *publ,
u32 addr)
{ {
struct tipc_node *node; struct tipc_node *node;
node = tipc_node_find(addr); node = tipc_node_find(net, addr);
if (!node) if (!node)
return; return;
...@@ -256,7 +260,7 @@ static void tipc_publ_unsubscribe(struct publication *publ, u32 addr) ...@@ -256,7 +260,7 @@ static void tipc_publ_unsubscribe(struct publication *publ, u32 addr)
* Invoked for each publication issued by a newly failed node. * Invoked for each publication issued by a newly failed node.
* Removes publication structure from name table & deletes it. * Removes publication structure from name table & deletes it.
*/ */
static void tipc_publ_purge(struct publication *publ, u32 addr) static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr)
{ {
struct publication *p; struct publication *p;
...@@ -264,7 +268,7 @@ static void tipc_publ_purge(struct publication *publ, u32 addr) ...@@ -264,7 +268,7 @@ static void tipc_publ_purge(struct publication *publ, u32 addr)
p = tipc_nametbl_remove_publ(publ->type, publ->lower, p = tipc_nametbl_remove_publ(publ->type, publ->lower,
publ->node, publ->ref, publ->key); publ->node, publ->ref, publ->key);
if (p) if (p)
tipc_publ_unsubscribe(p, addr); tipc_publ_unsubscribe(net, p, addr);
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tipc_nametbl_lock);
if (p != publ) { if (p != publ) {
...@@ -277,12 +281,12 @@ static void tipc_publ_purge(struct publication *publ, u32 addr) ...@@ -277,12 +281,12 @@ static void tipc_publ_purge(struct publication *publ, u32 addr)
kfree_rcu(p, rcu); kfree_rcu(p, rcu);
} }
void tipc_publ_notify(struct list_head *nsub_list, u32 addr) void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr)
{ {
struct publication *publ, *tmp; struct publication *publ, *tmp;
list_for_each_entry_safe(publ, tmp, nsub_list, nodesub_list) list_for_each_entry_safe(publ, tmp, nsub_list, nodesub_list)
tipc_publ_purge(publ, addr); tipc_publ_purge(net, publ, addr);
} }
/** /**
...@@ -292,7 +296,8 @@ void tipc_publ_notify(struct list_head *nsub_list, u32 addr) ...@@ -292,7 +296,8 @@ void tipc_publ_notify(struct list_head *nsub_list, u32 addr)
* tipc_nametbl_lock must be held. * tipc_nametbl_lock must be held.
* Returns the publication item if successful, otherwise NULL. * Returns the publication item if successful, otherwise NULL.
*/ */
static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
u32 node, u32 dtype)
{ {
struct publication *publ = NULL; struct publication *publ = NULL;
...@@ -302,7 +307,7 @@ static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) ...@@ -302,7 +307,7 @@ static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype)
TIPC_CLUSTER_SCOPE, node, TIPC_CLUSTER_SCOPE, node,
ntohl(i->ref), ntohl(i->key)); ntohl(i->ref), ntohl(i->key));
if (publ) { if (publ) {
tipc_publ_subscribe(publ, node); tipc_publ_subscribe(net, publ, node);
return true; return true;
} }
} else if (dtype == WITHDRAWAL) { } else if (dtype == WITHDRAWAL) {
...@@ -310,7 +315,7 @@ static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) ...@@ -310,7 +315,7 @@ static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype)
node, ntohl(i->ref), node, ntohl(i->ref),
ntohl(i->key)); ntohl(i->key));
if (publ) { if (publ) {
tipc_publ_unsubscribe(publ, node); tipc_publ_unsubscribe(net, publ, node);
kfree_rcu(publ, rcu); kfree_rcu(publ, rcu);
return true; return true;
} }
...@@ -343,7 +348,7 @@ static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node) ...@@ -343,7 +348,7 @@ static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
* tipc_named_process_backlog - try to process any pending name table updates * tipc_named_process_backlog - try to process any pending name table updates
* from the network. * from the network.
*/ */
void tipc_named_process_backlog(void) void tipc_named_process_backlog(struct net *net)
{ {
struct distr_queue_item *e, *tmp; struct distr_queue_item *e, *tmp;
char addr[16]; char addr[16];
...@@ -351,7 +356,7 @@ void tipc_named_process_backlog(void) ...@@ -351,7 +356,7 @@ void tipc_named_process_backlog(void)
list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) { list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) {
if (time_after(e->expires, now)) { if (time_after(e->expires, now)) {
if (!tipc_update_nametbl(&e->i, e->node, e->dtype)) if (!tipc_update_nametbl(net, &e->i, e->node, e->dtype))
continue; continue;
} else { } else {
tipc_addr_string_fill(addr, e->node); tipc_addr_string_fill(addr, e->node);
...@@ -369,7 +374,7 @@ void tipc_named_process_backlog(void) ...@@ -369,7 +374,7 @@ void tipc_named_process_backlog(void)
/** /**
* tipc_named_rcv - process name table update message sent by another node * tipc_named_rcv - process name table update message sent by another node
*/ */
void tipc_named_rcv(struct sk_buff *buf) void tipc_named_rcv(struct net *net, struct sk_buff *buf)
{ {
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);
...@@ -378,11 +383,11 @@ void tipc_named_rcv(struct sk_buff *buf) ...@@ -378,11 +383,11 @@ void tipc_named_rcv(struct sk_buff *buf)
spin_lock_bh(&tipc_nametbl_lock); spin_lock_bh(&tipc_nametbl_lock);
while (count--) { while (count--) {
if (!tipc_update_nametbl(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(); tipc_named_process_backlog(net);
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tipc_nametbl_lock);
kfree_skb(buf); kfree_skb(buf);
} }
......
...@@ -69,11 +69,11 @@ struct distr_item { ...@@ -69,11 +69,11 @@ struct distr_item {
struct sk_buff *tipc_named_publish(struct publication *publ); struct sk_buff *tipc_named_publish(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 sk_buff *buf); void named_cluster_distribute(struct net *net, struct sk_buff *buf);
void tipc_named_node_up(u32 dnode); void tipc_named_node_up(struct net *net, u32 dnode);
void tipc_named_rcv(struct sk_buff *buf); void tipc_named_rcv(struct net *net, struct sk_buff *buf);
void tipc_named_reinit(void); void tipc_named_reinit(void);
void tipc_named_process_backlog(void); void tipc_named_process_backlog(struct net *net);
void tipc_publ_notify(struct list_head *nsub_list, u32 addr); void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr);
#endif #endif
...@@ -650,8 +650,9 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, ...@@ -650,8 +650,9 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
/* /*
* tipc_nametbl_publish - add name publication to network name tables * tipc_nametbl_publish - add name publication to network name tables
*/ */
struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower,
u32 scope, u32 port_ref, u32 key) u32 upper, u32 scope, u32 port_ref,
u32 key)
{ {
struct publication *publ; struct publication *publ;
struct sk_buff *buf = NULL; struct sk_buff *buf = NULL;
...@@ -670,19 +671,20 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, ...@@ -670,19 +671,20 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
tipc_nametbl->local_publ_count++; tipc_nametbl->local_publ_count++;
buf = tipc_named_publish(publ); buf = tipc_named_publish(publ);
/* Any pending external events? */ /* Any pending external events? */
tipc_named_process_backlog(); tipc_named_process_backlog(net);
} }
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tipc_nametbl_lock);
if (buf) if (buf)
named_cluster_distribute(buf); named_cluster_distribute(net, buf);
return publ; return publ;
} }
/** /**
* tipc_nametbl_withdraw - withdraw name publication from network name tables * tipc_nametbl_withdraw - withdraw name publication from network name tables
*/ */
int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
u32 key)
{ {
struct publication *publ; struct publication *publ;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
...@@ -693,7 +695,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) ...@@ -693,7 +695,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
tipc_nametbl->local_publ_count--; tipc_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(); tipc_named_process_backlog(net);
list_del_init(&publ->pport_list); list_del_init(&publ->pport_list);
kfree_rcu(publ, rcu); kfree_rcu(publ, rcu);
} else { } else {
...@@ -704,7 +706,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) ...@@ -704,7 +706,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
spin_unlock_bh(&tipc_nametbl_lock); spin_unlock_bh(&tipc_nametbl_lock);
if (skb) { if (skb) {
named_cluster_distribute(skb); named_cluster_distribute(net, skb);
return 1; return 1;
} }
return 0; return 0;
......
...@@ -104,9 +104,11 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); ...@@ -104,9 +104,11 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space);
u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node);
int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
struct tipc_port_list *dports); struct tipc_port_list *dports);
struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower,
u32 scope, u32 port_ref, u32 key); u32 upper, u32 scope, u32 port_ref,
int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key); u32 key);
int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
u32 key);
struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
u32 scope, u32 node, u32 ref, u32 scope, u32 node, u32 ref,
u32 key); u32 key);
......
...@@ -121,7 +121,7 @@ int tipc_net_start(struct net *net, u32 addr) ...@@ -121,7 +121,7 @@ int tipc_net_start(struct net *net, u32 addr)
if (res) if (res)
return res; return res;
tipc_nametbl_publish(TIPC_CFG_SRV, tipc_own_addr, tipc_own_addr, tipc_nametbl_publish(net, TIPC_CFG_SRV, tipc_own_addr, tipc_own_addr,
TIPC_ZONE_SCOPE, 0, tipc_own_addr); TIPC_ZONE_SCOPE, 0, tipc_own_addr);
pr_info("Started in network mode\n"); pr_info("Started in network mode\n");
...@@ -131,16 +131,17 @@ int tipc_net_start(struct net *net, u32 addr) ...@@ -131,16 +131,17 @@ int tipc_net_start(struct net *net, u32 addr)
return 0; return 0;
} }
void tipc_net_stop(void) void tipc_net_stop(struct net *net)
{ {
if (!tipc_own_addr) if (!tipc_own_addr)
return; return;
tipc_nametbl_withdraw(TIPC_CFG_SRV, tipc_own_addr, 0, tipc_own_addr); tipc_nametbl_withdraw(net, TIPC_CFG_SRV, tipc_own_addr, 0,
tipc_own_addr);
rtnl_lock(); rtnl_lock();
tipc_bearer_stop(); tipc_bearer_stop(net);
tipc_bclink_stop(); tipc_bclink_stop();
tipc_node_stop(); tipc_node_stop(net);
rtnl_unlock(); rtnl_unlock();
pr_info("Left network mode\n"); pr_info("Left network mode\n");
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
int tipc_net_start(struct net *net, u32 addr); int tipc_net_start(struct net *net, u32 addr);
void tipc_net_stop(void); void tipc_net_stop(struct net *net);
int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb); int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb);
int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info); int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info);
......
This diff is collapsed.
...@@ -42,11 +42,11 @@ ...@@ -42,11 +42,11 @@
#include "bearer.h" #include "bearer.h"
#include "msg.h" #include "msg.h"
/* /* Out-of-range value for node signature */
* Out-of-range value for node signature
*/
#define INVALID_NODE_SIG 0x10000 #define INVALID_NODE_SIG 0x10000
#define NODE_HTABLE_SIZE 512
/* Flags used to take different actions according to flag type /* Flags used to take different actions according to flag type
* TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down
* TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down
...@@ -90,6 +90,7 @@ struct tipc_node_bclink { ...@@ -90,6 +90,7 @@ struct tipc_node_bclink {
* struct tipc_node - TIPC node structure * struct tipc_node - TIPC node structure
* @addr: network address of node * @addr: network address of node
* @lock: spinlock governing access to structure * @lock: spinlock governing access to structure
* @net: the applicable net namespace
* @hash: links to adjacent nodes in unsorted hash chain * @hash: links to adjacent nodes in unsorted hash chain
* @active_links: pointers to active links to node * @active_links: pointers to active links to node
* @links: pointers to all links to node * @links: pointers to all links to node
...@@ -106,6 +107,7 @@ struct tipc_node_bclink { ...@@ -106,6 +107,7 @@ struct tipc_node_bclink {
struct tipc_node { struct tipc_node {
u32 addr; u32 addr;
spinlock_t lock; spinlock_t lock;
struct net *net;
struct hlist_node hash; struct hlist_node hash;
struct tipc_link *active_links[2]; struct tipc_link *active_links[2];
u32 act_mtus[2]; u32 act_mtus[2];
...@@ -123,23 +125,24 @@ struct tipc_node { ...@@ -123,23 +125,24 @@ struct tipc_node {
struct rcu_head rcu; struct rcu_head rcu;
}; };
extern struct list_head tipc_node_list; struct tipc_node *tipc_node_find(struct net *net, u32 addr);
struct tipc_node *tipc_node_create(struct net *net, u32 addr);
struct tipc_node *tipc_node_find(u32 addr); void tipc_node_stop(struct net *net);
struct tipc_node *tipc_node_create(u32 addr);
void tipc_node_stop(void);
void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr); void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr); void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
int tipc_node_active_links(struct tipc_node *n_ptr); int tipc_node_active_links(struct tipc_node *n_ptr);
int tipc_node_is_up(struct tipc_node *n_ptr); int tipc_node_is_up(struct tipc_node *n_ptr);
struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area,
struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); int req_tlv_space);
int tipc_node_get_linkname(u32 bearer_id, u32 node, char *linkname, size_t len); struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area,
int req_tlv_space);
int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node,
char *linkname, size_t len);
void tipc_node_unlock(struct tipc_node *node); void tipc_node_unlock(struct tipc_node *node);
int tipc_node_add_conn(u32 dnode, u32 port, u32 peer_port); int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);
void tipc_node_remove_conn(u32 dnode, u32 port); void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port);
int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb);
...@@ -154,12 +157,12 @@ static inline bool tipc_node_blocked(struct tipc_node *node) ...@@ -154,12 +157,12 @@ static inline bool tipc_node_blocked(struct tipc_node *node)
TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN)); TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN));
} }
static inline uint tipc_node_get_mtu(u32 addr, u32 selector) static inline uint tipc_node_get_mtu(struct net *net, u32 addr, u32 selector)
{ {
struct tipc_node *node; struct tipc_node *node;
u32 mtu; u32 mtu;
node = tipc_node_find(addr); node = tipc_node_find(net, addr);
if (likely(node)) if (likely(node))
mtu = node->act_mtus[selector & 1]; mtu = node->act_mtus[selector & 1];
......
This diff is collapsed.
...@@ -49,9 +49,9 @@ int tipc_sock_create_local(int type, struct socket **res); ...@@ -49,9 +49,9 @@ int tipc_sock_create_local(int type, struct socket **res);
void tipc_sock_release_local(struct socket *sock); void tipc_sock_release_local(struct socket *sock);
int tipc_sock_accept_local(struct socket *sock, struct socket **newsock, int tipc_sock_accept_local(struct socket *sock, struct socket **newsock,
int flags); int flags);
int tipc_sk_rcv(struct sk_buff *buf); int tipc_sk_rcv(struct net *net, struct sk_buff *buf);
struct sk_buff *tipc_sk_socks_show(void); struct sk_buff *tipc_sk_socks_show(void);
void tipc_sk_mcast_rcv(struct sk_buff *buf); void tipc_sk_mcast_rcv(struct net *net, struct sk_buff *buf);
void tipc_sk_reinit(void); void tipc_sk_reinit(void);
int tipc_sk_rht_init(void); int tipc_sk_rht_init(void);
void tipc_sk_rht_destroy(void); void tipc_sk_rht_destroy(void);
......
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