Skip to content

Commit b58343f

Browse files
ajstephensPaul Gortmaker
authored andcommitted
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: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
1 parent 077a26f commit b58343f

6 files changed

Lines changed: 5 additions & 20 deletions

File tree

‎net/tipc/bearer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
435435
u32 i;
436436
int res = -EINVAL;
437437

438-
if (tipc_mode != TIPC_NET_MODE) {
438+
if (!tipc_own_addr) {
439439
warn("Bearer <%s> rejected, not supported in standalone mode\n",
440440
name);
441441
return -ENOPROTOOPT;

‎net/tipc/config.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static struct sk_buff *cfg_set_own_addr(void)
179179
if (!tipc_addr_node_valid(addr))
180180
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
181181
" (node address)");
182-
if (tipc_mode == TIPC_NET_MODE)
182+
if (tipc_own_addr)
183183
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
184184
" (cannot change node address once assigned)");
185185

@@ -268,7 +268,7 @@ static struct sk_buff *cfg_set_netid(void)
268268
if (value < 1 || value > 9999)
269269
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
270270
" (network id must be 1-9999)");
271-
if (tipc_mode == TIPC_NET_MODE)
271+
if (tipc_own_addr)
272272
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
273273
" (cannot change network id once TIPC has joined a network)");
274274
tipc_net_id = value;

‎net/tipc/core.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454
/* global variables used by multiple sub-systems within TIPC */
5555

56-
int tipc_mode;
5756
int tipc_random;
5857

5958
const char tipc_alphabet[] =
@@ -144,7 +143,6 @@ static int tipc_core_start(void)
144143
int res;
145144

146145
get_random_bytes(&tipc_random, sizeof(tipc_random));
147-
tipc_mode = TIPC_NODE_MODE;
148146

149147
res = tipc_handler_start();
150148
if (!res)

‎net/tipc/core.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *);
129129

130130
#define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */
131131

132-
/*
133-
* TIPC operating mode routines
134-
*/
135-
136-
#define TIPC_NODE_MODE 1
137-
#define TIPC_NET_MODE 2
138-
139132
/*
140133
* Global configuration variables
141134
*/
@@ -151,7 +144,6 @@ extern int tipc_remote_management;
151144
* Other global variables
152145
*/
153146

154-
extern int tipc_mode;
155147
extern int tipc_random;
156148
extern const char tipc_alphabet[];
157149

‎net/tipc/net.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,10 @@ int tipc_net_start(u32 addr)
175175
{
176176
char addr_string[16];
177177

178-
if (tipc_mode != TIPC_NODE_MODE)
179-
return -ENOPROTOOPT;
180-
181178
tipc_subscr_stop();
182179
tipc_cfg_stop();
183180

184181
tipc_own_addr = addr;
185-
tipc_mode = TIPC_NET_MODE;
186182
tipc_named_reinit();
187183
tipc_port_reinit();
188184

@@ -201,10 +197,9 @@ void tipc_net_stop(void)
201197
{
202198
struct tipc_node *node, *t_node;
203199

204-
if (tipc_mode != TIPC_NET_MODE)
200+
if (!tipc_own_addr)
205201
return;
206202
write_lock_bh(&tipc_net_lock);
207-
tipc_mode = TIPC_NODE_MODE;
208203
tipc_bearer_stop();
209204
tipc_bclink_stop();
210205
list_for_each_entry_safe(node, t_node, &tipc_node_list, list)

‎net/tipc/node.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
406406
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
407407
" (network address)");
408408

409-
if (tipc_mode != TIPC_NET_MODE)
409+
if (!tipc_own_addr)
410410
return tipc_cfg_reply_none();
411411

412412
read_lock_bh(&tipc_net_lock);

0 commit comments

Comments
 (0)