Commit 68ad785c authored by David S. Miller's avatar David S. Miller

Merge branch 'tipc'

Ying Xue says:

====================
tipc: clean up components initialization code

In this series, we will fix a regression issue involved by commit
6e967adf(tipc: relocate common functions from media to bearer)
But before the issue is fixed, we firstly adjust the process of
components initialization so as to remove all enabled flags from
necessary tipc components. Otherwise, without the change, we also
have to add an extra enabled flag into bearer layer indicating
whether bearer setup is finshed or not.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7cce3b75 970122fd
......@@ -610,8 +610,13 @@ static struct notifier_block notifier = {
int tipc_bearer_setup(void)
{
int err;
err = register_netdevice_notifier(&notifier);
if (err)
return err;
dev_add_pack(&tipc_packet_type);
return register_netdevice_notifier(&notifier);
return 0;
}
void tipc_bearer_cleanup(void)
......
......@@ -181,7 +181,7 @@ static struct sk_buff *cfg_set_own_addr(void)
if (tipc_own_addr)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change node address once assigned)");
tipc_core_start_net(addr);
tipc_net_start(addr);
return tipc_cfg_reply_none();
}
......
......@@ -76,38 +76,14 @@ struct sk_buff *tipc_buf_acquire(u32 size)
return skb;
}
/**
* tipc_core_stop_net - shut down TIPC networking sub-systems
*/
static void tipc_core_stop_net(void)
{
tipc_net_stop();
tipc_bearer_cleanup();
}
/**
* start_net - start TIPC networking sub-systems
*/
int tipc_core_start_net(unsigned long addr)
{
int res;
tipc_net_start(addr);
res = tipc_bearer_setup();
if (res < 0)
goto err;
return res;
err:
tipc_core_stop_net();
return res;
}
/**
* tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode
*/
static void tipc_core_stop(void)
{
tipc_handler_stop();
tipc_net_stop();
tipc_bearer_cleanup();
tipc_netlink_stop();
tipc_cfg_stop();
tipc_subscr_stop();
......@@ -122,30 +98,65 @@ static void tipc_core_stop(void)
*/
static int tipc_core_start(void)
{
int res;
int err;
get_random_bytes(&tipc_random, sizeof(tipc_random));
res = tipc_handler_start();
if (!res)
res = tipc_ref_table_init(tipc_max_ports, tipc_random);
if (!res)
res = tipc_nametbl_init();
if (!res)
res = tipc_netlink_start();
if (!res)
res = tipc_socket_init();
if (!res)
res = tipc_register_sysctl();
if (!res)
res = tipc_subscr_start();
if (!res)
res = tipc_cfg_init();
if (res) {
err = tipc_handler_start();
if (err)
goto out_handler;
err = tipc_ref_table_init(tipc_max_ports, tipc_random);
if (err)
goto out_reftbl;
err = tipc_nametbl_init();
if (err)
goto out_nametbl;
err = tipc_netlink_start();
if (err)
goto out_netlink;
err = tipc_socket_init();
if (err)
goto out_socket;
err = tipc_register_sysctl();
if (err)
goto out_sysctl;
err = tipc_subscr_start();
if (err)
goto out_subscr;
err = tipc_cfg_init();
if (err)
goto out_cfg;
err = tipc_bearer_setup();
if (err)
goto out_bearer;
return 0;
out_bearer:
tipc_cfg_stop();
out_cfg:
tipc_subscr_stop();
out_subscr:
tipc_unregister_sysctl();
out_sysctl:
tipc_socket_stop();
out_socket:
tipc_netlink_stop();
out_netlink:
tipc_nametbl_stop();
out_nametbl:
tipc_ref_table_stop();
out_reftbl:
tipc_handler_stop();
tipc_core_stop();
}
return res;
out_handler:
return err;
}
static int __init tipc_init(void)
......@@ -174,8 +185,6 @@ static int __init tipc_init(void)
static void __exit tipc_exit(void)
{
tipc_handler_stop();
tipc_core_stop_net();
tipc_core_stop();
pr_info("Deactivated\n");
}
......
......@@ -90,7 +90,6 @@ extern int tipc_random __read_mostly;
/*
* Routines available to privileged subsystems
*/
int tipc_core_start_net(unsigned long);
int tipc_handler_start(void);
void tipc_handler_stop(void);
int tipc_netlink_start(void);
......
......@@ -945,9 +945,6 @@ void tipc_nametbl_stop(void)
{
u32 i;
if (!table.types)
return;
/* Verify name table is empty, then release it */
write_lock_bh(&tipc_nametbl_lock);
for (i = 0; i < TIPC_NAMETBL_SIZE; i++) {
......
......@@ -83,8 +83,6 @@ static struct genl_ops tipc_genl_ops[] = {
},
};
static int tipc_genl_family_registered;
int tipc_netlink_start(void)
{
int res;
......@@ -94,16 +92,10 @@ int tipc_netlink_start(void)
pr_err("Failed to register netlink interface\n");
return res;
}
tipc_genl_family_registered = 1;
return 0;
}
void tipc_netlink_stop(void)
{
if (!tipc_genl_family_registered)
return;
genl_unregister_family(&tipc_genl_family);
tipc_genl_family_registered = 0;
}
......@@ -126,9 +126,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
*/
void tipc_ref_table_stop(void)
{
if (!tipc_ref_table.entries)
return;
vfree(tipc_ref_table.entries);
tipc_ref_table.entries = NULL;
}
......
......@@ -573,7 +573,6 @@ int tipc_server_start(struct tipc_server *s)
kmem_cache_destroy(s->rcvbuf_cache);
return ret;
}
s->enabled = 1;
return ret;
}
......@@ -583,10 +582,6 @@ void tipc_server_stop(struct tipc_server *s)
int total = 0;
int id;
if (!s->enabled)
return;
s->enabled = 0;
spin_lock_bh(&s->idr_lock);
for (id = 0; total < s->idr_in_use; id++) {
con = idr_find(&s->conn_idr, id);
......
......@@ -56,7 +56,6 @@
* @name: server name
* @imp: message importance
* @type: socket type
* @enabled: identify whether server is launched or not
*/
struct tipc_server {
struct idr conn_idr;
......@@ -74,7 +73,6 @@ struct tipc_server {
const char name[TIPC_SERVER_NAME_LEN];
int imp;
int type;
int enabled;
};
int tipc_conn_sendmsg(struct tipc_server *s, int conid,
......
......@@ -70,8 +70,6 @@ static const struct proto_ops msg_ops;
static struct proto tipc_proto;
static struct proto tipc_proto_kern;
static int sockets_enabled;
/*
* Revised TIPC socket locking policy:
*
......@@ -2027,8 +2025,6 @@ int tipc_socket_init(void)
proto_unregister(&tipc_proto);
goto out;
}
sockets_enabled = 1;
out:
return res;
}
......@@ -2038,10 +2034,6 @@ int tipc_socket_init(void)
*/
void tipc_socket_stop(void)
{
if (!sockets_enabled)
return;
sockets_enabled = 0;
sock_unregister(tipc_family_ops.family);
proto_unregister(&tipc_proto);
}
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