Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -248,7 +248,8 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
							req_tlv_space);
		break;
	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;
	case TIPC_CMD_GET_BEARER_NAMES:
		rep_tlv_buf = tipc_bearer_get_names(net);
+12 −7
Original line number Diff line number Diff line
@@ -62,12 +62,24 @@ static int __net_init tipc_init_net(struct net *net)
	spin_lock_init(&tn->node_list_lock);

	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;
}

static void __net_exit tipc_exit_net(struct net *net)
{
	tipc_net_stop(net);
	tipc_nametbl_stop(net);
	tipc_sk_rht_destroy(net);
}

@@ -98,10 +110,6 @@ static int __init tipc_init(void)
	if (err)
		goto out_pernet;

	err = tipc_nametbl_init();
	if (err)
		goto out_nametbl;

	err = tipc_netlink_start();
	if (err)
		goto out_netlink;
@@ -133,8 +141,6 @@ static int __init tipc_init(void)
out_socket:
	tipc_netlink_stop();
out_netlink:
	tipc_nametbl_stop();
out_nametbl:
	unregister_pernet_subsys(&tipc_net_ops);
out_pernet:
	pr_err("Unable to start in single node mode\n");
@@ -147,7 +153,6 @@ static void __exit tipc_exit(void)
	tipc_bearer_cleanup();
	tipc_netlink_stop();
	tipc_subscr_stop();
	tipc_nametbl_stop();
	tipc_socket_stop();
	tipc_unregister_sysctl();

+4 −0
Original line number Diff line number Diff line
@@ -105,6 +105,10 @@ struct tipc_net {

	/* Socket hash table */
	struct rhashtable sk_rht;

	/* Name table */
	spinlock_t nametbl_lock;
	struct name_table *nametbl;
};

#ifdef CONFIG_SYSCTL
+2 −2
Original line number Diff line number Diff line
@@ -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
 * 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);
	u32 dport;
@@ -441,7 +441,7 @@ int tipc_msg_eval(struct sk_buff *buf, u32 *dnode)
		return -TIPC_ERR_NO_NAME;

	*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),
				       dnode);
	if (!dport)
+1 −1
Original line number Diff line number Diff line
@@ -749,7 +749,7 @@ static inline u32 msg_tot_origport(struct tipc_msg *m)

struct sk_buff *tipc_buf_acquire(u32 size);
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,
		   u32 destnode);
struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
Loading