Commit b58343f9 authored by Allan Stephens's avatar Allan Stephens Committed by Paul Gortmaker

tipc: Eliminate support for tipc_mode global variable

Removes all references to the global variable that records whether
TIPC is running in "single node" mode or "network" mode, since this
information can be easily deduced from the global variable that
records TIPC's network address. (i.e. a non-zero network address
means that TIPC is running in network mode.)

The changes made update most existing mode-based checks to use the
network address global variable. A few checks that are no longer
needed are removed entirely, along with any associated code lying on
non-executable control paths.
Signed-off-by: default avatarAllan Stephens <allan.stephens@windriver.com>
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent 077a26f0
...@@ -435,7 +435,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) ...@@ -435,7 +435,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
u32 i; u32 i;
int res = -EINVAL; int res = -EINVAL;
if (tipc_mode != TIPC_NET_MODE) { if (!tipc_own_addr) {
warn("Bearer <%s> rejected, not supported in standalone mode\n", warn("Bearer <%s> rejected, not supported in standalone mode\n",
name); name);
return -ENOPROTOOPT; return -ENOPROTOOPT;
......
...@@ -179,7 +179,7 @@ static struct sk_buff *cfg_set_own_addr(void) ...@@ -179,7 +179,7 @@ static struct sk_buff *cfg_set_own_addr(void)
if (!tipc_addr_node_valid(addr)) if (!tipc_addr_node_valid(addr))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (node address)"); " (node address)");
if (tipc_mode == TIPC_NET_MODE) if (tipc_own_addr)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change node address once assigned)"); " (cannot change node address once assigned)");
...@@ -268,7 +268,7 @@ static struct sk_buff *cfg_set_netid(void) ...@@ -268,7 +268,7 @@ static struct sk_buff *cfg_set_netid(void)
if (value < 1 || value > 9999) if (value < 1 || value > 9999)
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (network id must be 1-9999)"); " (network id must be 1-9999)");
if (tipc_mode == TIPC_NET_MODE) if (tipc_own_addr)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change network id once TIPC has joined a network)"); " (cannot change network id once TIPC has joined a network)");
tipc_net_id = value; tipc_net_id = value;
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
/* global variables used by multiple sub-systems within TIPC */ /* global variables used by multiple sub-systems within TIPC */
int tipc_mode;
int tipc_random; int tipc_random;
const char tipc_alphabet[] = const char tipc_alphabet[] =
...@@ -144,7 +143,6 @@ static int tipc_core_start(void) ...@@ -144,7 +143,6 @@ static int tipc_core_start(void)
int res; int res;
get_random_bytes(&tipc_random, sizeof(tipc_random)); get_random_bytes(&tipc_random, sizeof(tipc_random));
tipc_mode = TIPC_NODE_MODE;
res = tipc_handler_start(); res = tipc_handler_start();
if (!res) if (!res)
......
...@@ -129,13 +129,6 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); ...@@ -129,13 +129,6 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *);
#define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */
/*
* TIPC operating mode routines
*/
#define TIPC_NODE_MODE 1
#define TIPC_NET_MODE 2
/* /*
* Global configuration variables * Global configuration variables
*/ */
...@@ -151,7 +144,6 @@ extern int tipc_remote_management; ...@@ -151,7 +144,6 @@ extern int tipc_remote_management;
* Other global variables * Other global variables
*/ */
extern int tipc_mode;
extern int tipc_random; extern int tipc_random;
extern const char tipc_alphabet[]; extern const char tipc_alphabet[];
......
...@@ -175,14 +175,10 @@ int tipc_net_start(u32 addr) ...@@ -175,14 +175,10 @@ int tipc_net_start(u32 addr)
{ {
char addr_string[16]; char addr_string[16];
if (tipc_mode != TIPC_NODE_MODE)
return -ENOPROTOOPT;
tipc_subscr_stop(); tipc_subscr_stop();
tipc_cfg_stop(); tipc_cfg_stop();
tipc_own_addr = addr; tipc_own_addr = addr;
tipc_mode = TIPC_NET_MODE;
tipc_named_reinit(); tipc_named_reinit();
tipc_port_reinit(); tipc_port_reinit();
...@@ -201,10 +197,9 @@ void tipc_net_stop(void) ...@@ -201,10 +197,9 @@ void tipc_net_stop(void)
{ {
struct tipc_node *node, *t_node; struct tipc_node *node, *t_node;
if (tipc_mode != TIPC_NET_MODE) if (!tipc_own_addr)
return; return;
write_lock_bh(&tipc_net_lock); write_lock_bh(&tipc_net_lock);
tipc_mode = TIPC_NODE_MODE;
tipc_bearer_stop(); tipc_bearer_stop();
tipc_bclink_stop(); tipc_bclink_stop();
list_for_each_entry_safe(node, t_node, &tipc_node_list, list) list_for_each_entry_safe(node, t_node, &tipc_node_list, list)
......
...@@ -406,7 +406,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) ...@@ -406,7 +406,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (network address)"); " (network address)");
if (tipc_mode != TIPC_NET_MODE) if (!tipc_own_addr)
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
......
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