diff options
Diffstat (limited to 'net/tipc/net.c')
| -rw-r--r-- | net/tipc/net.c | 72 |
1 files changed, 16 insertions, 56 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c index 1a621cfd6604..9bacfd00b91e 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
| @@ -35,18 +35,10 @@ | |||
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | #include "core.h" | 37 | #include "core.h" |
| 38 | #include "bearer.h" | ||
| 39 | #include "net.h" | 38 | #include "net.h" |
| 40 | #include "zone.h" | ||
| 41 | #include "addr.h" | ||
| 42 | #include "name_table.h" | ||
| 43 | #include "name_distr.h" | 39 | #include "name_distr.h" |
| 44 | #include "subscr.h" | 40 | #include "subscr.h" |
| 45 | #include "link.h" | ||
| 46 | #include "msg.h" | ||
| 47 | #include "port.h" | 41 | #include "port.h" |
| 48 | #include "bcast.h" | ||
| 49 | #include "discover.h" | ||
| 50 | #include "config.h" | 42 | #include "config.h" |
| 51 | 43 | ||
| 52 | /* | 44 | /* |
| @@ -116,46 +108,25 @@ | |||
| 116 | */ | 108 | */ |
| 117 | 109 | ||
| 118 | DEFINE_RWLOCK(tipc_net_lock); | 110 | DEFINE_RWLOCK(tipc_net_lock); |
| 119 | static struct _zone *tipc_zones[256] = { NULL, }; | 111 | struct network tipc_net; |
| 120 | struct network tipc_net = { tipc_zones }; | ||
| 121 | 112 | ||
| 122 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) | 113 | static int net_start(void) |
| 123 | { | 114 | { |
| 124 | return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); | 115 | tipc_net.nodes = kcalloc(tipc_max_nodes + 1, |
| 125 | } | 116 | sizeof(*tipc_net.nodes), GFP_ATOMIC); |
| 126 | 117 | tipc_net.highest_node = 0; | |
| 127 | u32 tipc_net_select_router(u32 addr, u32 ref) | ||
| 128 | { | ||
| 129 | return tipc_zone_select_router(tipc_net.zones[tipc_zone(addr)], addr, ref); | ||
| 130 | } | ||
| 131 | |||
| 132 | void tipc_net_remove_as_router(u32 router) | ||
| 133 | { | ||
| 134 | u32 z_num; | ||
| 135 | |||
| 136 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) { | ||
| 137 | if (!tipc_net.zones[z_num]) | ||
| 138 | continue; | ||
| 139 | tipc_zone_remove_as_router(tipc_net.zones[z_num], router); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | void tipc_net_send_external_routes(u32 dest) | ||
| 144 | { | ||
| 145 | u32 z_num; | ||
| 146 | 118 | ||
| 147 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) { | 119 | return tipc_net.nodes ? 0 : -ENOMEM; |
| 148 | if (tipc_net.zones[z_num]) | ||
| 149 | tipc_zone_send_external_routes(tipc_net.zones[z_num], dest); | ||
| 150 | } | ||
| 151 | } | 120 | } |
| 152 | 121 | ||
| 153 | static void net_stop(void) | 122 | static void net_stop(void) |
| 154 | { | 123 | { |
| 155 | u32 z_num; | 124 | u32 n_num; |
| 156 | 125 | ||
| 157 | for (z_num = 1; z_num <= tipc_max_zones; z_num++) | 126 | for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) |
| 158 | tipc_zone_delete(tipc_net.zones[z_num]); | 127 | tipc_node_delete(tipc_net.nodes[n_num]); |
| 128 | kfree(tipc_net.nodes); | ||
| 129 | tipc_net.nodes = NULL; | ||
| 159 | } | 130 | } |
| 160 | 131 | ||
| 161 | static void net_route_named_msg(struct sk_buff *buf) | 132 | static void net_route_named_msg(struct sk_buff *buf) |
| @@ -165,22 +136,18 @@ static void net_route_named_msg(struct sk_buff *buf) | |||
| 165 | u32 dport; | 136 | u32 dport; |
| 166 | 137 | ||
| 167 | if (!msg_named(msg)) { | 138 | if (!msg_named(msg)) { |
| 168 | msg_dbg(msg, "tipc_net->drop_nam:"); | ||
| 169 | buf_discard(buf); | 139 | buf_discard(buf); |
| 170 | return; | 140 | return; |
| 171 | } | 141 | } |
| 172 | 142 | ||
| 173 | dnode = addr_domain(msg_lookup_scope(msg)); | 143 | dnode = addr_domain(msg_lookup_scope(msg)); |
| 174 | dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode); | 144 | dport = tipc_nametbl_translate(msg_nametype(msg), msg_nameinst(msg), &dnode); |
| 175 | dbg("tipc_net->lookup<%u,%u>-><%u,%x>\n", | ||
| 176 | msg_nametype(msg), msg_nameinst(msg), dport, dnode); | ||
| 177 | if (dport) { | 145 | if (dport) { |
| 178 | msg_set_destnode(msg, dnode); | 146 | msg_set_destnode(msg, dnode); |
| 179 | msg_set_destport(msg, dport); | 147 | msg_set_destport(msg, dport); |
| 180 | tipc_net_route_msg(buf); | 148 | tipc_net_route_msg(buf); |
| 181 | return; | 149 | return; |
| 182 | } | 150 | } |
| 183 | msg_dbg(msg, "tipc_net->rej:NO NAME: "); | ||
| 184 | tipc_reject_msg(buf, TIPC_ERR_NO_NAME); | 151 | tipc_reject_msg(buf, TIPC_ERR_NO_NAME); |
| 185 | } | 152 | } |
| 186 | 153 | ||
| @@ -196,18 +163,14 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
| 196 | msg_incr_reroute_cnt(msg); | 163 | msg_incr_reroute_cnt(msg); |
| 197 | if (msg_reroute_cnt(msg) > 6) { | 164 | if (msg_reroute_cnt(msg) > 6) { |
| 198 | if (msg_errcode(msg)) { | 165 | if (msg_errcode(msg)) { |
| 199 | msg_dbg(msg, "NET>DISC>:"); | ||
| 200 | buf_discard(buf); | 166 | buf_discard(buf); |
| 201 | } else { | 167 | } else { |
| 202 | msg_dbg(msg, "NET>REJ>:"); | ||
| 203 | tipc_reject_msg(buf, msg_destport(msg) ? | 168 | tipc_reject_msg(buf, msg_destport(msg) ? |
| 204 | TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME); | 169 | TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME); |
| 205 | } | 170 | } |
| 206 | return; | 171 | return; |
| 207 | } | 172 | } |
| 208 | 173 | ||
| 209 | msg_dbg(msg, "tipc_net->rout: "); | ||
| 210 | |||
| 211 | /* Handle message for this node */ | 174 | /* Handle message for this node */ |
| 212 | dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); | 175 | dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); |
| 213 | if (tipc_in_scope(dnode, tipc_own_addr)) { | 176 | if (tipc_in_scope(dnode, tipc_own_addr)) { |
| @@ -221,9 +184,6 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
| 221 | return; | 184 | return; |
| 222 | } | 185 | } |
| 223 | switch (msg_user(msg)) { | 186 | switch (msg_user(msg)) { |
| 224 | case ROUTE_DISTRIBUTOR: | ||
| 225 | tipc_cltr_recv_routing_table(buf); | ||
| 226 | break; | ||
| 227 | case NAME_DISTRIBUTOR: | 187 | case NAME_DISTRIBUTOR: |
| 228 | tipc_named_recv(buf); | 188 | tipc_named_recv(buf); |
| 229 | break; | 189 | break; |
| @@ -231,14 +191,12 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
| 231 | tipc_port_recv_proto_msg(buf); | 191 | tipc_port_recv_proto_msg(buf); |
| 232 | break; | 192 | break; |
| 233 | default: | 193 | default: |
| 234 | msg_dbg(msg,"DROP/NET/<REC<"); | ||
| 235 | buf_discard(buf); | 194 | buf_discard(buf); |
| 236 | } | 195 | } |
| 237 | return; | 196 | return; |
| 238 | } | 197 | } |
| 239 | 198 | ||
| 240 | /* Handle message for another node */ | 199 | /* Handle message for another node */ |
| 241 | msg_dbg(msg, "NET>SEND>: "); | ||
| 242 | skb_trim(buf, msg_size(msg)); | 200 | skb_trim(buf, msg_size(msg)); |
| 243 | tipc_link_send(buf, dnode, msg_link_selector(msg)); | 201 | tipc_link_send(buf, dnode, msg_link_selector(msg)); |
| 244 | } | 202 | } |
| @@ -259,10 +217,12 @@ int tipc_net_start(u32 addr) | |||
| 259 | tipc_named_reinit(); | 217 | tipc_named_reinit(); |
| 260 | tipc_port_reinit(); | 218 | tipc_port_reinit(); |
| 261 | 219 | ||
| 262 | if ((res = tipc_cltr_init()) || | 220 | res = net_start(); |
| 263 | (res = tipc_bclink_init())) { | 221 | if (res) |
| 222 | return res; | ||
| 223 | res = tipc_bclink_init(); | ||
| 224 | if (res) | ||
| 264 | return res; | 225 | return res; |
| 265 | } | ||
| 266 | 226 | ||
| 267 | tipc_k_signal((Handler)tipc_subscr_start, 0); | 227 | tipc_k_signal((Handler)tipc_subscr_start, 0); |
| 268 | tipc_k_signal((Handler)tipc_cfg_init, 0); | 228 | tipc_k_signal((Handler)tipc_cfg_init, 0); |
