aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r--net/tipc/net.c44
1 files changed, 11 insertions, 33 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 68b3dd637291..5b5cea259caf 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -117,7 +117,7 @@ static void net_route_named_msg(struct sk_buff *buf)
117 u32 dport; 117 u32 dport;
118 118
119 if (!msg_named(msg)) { 119 if (!msg_named(msg)) {
120 buf_discard(buf); 120 kfree_skb(buf);
121 return; 121 return;
122 } 122 }
123 123
@@ -141,17 +141,6 @@ void tipc_net_route_msg(struct sk_buff *buf)
141 return; 141 return;
142 msg = buf_msg(buf); 142 msg = buf_msg(buf);
143 143
144 msg_incr_reroute_cnt(msg);
145 if (msg_reroute_cnt(msg) > 6) {
146 if (msg_errcode(msg)) {
147 buf_discard(buf);
148 } else {
149 tipc_reject_msg(buf, msg_destport(msg) ?
150 TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME);
151 }
152 return;
153 }
154
155 /* Handle message for this node */ 144 /* Handle message for this node */
156 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); 145 dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg);
157 if (tipc_in_scope(dnode, tipc_own_addr)) { 146 if (tipc_in_scope(dnode, tipc_own_addr)) {
@@ -172,7 +161,7 @@ void tipc_net_route_msg(struct sk_buff *buf)
172 tipc_port_recv_proto_msg(buf); 161 tipc_port_recv_proto_msg(buf);
173 break; 162 break;
174 default: 163 default:
175 buf_discard(buf); 164 kfree_skb(buf);
176 } 165 }
177 return; 166 return;
178 } 167 }
@@ -185,29 +174,19 @@ void tipc_net_route_msg(struct sk_buff *buf)
185int tipc_net_start(u32 addr) 174int tipc_net_start(u32 addr)
186{ 175{
187 char addr_string[16]; 176 char addr_string[16];
188 int res;
189
190 if (tipc_mode != TIPC_NODE_MODE)
191 return -ENOPROTOOPT;
192
193 tipc_subscr_stop();
194 tipc_cfg_stop();
195 177
178 write_lock_bh(&tipc_net_lock);
196 tipc_own_addr = addr; 179 tipc_own_addr = addr;
197 tipc_mode = TIPC_NET_MODE;
198 tipc_named_reinit(); 180 tipc_named_reinit();
199 tipc_port_reinit(); 181 tipc_port_reinit();
182 tipc_bclink_init();
183 write_unlock_bh(&tipc_net_lock);
200 184
201 res = tipc_bclink_init(); 185 tipc_cfg_reinit();
202 if (res)
203 return res;
204
205 tipc_k_signal((Handler)tipc_subscr_start, 0);
206 tipc_k_signal((Handler)tipc_cfg_init, 0);
207 186
208 info("Started in network mode\n"); 187 pr_info("Started in network mode\n");
209 info("Own node address %s, network identity %u\n", 188 pr_info("Own node address %s, network identity %u\n",
210 tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); 189 tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id);
211 return 0; 190 return 0;
212} 191}
213 192
@@ -215,14 +194,13 @@ void tipc_net_stop(void)
215{ 194{
216 struct tipc_node *node, *t_node; 195 struct tipc_node *node, *t_node;
217 196
218 if (tipc_mode != TIPC_NET_MODE) 197 if (!tipc_own_addr)
219 return; 198 return;
220 write_lock_bh(&tipc_net_lock); 199 write_lock_bh(&tipc_net_lock);
221 tipc_bearer_stop(); 200 tipc_bearer_stop();
222 tipc_mode = TIPC_NODE_MODE;
223 tipc_bclink_stop(); 201 tipc_bclink_stop();
224 list_for_each_entry_safe(node, t_node, &tipc_node_list, list) 202 list_for_each_entry_safe(node, t_node, &tipc_node_list, list)
225 tipc_node_delete(node); 203 tipc_node_delete(node);
226 write_unlock_bh(&tipc_net_lock); 204 write_unlock_bh(&tipc_net_lock);
227 info("Left network mode\n"); 205 pr_info("Left network mode\n");
228} 206}