diff options
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r-- | net/tipc/port.c | 511 |
1 files changed, 201 insertions, 310 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c index 82092eaa1536..c68dc956a423 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/port.c: TIPC port code | 2 | * net/tipc/port.c: TIPC port code |
3 | * | 3 | * |
4 | * Copyright (c) 1992-2007, Ericsson AB | 4 | * Copyright (c) 1992-2007, Ericsson AB |
5 | * Copyright (c) 2004-2008, Wind River Systems | 5 | * Copyright (c) 2004-2008, 2010-2011, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -36,15 +36,8 @@ | |||
36 | 36 | ||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "config.h" | 38 | #include "config.h" |
39 | #include "dbg.h" | ||
40 | #include "port.h" | 39 | #include "port.h" |
41 | #include "addr.h" | ||
42 | #include "link.h" | ||
43 | #include "node.h" | ||
44 | #include "name_table.h" | 40 | #include "name_table.h" |
45 | #include "user_reg.h" | ||
46 | #include "msg.h" | ||
47 | #include "bcast.h" | ||
48 | 41 | ||
49 | /* Connection management: */ | 42 | /* Connection management: */ |
50 | #define PROBING_INTERVAL 3600000 /* [ms] => 1 h */ | 43 | #define PROBING_INTERVAL 3600000 /* [ms] => 1 h */ |
@@ -53,55 +46,42 @@ | |||
53 | 46 | ||
54 | #define MAX_REJECT_SIZE 1024 | 47 | #define MAX_REJECT_SIZE 1024 |
55 | 48 | ||
56 | static struct sk_buff *msg_queue_head = NULL; | 49 | static struct sk_buff *msg_queue_head; |
57 | static struct sk_buff *msg_queue_tail = NULL; | 50 | static struct sk_buff *msg_queue_tail; |
58 | 51 | ||
59 | DEFINE_SPINLOCK(tipc_port_list_lock); | 52 | DEFINE_SPINLOCK(tipc_port_list_lock); |
60 | static DEFINE_SPINLOCK(queue_lock); | 53 | static DEFINE_SPINLOCK(queue_lock); |
61 | 54 | ||
62 | static LIST_HEAD(ports); | 55 | static LIST_HEAD(ports); |
63 | static void port_handle_node_down(unsigned long ref); | 56 | static void port_handle_node_down(unsigned long ref); |
64 | static struct sk_buff* port_build_self_abort_msg(struct port *,u32 err); | 57 | static struct sk_buff *port_build_self_abort_msg(struct tipc_port *, u32 err); |
65 | static struct sk_buff* port_build_peer_abort_msg(struct port *,u32 err); | 58 | static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err); |
66 | static void port_timeout(unsigned long ref); | 59 | static void port_timeout(unsigned long ref); |
67 | 60 | ||
68 | 61 | ||
69 | static u32 port_peernode(struct port *p_ptr) | 62 | static u32 port_peernode(struct tipc_port *p_ptr) |
70 | { | 63 | { |
71 | return msg_destnode(&p_ptr->publ.phdr); | 64 | return msg_destnode(&p_ptr->phdr); |
72 | } | 65 | } |
73 | 66 | ||
74 | static u32 port_peerport(struct port *p_ptr) | 67 | static u32 port_peerport(struct tipc_port *p_ptr) |
75 | { | 68 | { |
76 | return msg_destport(&p_ptr->publ.phdr); | 69 | return msg_destport(&p_ptr->phdr); |
77 | } | ||
78 | |||
79 | static u32 port_out_seqno(struct port *p_ptr) | ||
80 | { | ||
81 | return msg_transp_seqno(&p_ptr->publ.phdr); | ||
82 | } | ||
83 | |||
84 | static void port_incr_out_seqno(struct port *p_ptr) | ||
85 | { | ||
86 | struct tipc_msg *m = &p_ptr->publ.phdr; | ||
87 | |||
88 | if (likely(!msg_routed(m))) | ||
89 | return; | ||
90 | msg_set_transp_seqno(m, (msg_transp_seqno(m) + 1)); | ||
91 | } | 70 | } |
92 | 71 | ||
93 | /** | 72 | /** |
94 | * tipc_multicast - send a multicast message to local and remote destinations | 73 | * tipc_multicast - send a multicast message to local and remote destinations |
95 | */ | 74 | */ |
96 | 75 | ||
97 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, | 76 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, |
98 | u32 num_sect, struct iovec const *msg_sect) | 77 | u32 num_sect, struct iovec const *msg_sect, |
78 | unsigned int total_len) | ||
99 | { | 79 | { |
100 | struct tipc_msg *hdr; | 80 | struct tipc_msg *hdr; |
101 | struct sk_buff *buf; | 81 | struct sk_buff *buf; |
102 | struct sk_buff *ibuf = NULL; | 82 | struct sk_buff *ibuf = NULL; |
103 | struct port_list dports = {0, NULL, }; | 83 | struct port_list dports = {0, NULL, }; |
104 | struct port *oport = tipc_port_deref(ref); | 84 | struct tipc_port *oport = tipc_port_deref(ref); |
105 | int ext_targets; | 85 | int ext_targets; |
106 | int res; | 86 | int res; |
107 | 87 | ||
@@ -110,13 +90,16 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, | |||
110 | 90 | ||
111 | /* Create multicast message */ | 91 | /* Create multicast message */ |
112 | 92 | ||
113 | hdr = &oport->publ.phdr; | 93 | hdr = &oport->phdr; |
114 | msg_set_type(hdr, TIPC_MCAST_MSG); | 94 | msg_set_type(hdr, TIPC_MCAST_MSG); |
95 | msg_set_lookup_scope(hdr, TIPC_CLUSTER_SCOPE); | ||
96 | msg_set_destport(hdr, 0); | ||
97 | msg_set_destnode(hdr, 0); | ||
115 | msg_set_nametype(hdr, seq->type); | 98 | msg_set_nametype(hdr, seq->type); |
116 | msg_set_namelower(hdr, seq->lower); | 99 | msg_set_namelower(hdr, seq->lower); |
117 | msg_set_nameupper(hdr, seq->upper); | 100 | msg_set_nameupper(hdr, seq->upper); |
118 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); | 101 | msg_set_hdr_sz(hdr, MCAST_H_SIZE); |
119 | res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, | 102 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE, |
120 | !oport->user_port, &buf); | 103 | !oport->user_port, &buf); |
121 | if (unlikely(!buf)) | 104 | if (unlikely(!buf)) |
122 | return res; | 105 | return res; |
@@ -138,9 +121,8 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, | |||
138 | } | 121 | } |
139 | } | 122 | } |
140 | res = tipc_bclink_send_msg(buf); | 123 | res = tipc_bclink_send_msg(buf); |
141 | if ((res < 0) && (dports.count != 0)) { | 124 | if ((res < 0) && (dports.count != 0)) |
142 | buf_discard(ibuf); | 125 | buf_discard(ibuf); |
143 | } | ||
144 | } else { | 126 | } else { |
145 | ibuf = buf; | 127 | ibuf = buf; |
146 | } | 128 | } |
@@ -162,7 +144,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, | |||
162 | 144 | ||
163 | void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp) | 145 | void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp) |
164 | { | 146 | { |
165 | struct tipc_msg* msg; | 147 | struct tipc_msg *msg; |
166 | struct port_list dports = {0, NULL, }; | 148 | struct port_list dports = {0, NULL, }; |
167 | struct port_list *item = dp; | 149 | struct port_list *item = dp; |
168 | int cnt = 0; | 150 | int cnt = 0; |
@@ -183,6 +165,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp) | |||
183 | /* Deliver a copy of message to each destination port */ | 165 | /* Deliver a copy of message to each destination port */ |
184 | 166 | ||
185 | if (dp->count != 0) { | 167 | if (dp->count != 0) { |
168 | msg_set_destnode(msg, tipc_own_addr); | ||
186 | if (dp->count == 1) { | 169 | if (dp->count == 1) { |
187 | msg_set_destport(msg, dp->ports[0]); | 170 | msg_set_destport(msg, dp->ports[0]); |
188 | tipc_port_recv_msg(buf); | 171 | tipc_port_recv_msg(buf); |
@@ -195,13 +178,11 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp) | |||
195 | 178 | ||
196 | if (b == NULL) { | 179 | if (b == NULL) { |
197 | warn("Unable to deliver multicast message(s)\n"); | 180 | warn("Unable to deliver multicast message(s)\n"); |
198 | msg_dbg(msg, "LOST:"); | ||
199 | goto exit; | 181 | goto exit; |
200 | } | 182 | } |
201 | if ((index == 0) && (cnt != 0)) { | 183 | if ((index == 0) && (cnt != 0)) |
202 | item = item->next; | 184 | item = item->next; |
203 | } | 185 | msg_set_destport(buf_msg(b), item->ports[index]); |
204 | msg_set_destport(buf_msg(b),item->ports[index]); | ||
205 | tipc_port_recv_msg(b); | 186 | tipc_port_recv_msg(b); |
206 | } | 187 | } |
207 | } | 188 | } |
@@ -221,7 +202,7 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, | |||
221 | void (*wakeup)(struct tipc_port *), | 202 | void (*wakeup)(struct tipc_port *), |
222 | const u32 importance) | 203 | const u32 importance) |
223 | { | 204 | { |
224 | struct port *p_ptr; | 205 | struct tipc_port *p_ptr; |
225 | struct tipc_msg *msg; | 206 | struct tipc_msg *msg; |
226 | u32 ref; | 207 | u32 ref; |
227 | 208 | ||
@@ -230,21 +211,19 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, | |||
230 | warn("Port creation failed, no memory\n"); | 211 | warn("Port creation failed, no memory\n"); |
231 | return NULL; | 212 | return NULL; |
232 | } | 213 | } |
233 | ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); | 214 | ref = tipc_ref_acquire(p_ptr, &p_ptr->lock); |
234 | if (!ref) { | 215 | if (!ref) { |
235 | warn("Port creation failed, reference table exhausted\n"); | 216 | warn("Port creation failed, reference table exhausted\n"); |
236 | kfree(p_ptr); | 217 | kfree(p_ptr); |
237 | return NULL; | 218 | return NULL; |
238 | } | 219 | } |
239 | 220 | ||
240 | p_ptr->publ.usr_handle = usr_handle; | 221 | p_ptr->usr_handle = usr_handle; |
241 | p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; | 222 | p_ptr->max_pkt = MAX_PKT_DEFAULT; |
242 | p_ptr->publ.ref = ref; | 223 | p_ptr->ref = ref; |
243 | msg = &p_ptr->publ.phdr; | 224 | msg = &p_ptr->phdr; |
244 | tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); | 225 | tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); |
245 | msg_set_origport(msg, ref); | 226 | msg_set_origport(msg, ref); |
246 | p_ptr->last_in_seqno = 41; | ||
247 | p_ptr->sent = 1; | ||
248 | INIT_LIST_HEAD(&p_ptr->wait_list); | 227 | INIT_LIST_HEAD(&p_ptr->wait_list); |
249 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); | 228 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); |
250 | p_ptr->dispatcher = dispatcher; | 229 | p_ptr->dispatcher = dispatcher; |
@@ -256,12 +235,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, | |||
256 | INIT_LIST_HEAD(&p_ptr->port_list); | 235 | INIT_LIST_HEAD(&p_ptr->port_list); |
257 | list_add_tail(&p_ptr->port_list, &ports); | 236 | list_add_tail(&p_ptr->port_list, &ports); |
258 | spin_unlock_bh(&tipc_port_list_lock); | 237 | spin_unlock_bh(&tipc_port_list_lock); |
259 | return &(p_ptr->publ); | 238 | return p_ptr; |
260 | } | 239 | } |
261 | 240 | ||
262 | int tipc_deleteport(u32 ref) | 241 | int tipc_deleteport(u32 ref) |
263 | { | 242 | { |
264 | struct port *p_ptr; | 243 | struct tipc_port *p_ptr; |
265 | struct sk_buff *buf = NULL; | 244 | struct sk_buff *buf = NULL; |
266 | 245 | ||
267 | tipc_withdraw(ref, 0, NULL); | 246 | tipc_withdraw(ref, 0, NULL); |
@@ -273,14 +252,11 @@ int tipc_deleteport(u32 ref) | |||
273 | tipc_port_unlock(p_ptr); | 252 | tipc_port_unlock(p_ptr); |
274 | 253 | ||
275 | k_cancel_timer(&p_ptr->timer); | 254 | k_cancel_timer(&p_ptr->timer); |
276 | if (p_ptr->publ.connected) { | 255 | if (p_ptr->connected) { |
277 | buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT); | 256 | buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT); |
278 | tipc_nodesub_unsubscribe(&p_ptr->subscription); | 257 | tipc_nodesub_unsubscribe(&p_ptr->subscription); |
279 | } | 258 | } |
280 | if (p_ptr->user_port) { | 259 | kfree(p_ptr->user_port); |
281 | tipc_reg_remove_port(p_ptr->user_port); | ||
282 | kfree(p_ptr->user_port); | ||
283 | } | ||
284 | 260 | ||
285 | spin_lock_bh(&tipc_port_list_lock); | 261 | spin_lock_bh(&tipc_port_list_lock); |
286 | list_del(&p_ptr->port_list); | 262 | list_del(&p_ptr->port_list); |
@@ -288,19 +264,18 @@ int tipc_deleteport(u32 ref) | |||
288 | spin_unlock_bh(&tipc_port_list_lock); | 264 | spin_unlock_bh(&tipc_port_list_lock); |
289 | k_term_timer(&p_ptr->timer); | 265 | k_term_timer(&p_ptr->timer); |
290 | kfree(p_ptr); | 266 | kfree(p_ptr); |
291 | dbg("Deleted port %u\n", ref); | ||
292 | tipc_net_route_msg(buf); | 267 | tipc_net_route_msg(buf); |
293 | return 0; | 268 | return 0; |
294 | } | 269 | } |
295 | 270 | ||
296 | static int port_unreliable(struct port *p_ptr) | 271 | static int port_unreliable(struct tipc_port *p_ptr) |
297 | { | 272 | { |
298 | return msg_src_droppable(&p_ptr->publ.phdr); | 273 | return msg_src_droppable(&p_ptr->phdr); |
299 | } | 274 | } |
300 | 275 | ||
301 | int tipc_portunreliable(u32 ref, unsigned int *isunreliable) | 276 | int tipc_portunreliable(u32 ref, unsigned int *isunreliable) |
302 | { | 277 | { |
303 | struct port *p_ptr; | 278 | struct tipc_port *p_ptr; |
304 | 279 | ||
305 | p_ptr = tipc_port_lock(ref); | 280 | p_ptr = tipc_port_lock(ref); |
306 | if (!p_ptr) | 281 | if (!p_ptr) |
@@ -312,24 +287,24 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable) | |||
312 | 287 | ||
313 | int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) | 288 | int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) |
314 | { | 289 | { |
315 | struct port *p_ptr; | 290 | struct tipc_port *p_ptr; |
316 | 291 | ||
317 | p_ptr = tipc_port_lock(ref); | 292 | p_ptr = tipc_port_lock(ref); |
318 | if (!p_ptr) | 293 | if (!p_ptr) |
319 | return -EINVAL; | 294 | return -EINVAL; |
320 | msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0)); | 295 | msg_set_src_droppable(&p_ptr->phdr, (isunreliable != 0)); |
321 | tipc_port_unlock(p_ptr); | 296 | tipc_port_unlock(p_ptr); |
322 | return 0; | 297 | return 0; |
323 | } | 298 | } |
324 | 299 | ||
325 | static int port_unreturnable(struct port *p_ptr) | 300 | static int port_unreturnable(struct tipc_port *p_ptr) |
326 | { | 301 | { |
327 | return msg_dest_droppable(&p_ptr->publ.phdr); | 302 | return msg_dest_droppable(&p_ptr->phdr); |
328 | } | 303 | } |
329 | 304 | ||
330 | int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) | 305 | int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) |
331 | { | 306 | { |
332 | struct port *p_ptr; | 307 | struct tipc_port *p_ptr; |
333 | 308 | ||
334 | p_ptr = tipc_port_lock(ref); | 309 | p_ptr = tipc_port_lock(ref); |
335 | if (!p_ptr) | 310 | if (!p_ptr) |
@@ -341,12 +316,12 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) | |||
341 | 316 | ||
342 | int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) | 317 | int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) |
343 | { | 318 | { |
344 | struct port *p_ptr; | 319 | struct tipc_port *p_ptr; |
345 | 320 | ||
346 | p_ptr = tipc_port_lock(ref); | 321 | p_ptr = tipc_port_lock(ref); |
347 | if (!p_ptr) | 322 | if (!p_ptr) |
348 | return -EINVAL; | 323 | return -EINVAL; |
349 | msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0)); | 324 | msg_set_dest_droppable(&p_ptr->phdr, (isunrejectable != 0)); |
350 | tipc_port_unlock(p_ptr); | 325 | tipc_port_unlock(p_ptr); |
351 | return 0; | 326 | return 0; |
352 | } | 327 | } |
@@ -359,7 +334,7 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) | |||
359 | static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, | 334 | static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, |
360 | u32 origport, u32 orignode, | 335 | u32 origport, u32 orignode, |
361 | u32 usr, u32 type, u32 err, | 336 | u32 usr, u32 type, u32 err, |
362 | u32 seqno, u32 ack) | 337 | u32 ack) |
363 | { | 338 | { |
364 | struct sk_buff *buf; | 339 | struct sk_buff *buf; |
365 | struct tipc_msg *msg; | 340 | struct tipc_msg *msg; |
@@ -372,9 +347,7 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, | |||
372 | msg_set_destport(msg, destport); | 347 | msg_set_destport(msg, destport); |
373 | msg_set_origport(msg, origport); | 348 | msg_set_origport(msg, origport); |
374 | msg_set_orignode(msg, orignode); | 349 | msg_set_orignode(msg, orignode); |
375 | msg_set_transp_seqno(msg, seqno); | ||
376 | msg_set_msgcnt(msg, ack); | 350 | msg_set_msgcnt(msg, ack); |
377 | msg_dbg(msg, "PORT>SEND>:"); | ||
378 | } | 351 | } |
379 | return buf; | 352 | return buf; |
380 | } | 353 | } |
@@ -392,7 +365,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
392 | data_sz = MAX_REJECT_SIZE; | 365 | data_sz = MAX_REJECT_SIZE; |
393 | if (msg_connected(msg) && (imp < TIPC_CRITICAL_IMPORTANCE)) | 366 | if (msg_connected(msg) && (imp < TIPC_CRITICAL_IMPORTANCE)) |
394 | imp++; | 367 | imp++; |
395 | msg_dbg(msg, "port->rej: "); | ||
396 | 368 | ||
397 | /* discard rejected message if it shouldn't be returned to sender */ | 369 | /* discard rejected message if it shouldn't be returned to sender */ |
398 | if (msg_errcode(msg) || msg_dest_droppable(msg)) { | 370 | if (msg_errcode(msg) || msg_dest_droppable(msg)) { |
@@ -429,10 +401,10 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
429 | /* send self-abort message when rejecting on a connected port */ | 401 | /* send self-abort message when rejecting on a connected port */ |
430 | if (msg_connected(msg)) { | 402 | if (msg_connected(msg)) { |
431 | struct sk_buff *abuf = NULL; | 403 | struct sk_buff *abuf = NULL; |
432 | struct port *p_ptr = tipc_port_lock(msg_destport(msg)); | 404 | struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg)); |
433 | 405 | ||
434 | if (p_ptr) { | 406 | if (p_ptr) { |
435 | if (p_ptr->publ.connected) | 407 | if (p_ptr->connected) |
436 | abuf = port_build_self_abort_msg(p_ptr, err); | 408 | abuf = port_build_self_abort_msg(p_ptr, err); |
437 | tipc_port_unlock(p_ptr); | 409 | tipc_port_unlock(p_ptr); |
438 | } | 410 | } |
@@ -445,14 +417,14 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
445 | return data_sz; | 417 | return data_sz; |
446 | } | 418 | } |
447 | 419 | ||
448 | int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, | 420 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, |
449 | struct iovec const *msg_sect, u32 num_sect, | 421 | struct iovec const *msg_sect, u32 num_sect, |
450 | int err) | 422 | unsigned int total_len, int err) |
451 | { | 423 | { |
452 | struct sk_buff *buf; | 424 | struct sk_buff *buf; |
453 | int res; | 425 | int res; |
454 | 426 | ||
455 | res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, | 427 | res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE, |
456 | !p_ptr->user_port, &buf); | 428 | !p_ptr->user_port, &buf); |
457 | if (!buf) | 429 | if (!buf) |
458 | return res; | 430 | return res; |
@@ -462,13 +434,13 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, | |||
462 | 434 | ||
463 | static void port_timeout(unsigned long ref) | 435 | static void port_timeout(unsigned long ref) |
464 | { | 436 | { |
465 | struct port *p_ptr = tipc_port_lock(ref); | 437 | struct tipc_port *p_ptr = tipc_port_lock(ref); |
466 | struct sk_buff *buf = NULL; | 438 | struct sk_buff *buf = NULL; |
467 | 439 | ||
468 | if (!p_ptr) | 440 | if (!p_ptr) |
469 | return; | 441 | return; |
470 | 442 | ||
471 | if (!p_ptr->publ.connected) { | 443 | if (!p_ptr->connected) { |
472 | tipc_port_unlock(p_ptr); | 444 | tipc_port_unlock(p_ptr); |
473 | return; | 445 | return; |
474 | } | 446 | } |
@@ -479,14 +451,12 @@ static void port_timeout(unsigned long ref) | |||
479 | } else { | 451 | } else { |
480 | buf = port_build_proto_msg(port_peerport(p_ptr), | 452 | buf = port_build_proto_msg(port_peerport(p_ptr), |
481 | port_peernode(p_ptr), | 453 | port_peernode(p_ptr), |
482 | p_ptr->publ.ref, | 454 | p_ptr->ref, |
483 | tipc_own_addr, | 455 | tipc_own_addr, |
484 | CONN_MANAGER, | 456 | CONN_MANAGER, |
485 | CONN_PROBE, | 457 | CONN_PROBE, |
486 | TIPC_OK, | 458 | TIPC_OK, |
487 | port_out_seqno(p_ptr), | ||
488 | 0); | 459 | 0); |
489 | port_incr_out_seqno(p_ptr); | ||
490 | p_ptr->probing_state = PROBING; | 460 | p_ptr->probing_state = PROBING; |
491 | k_start_timer(&p_ptr->timer, p_ptr->probing_interval); | 461 | k_start_timer(&p_ptr->timer, p_ptr->probing_interval); |
492 | } | 462 | } |
@@ -497,8 +467,8 @@ static void port_timeout(unsigned long ref) | |||
497 | 467 | ||
498 | static void port_handle_node_down(unsigned long ref) | 468 | static void port_handle_node_down(unsigned long ref) |
499 | { | 469 | { |
500 | struct port *p_ptr = tipc_port_lock(ref); | 470 | struct tipc_port *p_ptr = tipc_port_lock(ref); |
501 | struct sk_buff* buf = NULL; | 471 | struct sk_buff *buf = NULL; |
502 | 472 | ||
503 | if (!p_ptr) | 473 | if (!p_ptr) |
504 | return; | 474 | return; |
@@ -508,75 +478,71 @@ static void port_handle_node_down(unsigned long ref) | |||
508 | } | 478 | } |
509 | 479 | ||
510 | 480 | ||
511 | static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err) | 481 | static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 err) |
512 | { | 482 | { |
513 | u32 imp = msg_importance(&p_ptr->publ.phdr); | 483 | u32 imp = msg_importance(&p_ptr->phdr); |
514 | 484 | ||
515 | if (!p_ptr->publ.connected) | 485 | if (!p_ptr->connected) |
516 | return NULL; | 486 | return NULL; |
517 | if (imp < TIPC_CRITICAL_IMPORTANCE) | 487 | if (imp < TIPC_CRITICAL_IMPORTANCE) |
518 | imp++; | 488 | imp++; |
519 | return port_build_proto_msg(p_ptr->publ.ref, | 489 | return port_build_proto_msg(p_ptr->ref, |
520 | tipc_own_addr, | 490 | tipc_own_addr, |
521 | port_peerport(p_ptr), | 491 | port_peerport(p_ptr), |
522 | port_peernode(p_ptr), | 492 | port_peernode(p_ptr), |
523 | imp, | 493 | imp, |
524 | TIPC_CONN_MSG, | 494 | TIPC_CONN_MSG, |
525 | err, | 495 | err, |
526 | p_ptr->last_in_seqno + 1, | ||
527 | 0); | 496 | 0); |
528 | } | 497 | } |
529 | 498 | ||
530 | 499 | ||
531 | static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err) | 500 | static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 err) |
532 | { | 501 | { |
533 | u32 imp = msg_importance(&p_ptr->publ.phdr); | 502 | u32 imp = msg_importance(&p_ptr->phdr); |
534 | 503 | ||
535 | if (!p_ptr->publ.connected) | 504 | if (!p_ptr->connected) |
536 | return NULL; | 505 | return NULL; |
537 | if (imp < TIPC_CRITICAL_IMPORTANCE) | 506 | if (imp < TIPC_CRITICAL_IMPORTANCE) |
538 | imp++; | 507 | imp++; |
539 | return port_build_proto_msg(port_peerport(p_ptr), | 508 | return port_build_proto_msg(port_peerport(p_ptr), |
540 | port_peernode(p_ptr), | 509 | port_peernode(p_ptr), |
541 | p_ptr->publ.ref, | 510 | p_ptr->ref, |
542 | tipc_own_addr, | 511 | tipc_own_addr, |
543 | imp, | 512 | imp, |
544 | TIPC_CONN_MSG, | 513 | TIPC_CONN_MSG, |
545 | err, | 514 | err, |
546 | port_out_seqno(p_ptr), | ||
547 | 0); | 515 | 0); |
548 | } | 516 | } |
549 | 517 | ||
550 | void tipc_port_recv_proto_msg(struct sk_buff *buf) | 518 | void tipc_port_recv_proto_msg(struct sk_buff *buf) |
551 | { | 519 | { |
552 | struct tipc_msg *msg = buf_msg(buf); | 520 | struct tipc_msg *msg = buf_msg(buf); |
553 | struct port *p_ptr = tipc_port_lock(msg_destport(msg)); | 521 | struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg)); |
554 | u32 err = TIPC_OK; | 522 | u32 err = TIPC_OK; |
555 | struct sk_buff *r_buf = NULL; | 523 | struct sk_buff *r_buf = NULL; |
556 | struct sk_buff *abort_buf = NULL; | 524 | struct sk_buff *abort_buf = NULL; |
557 | 525 | ||
558 | msg_dbg(msg, "PORT<RECV<:"); | ||
559 | |||
560 | if (!p_ptr) { | 526 | if (!p_ptr) { |
561 | err = TIPC_ERR_NO_PORT; | 527 | err = TIPC_ERR_NO_PORT; |
562 | } else if (p_ptr->publ.connected) { | 528 | } else if (p_ptr->connected) { |
563 | if ((port_peernode(p_ptr) != msg_orignode(msg)) || | 529 | if ((port_peernode(p_ptr) != msg_orignode(msg)) || |
564 | (port_peerport(p_ptr) != msg_origport(msg))) { | 530 | (port_peerport(p_ptr) != msg_origport(msg))) { |
565 | err = TIPC_ERR_NO_PORT; | 531 | err = TIPC_ERR_NO_PORT; |
566 | } else if (msg_type(msg) == CONN_ACK) { | 532 | } else if (msg_type(msg) == CONN_ACK) { |
567 | int wakeup = tipc_port_congested(p_ptr) && | 533 | int wakeup = tipc_port_congested(p_ptr) && |
568 | p_ptr->publ.congested && | 534 | p_ptr->congested && |
569 | p_ptr->wakeup; | 535 | p_ptr->wakeup; |
570 | p_ptr->acked += msg_msgcnt(msg); | 536 | p_ptr->acked += msg_msgcnt(msg); |
571 | if (tipc_port_congested(p_ptr)) | 537 | if (tipc_port_congested(p_ptr)) |
572 | goto exit; | 538 | goto exit; |
573 | p_ptr->publ.congested = 0; | 539 | p_ptr->congested = 0; |
574 | if (!wakeup) | 540 | if (!wakeup) |
575 | goto exit; | 541 | goto exit; |
576 | p_ptr->wakeup(&p_ptr->publ); | 542 | p_ptr->wakeup(p_ptr); |
577 | goto exit; | 543 | goto exit; |
578 | } | 544 | } |
579 | } else if (p_ptr->publ.published) { | 545 | } else if (p_ptr->published) { |
580 | err = TIPC_ERR_NO_PORT; | 546 | err = TIPC_ERR_NO_PORT; |
581 | } | 547 | } |
582 | if (err) { | 548 | if (err) { |
@@ -587,7 +553,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) | |||
587 | TIPC_HIGH_IMPORTANCE, | 553 | TIPC_HIGH_IMPORTANCE, |
588 | TIPC_CONN_MSG, | 554 | TIPC_CONN_MSG, |
589 | err, | 555 | err, |
590 | 0, | ||
591 | 0); | 556 | 0); |
592 | goto exit; | 557 | goto exit; |
593 | } | 558 | } |
@@ -601,11 +566,9 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) | |||
601 | CONN_MANAGER, | 566 | CONN_MANAGER, |
602 | CONN_PROBE_REPLY, | 567 | CONN_PROBE_REPLY, |
603 | TIPC_OK, | 568 | TIPC_OK, |
604 | port_out_seqno(p_ptr), | ||
605 | 0); | 569 | 0); |
606 | } | 570 | } |
607 | p_ptr->probing_state = CONFIRMED; | 571 | p_ptr->probing_state = CONFIRMED; |
608 | port_incr_out_seqno(p_ptr); | ||
609 | exit: | 572 | exit: |
610 | if (p_ptr) | 573 | if (p_ptr) |
611 | tipc_port_unlock(p_ptr); | 574 | tipc_port_unlock(p_ptr); |
@@ -614,30 +577,29 @@ exit: | |||
614 | buf_discard(buf); | 577 | buf_discard(buf); |
615 | } | 578 | } |
616 | 579 | ||
617 | static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id) | 580 | static void port_print(struct tipc_port *p_ptr, struct print_buf *buf, int full_id) |
618 | { | 581 | { |
619 | struct publication *publ; | 582 | struct publication *publ; |
620 | 583 | ||
621 | if (full_id) | 584 | if (full_id) |
622 | tipc_printf(buf, "<%u.%u.%u:%u>:", | 585 | tipc_printf(buf, "<%u.%u.%u:%u>:", |
623 | tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), | 586 | tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), |
624 | tipc_node(tipc_own_addr), p_ptr->publ.ref); | 587 | tipc_node(tipc_own_addr), p_ptr->ref); |
625 | else | 588 | else |
626 | tipc_printf(buf, "%-10u:", p_ptr->publ.ref); | 589 | tipc_printf(buf, "%-10u:", p_ptr->ref); |
627 | 590 | ||
628 | if (p_ptr->publ.connected) { | 591 | if (p_ptr->connected) { |
629 | u32 dport = port_peerport(p_ptr); | 592 | u32 dport = port_peerport(p_ptr); |
630 | u32 destnode = port_peernode(p_ptr); | 593 | u32 destnode = port_peernode(p_ptr); |
631 | 594 | ||
632 | tipc_printf(buf, " connected to <%u.%u.%u:%u>", | 595 | tipc_printf(buf, " connected to <%u.%u.%u:%u>", |
633 | tipc_zone(destnode), tipc_cluster(destnode), | 596 | tipc_zone(destnode), tipc_cluster(destnode), |
634 | tipc_node(destnode), dport); | 597 | tipc_node(destnode), dport); |
635 | if (p_ptr->publ.conn_type != 0) | 598 | if (p_ptr->conn_type != 0) |
636 | tipc_printf(buf, " via {%u,%u}", | 599 | tipc_printf(buf, " via {%u,%u}", |
637 | p_ptr->publ.conn_type, | 600 | p_ptr->conn_type, |
638 | p_ptr->publ.conn_instance); | 601 | p_ptr->conn_instance); |
639 | } | 602 | } else if (p_ptr->published) { |
640 | else if (p_ptr->publ.published) { | ||
641 | tipc_printf(buf, " bound to"); | 603 | tipc_printf(buf, " bound to"); |
642 | list_for_each_entry(publ, &p_ptr->publications, pport_list) { | 604 | list_for_each_entry(publ, &p_ptr->publications, pport_list) { |
643 | if (publ->lower == publ->upper) | 605 | if (publ->lower == publ->upper) |
@@ -658,7 +620,7 @@ struct sk_buff *tipc_port_get_ports(void) | |||
658 | struct sk_buff *buf; | 620 | struct sk_buff *buf; |
659 | struct tlv_desc *rep_tlv; | 621 | struct tlv_desc *rep_tlv; |
660 | struct print_buf pb; | 622 | struct print_buf pb; |
661 | struct port *p_ptr; | 623 | struct tipc_port *p_ptr; |
662 | int str_len; | 624 | int str_len; |
663 | 625 | ||
664 | buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY)); | 626 | buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY)); |
@@ -669,9 +631,9 @@ struct sk_buff *tipc_port_get_ports(void) | |||
669 | tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY); | 631 | tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY); |
670 | spin_lock_bh(&tipc_port_list_lock); | 632 | spin_lock_bh(&tipc_port_list_lock); |
671 | list_for_each_entry(p_ptr, &ports, port_list) { | 633 | list_for_each_entry(p_ptr, &ports, port_list) { |
672 | spin_lock_bh(p_ptr->publ.lock); | 634 | spin_lock_bh(p_ptr->lock); |
673 | port_print(p_ptr, &pb, 0); | 635 | port_print(p_ptr, &pb, 0); |
674 | spin_unlock_bh(p_ptr->publ.lock); | 636 | spin_unlock_bh(p_ptr->lock); |
675 | } | 637 | } |
676 | spin_unlock_bh(&tipc_port_list_lock); | 638 | spin_unlock_bh(&tipc_port_list_lock); |
677 | str_len = tipc_printbuf_validate(&pb); | 639 | str_len = tipc_printbuf_validate(&pb); |
@@ -684,12 +646,12 @@ struct sk_buff *tipc_port_get_ports(void) | |||
684 | 646 | ||
685 | void tipc_port_reinit(void) | 647 | void tipc_port_reinit(void) |
686 | { | 648 | { |
687 | struct port *p_ptr; | 649 | struct tipc_port *p_ptr; |
688 | struct tipc_msg *msg; | 650 | struct tipc_msg *msg; |
689 | 651 | ||
690 | spin_lock_bh(&tipc_port_list_lock); | 652 | spin_lock_bh(&tipc_port_list_lock); |
691 | list_for_each_entry(p_ptr, &ports, port_list) { | 653 | list_for_each_entry(p_ptr, &ports, port_list) { |
692 | msg = &p_ptr->publ.phdr; | 654 | msg = &p_ptr->phdr; |
693 | if (msg_orignode(msg) == tipc_own_addr) | 655 | if (msg_orignode(msg) == tipc_own_addr) |
694 | break; | 656 | break; |
695 | msg_set_prevnode(msg, tipc_own_addr); | 657 | msg_set_prevnode(msg, tipc_own_addr); |
@@ -714,7 +676,7 @@ static void port_dispatcher_sigh(void *dummy) | |||
714 | spin_unlock_bh(&queue_lock); | 676 | spin_unlock_bh(&queue_lock); |
715 | 677 | ||
716 | while (buf) { | 678 | while (buf) { |
717 | struct port *p_ptr; | 679 | struct tipc_port *p_ptr; |
718 | struct user_port *up_ptr; | 680 | struct user_port *up_ptr; |
719 | struct tipc_portid orig; | 681 | struct tipc_portid orig; |
720 | struct tipc_name_seq dseq; | 682 | struct tipc_name_seq dseq; |
@@ -739,8 +701,8 @@ static void port_dispatcher_sigh(void *dummy) | |||
739 | orig.node = msg_orignode(msg); | 701 | orig.node = msg_orignode(msg); |
740 | up_ptr = p_ptr->user_port; | 702 | up_ptr = p_ptr->user_port; |
741 | usr_handle = up_ptr->usr_handle; | 703 | usr_handle = up_ptr->usr_handle; |
742 | connected = p_ptr->publ.connected; | 704 | connected = p_ptr->connected; |
743 | published = p_ptr->publ.published; | 705 | published = p_ptr->published; |
744 | 706 | ||
745 | if (unlikely(msg_errcode(msg))) | 707 | if (unlikely(msg_errcode(msg))) |
746 | goto err; | 708 | goto err; |
@@ -751,6 +713,7 @@ static void port_dispatcher_sigh(void *dummy) | |||
751 | tipc_conn_msg_event cb = up_ptr->conn_msg_cb; | 713 | tipc_conn_msg_event cb = up_ptr->conn_msg_cb; |
752 | u32 peer_port = port_peerport(p_ptr); | 714 | u32 peer_port = port_peerport(p_ptr); |
753 | u32 peer_node = port_peernode(p_ptr); | 715 | u32 peer_node = port_peernode(p_ptr); |
716 | u32 dsz; | ||
754 | 717 | ||
755 | tipc_port_unlock(p_ptr); | 718 | tipc_port_unlock(p_ptr); |
756 | if (unlikely(!cb)) | 719 | if (unlikely(!cb)) |
@@ -761,13 +724,14 @@ static void port_dispatcher_sigh(void *dummy) | |||
761 | } else if ((msg_origport(msg) != peer_port) || | 724 | } else if ((msg_origport(msg) != peer_port) || |
762 | (msg_orignode(msg) != peer_node)) | 725 | (msg_orignode(msg) != peer_node)) |
763 | goto reject; | 726 | goto reject; |
764 | if (unlikely(++p_ptr->publ.conn_unacked >= | 727 | dsz = msg_data_sz(msg); |
765 | TIPC_FLOW_CONTROL_WIN)) | 728 | if (unlikely(dsz && |
729 | (++p_ptr->conn_unacked >= | ||
730 | TIPC_FLOW_CONTROL_WIN))) | ||
766 | tipc_acknowledge(dref, | 731 | tipc_acknowledge(dref, |
767 | p_ptr->publ.conn_unacked); | 732 | p_ptr->conn_unacked); |
768 | skb_pull(buf, msg_hdr_sz(msg)); | 733 | skb_pull(buf, msg_hdr_sz(msg)); |
769 | cb(usr_handle, dref, &buf, msg_data(msg), | 734 | cb(usr_handle, dref, &buf, msg_data(msg), dsz); |
770 | msg_data_sz(msg)); | ||
771 | break; | 735 | break; |
772 | } | 736 | } |
773 | case TIPC_DIRECT_MSG:{ | 737 | case TIPC_DIRECT_MSG:{ |
@@ -891,7 +855,7 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf) | |||
891 | 855 | ||
892 | static void port_wakeup_sh(unsigned long ref) | 856 | static void port_wakeup_sh(unsigned long ref) |
893 | { | 857 | { |
894 | struct port *p_ptr; | 858 | struct tipc_port *p_ptr; |
895 | struct user_port *up_ptr; | 859 | struct user_port *up_ptr; |
896 | tipc_continue_event cb = NULL; | 860 | tipc_continue_event cb = NULL; |
897 | void *uh = NULL; | 861 | void *uh = NULL; |
@@ -917,14 +881,14 @@ static void port_wakeup(struct tipc_port *p_ptr) | |||
917 | 881 | ||
918 | void tipc_acknowledge(u32 ref, u32 ack) | 882 | void tipc_acknowledge(u32 ref, u32 ack) |
919 | { | 883 | { |
920 | struct port *p_ptr; | 884 | struct tipc_port *p_ptr; |
921 | struct sk_buff *buf = NULL; | 885 | struct sk_buff *buf = NULL; |
922 | 886 | ||
923 | p_ptr = tipc_port_lock(ref); | 887 | p_ptr = tipc_port_lock(ref); |
924 | if (!p_ptr) | 888 | if (!p_ptr) |
925 | return; | 889 | return; |
926 | if (p_ptr->publ.connected) { | 890 | if (p_ptr->connected) { |
927 | p_ptr->publ.conn_unacked -= ack; | 891 | p_ptr->conn_unacked -= ack; |
928 | buf = port_build_proto_msg(port_peerport(p_ptr), | 892 | buf = port_build_proto_msg(port_peerport(p_ptr), |
929 | port_peernode(p_ptr), | 893 | port_peernode(p_ptr), |
930 | ref, | 894 | ref, |
@@ -932,7 +896,6 @@ void tipc_acknowledge(u32 ref, u32 ack) | |||
932 | CONN_MANAGER, | 896 | CONN_MANAGER, |
933 | CONN_ACK, | 897 | CONN_ACK, |
934 | TIPC_OK, | 898 | TIPC_OK, |
935 | port_out_seqno(p_ptr), | ||
936 | ack); | 899 | ack); |
937 | } | 900 | } |
938 | tipc_port_unlock(p_ptr); | 901 | tipc_port_unlock(p_ptr); |
@@ -940,12 +903,10 @@ void tipc_acknowledge(u32 ref, u32 ack) | |||
940 | } | 903 | } |
941 | 904 | ||
942 | /* | 905 | /* |
943 | * tipc_createport(): user level call. Will add port to | 906 | * tipc_createport(): user level call. |
944 | * registry if non-zero user_ref. | ||
945 | */ | 907 | */ |
946 | 908 | ||
947 | int tipc_createport(u32 user_ref, | 909 | int tipc_createport(void *usr_handle, |
948 | void *usr_handle, | ||
949 | unsigned int importance, | 910 | unsigned int importance, |
950 | tipc_msg_err_event error_cb, | 911 | tipc_msg_err_event error_cb, |
951 | tipc_named_msg_err_event named_error_cb, | 912 | tipc_named_msg_err_event named_error_cb, |
@@ -957,14 +918,14 @@ int tipc_createport(u32 user_ref, | |||
957 | u32 *portref) | 918 | u32 *portref) |
958 | { | 919 | { |
959 | struct user_port *up_ptr; | 920 | struct user_port *up_ptr; |
960 | struct port *p_ptr; | 921 | struct tipc_port *p_ptr; |
961 | 922 | ||
962 | up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); | 923 | up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); |
963 | if (!up_ptr) { | 924 | if (!up_ptr) { |
964 | warn("Port creation failed, no memory\n"); | 925 | warn("Port creation failed, no memory\n"); |
965 | return -ENOMEM; | 926 | return -ENOMEM; |
966 | } | 927 | } |
967 | p_ptr = (struct port *)tipc_createport_raw(NULL, port_dispatcher, | 928 | p_ptr = (struct tipc_port *)tipc_createport_raw(NULL, port_dispatcher, |
968 | port_wakeup, importance); | 929 | port_wakeup, importance); |
969 | if (!p_ptr) { | 930 | if (!p_ptr) { |
970 | kfree(up_ptr); | 931 | kfree(up_ptr); |
@@ -972,9 +933,8 @@ int tipc_createport(u32 user_ref, | |||
972 | } | 933 | } |
973 | 934 | ||
974 | p_ptr->user_port = up_ptr; | 935 | p_ptr->user_port = up_ptr; |
975 | up_ptr->user_ref = user_ref; | ||
976 | up_ptr->usr_handle = usr_handle; | 936 | up_ptr->usr_handle = usr_handle; |
977 | up_ptr->ref = p_ptr->publ.ref; | 937 | up_ptr->ref = p_ptr->ref; |
978 | up_ptr->err_cb = error_cb; | 938 | up_ptr->err_cb = error_cb; |
979 | up_ptr->named_err_cb = named_error_cb; | 939 | up_ptr->named_err_cb = named_error_cb; |
980 | up_ptr->conn_err_cb = conn_error_cb; | 940 | up_ptr->conn_err_cb = conn_error_cb; |
@@ -982,35 +942,26 @@ int tipc_createport(u32 user_ref, | |||
982 | up_ptr->named_msg_cb = named_msg_cb; | 942 | up_ptr->named_msg_cb = named_msg_cb; |
983 | up_ptr->conn_msg_cb = conn_msg_cb; | 943 | up_ptr->conn_msg_cb = conn_msg_cb; |
984 | up_ptr->continue_event_cb = continue_event_cb; | 944 | up_ptr->continue_event_cb = continue_event_cb; |
985 | INIT_LIST_HEAD(&up_ptr->uport_list); | 945 | *portref = p_ptr->ref; |
986 | tipc_reg_add_port(up_ptr); | ||
987 | *portref = p_ptr->publ.ref; | ||
988 | tipc_port_unlock(p_ptr); | 946 | tipc_port_unlock(p_ptr); |
989 | return 0; | 947 | return 0; |
990 | } | 948 | } |
991 | 949 | ||
992 | int tipc_ownidentity(u32 ref, struct tipc_portid *id) | ||
993 | { | ||
994 | id->ref = ref; | ||
995 | id->node = tipc_own_addr; | ||
996 | return 0; | ||
997 | } | ||
998 | |||
999 | int tipc_portimportance(u32 ref, unsigned int *importance) | 950 | int tipc_portimportance(u32 ref, unsigned int *importance) |
1000 | { | 951 | { |
1001 | struct port *p_ptr; | 952 | struct tipc_port *p_ptr; |
1002 | 953 | ||
1003 | p_ptr = tipc_port_lock(ref); | 954 | p_ptr = tipc_port_lock(ref); |
1004 | if (!p_ptr) | 955 | if (!p_ptr) |
1005 | return -EINVAL; | 956 | return -EINVAL; |
1006 | *importance = (unsigned int)msg_importance(&p_ptr->publ.phdr); | 957 | *importance = (unsigned int)msg_importance(&p_ptr->phdr); |
1007 | tipc_port_unlock(p_ptr); | 958 | tipc_port_unlock(p_ptr); |
1008 | return 0; | 959 | return 0; |
1009 | } | 960 | } |
1010 | 961 | ||
1011 | int tipc_set_portimportance(u32 ref, unsigned int imp) | 962 | int tipc_set_portimportance(u32 ref, unsigned int imp) |
1012 | { | 963 | { |
1013 | struct port *p_ptr; | 964 | struct tipc_port *p_ptr; |
1014 | 965 | ||
1015 | if (imp > TIPC_CRITICAL_IMPORTANCE) | 966 | if (imp > TIPC_CRITICAL_IMPORTANCE) |
1016 | return -EINVAL; | 967 | return -EINVAL; |
@@ -1018,7 +969,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp) | |||
1018 | p_ptr = tipc_port_lock(ref); | 969 | p_ptr = tipc_port_lock(ref); |
1019 | if (!p_ptr) | 970 | if (!p_ptr) |
1020 | return -EINVAL; | 971 | return -EINVAL; |
1021 | msg_set_importance(&p_ptr->publ.phdr, (u32)imp); | 972 | msg_set_importance(&p_ptr->phdr, (u32)imp); |
1022 | tipc_port_unlock(p_ptr); | 973 | tipc_port_unlock(p_ptr); |
1023 | return 0; | 974 | return 0; |
1024 | } | 975 | } |
@@ -1026,7 +977,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp) | |||
1026 | 977 | ||
1027 | int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | 978 | int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) |
1028 | { | 979 | { |
1029 | struct port *p_ptr; | 980 | struct tipc_port *p_ptr; |
1030 | struct publication *publ; | 981 | struct publication *publ; |
1031 | u32 key; | 982 | u32 key; |
1032 | int res = -EINVAL; | 983 | int res = -EINVAL; |
@@ -1035,10 +986,7 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | |||
1035 | if (!p_ptr) | 986 | if (!p_ptr) |
1036 | return -EINVAL; | 987 | return -EINVAL; |
1037 | 988 | ||
1038 | dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, " | 989 | if (p_ptr->connected) |
1039 | "lower = %u, upper = %u\n", | ||
1040 | ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper); | ||
1041 | if (p_ptr->publ.connected) | ||
1042 | goto exit; | 990 | goto exit; |
1043 | if (seq->lower > seq->upper) | 991 | if (seq->lower > seq->upper) |
1044 | goto exit; | 992 | goto exit; |
@@ -1050,11 +998,11 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | |||
1050 | goto exit; | 998 | goto exit; |
1051 | } | 999 | } |
1052 | publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, | 1000 | publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, |
1053 | scope, p_ptr->publ.ref, key); | 1001 | scope, p_ptr->ref, key); |
1054 | if (publ) { | 1002 | if (publ) { |
1055 | list_add(&publ->pport_list, &p_ptr->publications); | 1003 | list_add(&publ->pport_list, &p_ptr->publications); |
1056 | p_ptr->pub_count++; | 1004 | p_ptr->pub_count++; |
1057 | p_ptr->publ.published = 1; | 1005 | p_ptr->published = 1; |
1058 | res = 0; | 1006 | res = 0; |
1059 | } | 1007 | } |
1060 | exit: | 1008 | exit: |
@@ -1064,7 +1012,7 @@ exit: | |||
1064 | 1012 | ||
1065 | int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | 1013 | int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) |
1066 | { | 1014 | { |
1067 | struct port *p_ptr; | 1015 | struct tipc_port *p_ptr; |
1068 | struct publication *publ; | 1016 | struct publication *publ; |
1069 | struct publication *tpubl; | 1017 | struct publication *tpubl; |
1070 | int res = -EINVAL; | 1018 | int res = -EINVAL; |
@@ -1097,49 +1045,46 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | |||
1097 | } | 1045 | } |
1098 | } | 1046 | } |
1099 | if (list_empty(&p_ptr->publications)) | 1047 | if (list_empty(&p_ptr->publications)) |
1100 | p_ptr->publ.published = 0; | 1048 | p_ptr->published = 0; |
1101 | tipc_port_unlock(p_ptr); | 1049 | tipc_port_unlock(p_ptr); |
1102 | return res; | 1050 | return res; |
1103 | } | 1051 | } |
1104 | 1052 | ||
1105 | int tipc_connect2port(u32 ref, struct tipc_portid const *peer) | 1053 | int tipc_connect2port(u32 ref, struct tipc_portid const *peer) |
1106 | { | 1054 | { |
1107 | struct port *p_ptr; | 1055 | struct tipc_port *p_ptr; |
1108 | struct tipc_msg *msg; | 1056 | struct tipc_msg *msg; |
1109 | int res = -EINVAL; | 1057 | int res = -EINVAL; |
1110 | 1058 | ||
1111 | p_ptr = tipc_port_lock(ref); | 1059 | p_ptr = tipc_port_lock(ref); |
1112 | if (!p_ptr) | 1060 | if (!p_ptr) |
1113 | return -EINVAL; | 1061 | return -EINVAL; |
1114 | if (p_ptr->publ.published || p_ptr->publ.connected) | 1062 | if (p_ptr->published || p_ptr->connected) |
1115 | goto exit; | 1063 | goto exit; |
1116 | if (!peer->ref) | 1064 | if (!peer->ref) |
1117 | goto exit; | 1065 | goto exit; |
1118 | 1066 | ||
1119 | msg = &p_ptr->publ.phdr; | 1067 | msg = &p_ptr->phdr; |
1120 | msg_set_destnode(msg, peer->node); | 1068 | msg_set_destnode(msg, peer->node); |
1121 | msg_set_destport(msg, peer->ref); | 1069 | msg_set_destport(msg, peer->ref); |
1122 | msg_set_orignode(msg, tipc_own_addr); | 1070 | msg_set_orignode(msg, tipc_own_addr); |
1123 | msg_set_origport(msg, p_ptr->publ.ref); | 1071 | msg_set_origport(msg, p_ptr->ref); |
1124 | msg_set_transp_seqno(msg, 42); | ||
1125 | msg_set_type(msg, TIPC_CONN_MSG); | 1072 | msg_set_type(msg, TIPC_CONN_MSG); |
1126 | if (!may_route(peer->node)) | 1073 | msg_set_lookup_scope(msg, 0); |
1127 | msg_set_hdr_sz(msg, SHORT_H_SIZE); | 1074 | msg_set_hdr_sz(msg, SHORT_H_SIZE); |
1128 | else | ||
1129 | msg_set_hdr_sz(msg, LONG_H_SIZE); | ||
1130 | 1075 | ||
1131 | p_ptr->probing_interval = PROBING_INTERVAL; | 1076 | p_ptr->probing_interval = PROBING_INTERVAL; |
1132 | p_ptr->probing_state = CONFIRMED; | 1077 | p_ptr->probing_state = CONFIRMED; |
1133 | p_ptr->publ.connected = 1; | 1078 | p_ptr->connected = 1; |
1134 | k_start_timer(&p_ptr->timer, p_ptr->probing_interval); | 1079 | k_start_timer(&p_ptr->timer, p_ptr->probing_interval); |
1135 | 1080 | ||
1136 | tipc_nodesub_subscribe(&p_ptr->subscription,peer->node, | 1081 | tipc_nodesub_subscribe(&p_ptr->subscription, peer->node, |
1137 | (void *)(unsigned long)ref, | 1082 | (void *)(unsigned long)ref, |
1138 | (net_ev_handler)port_handle_node_down); | 1083 | (net_ev_handler)port_handle_node_down); |
1139 | res = 0; | 1084 | res = 0; |
1140 | exit: | 1085 | exit: |
1141 | tipc_port_unlock(p_ptr); | 1086 | tipc_port_unlock(p_ptr); |
1142 | p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref); | 1087 | p_ptr->max_pkt = tipc_link_get_max_pkt(peer->node, ref); |
1143 | return res; | 1088 | return res; |
1144 | } | 1089 | } |
1145 | 1090 | ||
@@ -1157,7 +1102,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr) | |||
1157 | tp_ptr->connected = 0; | 1102 | tp_ptr->connected = 0; |
1158 | /* let timer expire on it's own to avoid deadlock! */ | 1103 | /* let timer expire on it's own to avoid deadlock! */ |
1159 | tipc_nodesub_unsubscribe( | 1104 | tipc_nodesub_unsubscribe( |
1160 | &((struct port *)tp_ptr)->subscription); | 1105 | &((struct tipc_port *)tp_ptr)->subscription); |
1161 | res = 0; | 1106 | res = 0; |
1162 | } else { | 1107 | } else { |
1163 | res = -ENOTCONN; | 1108 | res = -ENOTCONN; |
@@ -1172,7 +1117,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr) | |||
1172 | 1117 | ||
1173 | int tipc_disconnect(u32 ref) | 1118 | int tipc_disconnect(u32 ref) |
1174 | { | 1119 | { |
1175 | struct port *p_ptr; | 1120 | struct tipc_port *p_ptr; |
1176 | int res; | 1121 | int res; |
1177 | 1122 | ||
1178 | p_ptr = tipc_port_lock(ref); | 1123 | p_ptr = tipc_port_lock(ref); |
@@ -1188,15 +1133,15 @@ int tipc_disconnect(u32 ref) | |||
1188 | */ | 1133 | */ |
1189 | int tipc_shutdown(u32 ref) | 1134 | int tipc_shutdown(u32 ref) |
1190 | { | 1135 | { |
1191 | struct port *p_ptr; | 1136 | struct tipc_port *p_ptr; |
1192 | struct sk_buff *buf = NULL; | 1137 | struct sk_buff *buf = NULL; |
1193 | 1138 | ||
1194 | p_ptr = tipc_port_lock(ref); | 1139 | p_ptr = tipc_port_lock(ref); |
1195 | if (!p_ptr) | 1140 | if (!p_ptr) |
1196 | return -EINVAL; | 1141 | return -EINVAL; |
1197 | 1142 | ||
1198 | if (p_ptr->publ.connected) { | 1143 | if (p_ptr->connected) { |
1199 | u32 imp = msg_importance(&p_ptr->publ.phdr); | 1144 | u32 imp = msg_importance(&p_ptr->phdr); |
1200 | if (imp < TIPC_CRITICAL_IMPORTANCE) | 1145 | if (imp < TIPC_CRITICAL_IMPORTANCE) |
1201 | imp++; | 1146 | imp++; |
1202 | buf = port_build_proto_msg(port_peerport(p_ptr), | 1147 | buf = port_build_proto_msg(port_peerport(p_ptr), |
@@ -1206,7 +1151,6 @@ int tipc_shutdown(u32 ref) | |||
1206 | imp, | 1151 | imp, |
1207 | TIPC_CONN_MSG, | 1152 | TIPC_CONN_MSG, |
1208 | TIPC_CONN_SHUTDOWN, | 1153 | TIPC_CONN_SHUTDOWN, |
1209 | port_out_seqno(p_ptr), | ||
1210 | 0); | 1154 | 0); |
1211 | } | 1155 | } |
1212 | tipc_port_unlock(p_ptr); | 1156 | tipc_port_unlock(p_ptr); |
@@ -1219,13 +1163,14 @@ int tipc_shutdown(u32 ref) | |||
1219 | * message for this node. | 1163 | * message for this node. |
1220 | */ | 1164 | */ |
1221 | 1165 | ||
1222 | static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, | 1166 | static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect, |
1223 | struct iovec const *msg_sect) | 1167 | struct iovec const *msg_sect, |
1168 | unsigned int total_len) | ||
1224 | { | 1169 | { |
1225 | struct sk_buff *buf; | 1170 | struct sk_buff *buf; |
1226 | int res; | 1171 | int res; |
1227 | 1172 | ||
1228 | res = tipc_msg_build(&sender->publ.phdr, msg_sect, num_sect, | 1173 | res = tipc_msg_build(&sender->phdr, msg_sect, num_sect, total_len, |
1229 | MAX_MSG_SIZE, !sender->user_port, &buf); | 1174 | MAX_MSG_SIZE, !sender->user_port, &buf); |
1230 | if (likely(buf)) | 1175 | if (likely(buf)) |
1231 | tipc_port_recv_msg(buf); | 1176 | tipc_port_recv_msg(buf); |
@@ -1236,229 +1181,175 @@ static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, | |||
1236 | * tipc_send - send message sections on connection | 1181 | * tipc_send - send message sections on connection |
1237 | */ | 1182 | */ |
1238 | 1183 | ||
1239 | int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) | 1184 | int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect, |
1185 | unsigned int total_len) | ||
1240 | { | 1186 | { |
1241 | struct port *p_ptr; | 1187 | struct tipc_port *p_ptr; |
1242 | u32 destnode; | 1188 | u32 destnode; |
1243 | int res; | 1189 | int res; |
1244 | 1190 | ||
1245 | p_ptr = tipc_port_deref(ref); | 1191 | p_ptr = tipc_port_deref(ref); |
1246 | if (!p_ptr || !p_ptr->publ.connected) | 1192 | if (!p_ptr || !p_ptr->connected) |
1247 | return -EINVAL; | 1193 | return -EINVAL; |
1248 | 1194 | ||
1249 | p_ptr->publ.congested = 1; | 1195 | p_ptr->congested = 1; |
1250 | if (!tipc_port_congested(p_ptr)) { | 1196 | if (!tipc_port_congested(p_ptr)) { |
1251 | destnode = port_peernode(p_ptr); | 1197 | destnode = port_peernode(p_ptr); |
1252 | if (likely(destnode != tipc_own_addr)) | 1198 | if (likely(destnode != tipc_own_addr)) |
1253 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 1199 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, |
1254 | destnode); | 1200 | total_len, destnode); |
1255 | else | 1201 | else |
1256 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect); | 1202 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, |
1203 | total_len); | ||
1257 | 1204 | ||
1258 | if (likely(res != -ELINKCONG)) { | 1205 | if (likely(res != -ELINKCONG)) { |
1259 | port_incr_out_seqno(p_ptr); | 1206 | p_ptr->congested = 0; |
1260 | p_ptr->publ.congested = 0; | 1207 | if (res > 0) |
1261 | p_ptr->sent++; | 1208 | p_ptr->sent++; |
1262 | return res; | 1209 | return res; |
1263 | } | 1210 | } |
1264 | } | 1211 | } |
1265 | if (port_unreliable(p_ptr)) { | 1212 | if (port_unreliable(p_ptr)) { |
1266 | p_ptr->publ.congested = 0; | 1213 | p_ptr->congested = 0; |
1267 | /* Just calculate msg length and return */ | 1214 | return total_len; |
1268 | return tipc_msg_calc_data_size(msg_sect, num_sect); | ||
1269 | } | 1215 | } |
1270 | return -ELINKCONG; | 1216 | return -ELINKCONG; |
1271 | } | 1217 | } |
1272 | 1218 | ||
1273 | /** | 1219 | /** |
1274 | * tipc_forward2name - forward message sections to port name | 1220 | * tipc_send2name - send message sections to port name |
1275 | */ | 1221 | */ |
1276 | 1222 | ||
1277 | static int tipc_forward2name(u32 ref, | 1223 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, |
1278 | struct tipc_name const *name, | 1224 | unsigned int num_sect, struct iovec const *msg_sect, |
1279 | u32 domain, | 1225 | unsigned int total_len) |
1280 | u32 num_sect, | ||
1281 | struct iovec const *msg_sect, | ||
1282 | struct tipc_portid const *orig, | ||
1283 | unsigned int importance) | ||
1284 | { | 1226 | { |
1285 | struct port *p_ptr; | 1227 | struct tipc_port *p_ptr; |
1286 | struct tipc_msg *msg; | 1228 | struct tipc_msg *msg; |
1287 | u32 destnode = domain; | 1229 | u32 destnode = domain; |
1288 | u32 destport; | 1230 | u32 destport; |
1289 | int res; | 1231 | int res; |
1290 | 1232 | ||
1291 | p_ptr = tipc_port_deref(ref); | 1233 | p_ptr = tipc_port_deref(ref); |
1292 | if (!p_ptr || p_ptr->publ.connected) | 1234 | if (!p_ptr || p_ptr->connected) |
1293 | return -EINVAL; | 1235 | return -EINVAL; |
1294 | 1236 | ||
1295 | msg = &p_ptr->publ.phdr; | 1237 | msg = &p_ptr->phdr; |
1296 | msg_set_type(msg, TIPC_NAMED_MSG); | 1238 | msg_set_type(msg, TIPC_NAMED_MSG); |
1297 | msg_set_orignode(msg, orig->node); | 1239 | msg_set_orignode(msg, tipc_own_addr); |
1298 | msg_set_origport(msg, orig->ref); | 1240 | msg_set_origport(msg, ref); |
1299 | msg_set_hdr_sz(msg, LONG_H_SIZE); | 1241 | msg_set_hdr_sz(msg, LONG_H_SIZE); |
1300 | msg_set_nametype(msg, name->type); | 1242 | msg_set_nametype(msg, name->type); |
1301 | msg_set_nameinst(msg, name->instance); | 1243 | msg_set_nameinst(msg, name->instance); |
1302 | msg_set_lookup_scope(msg, tipc_addr_scope(domain)); | 1244 | msg_set_lookup_scope(msg, tipc_addr_scope(domain)); |
1303 | if (importance <= TIPC_CRITICAL_IMPORTANCE) | ||
1304 | msg_set_importance(msg,importance); | ||
1305 | destport = tipc_nametbl_translate(name->type, name->instance, &destnode); | 1245 | destport = tipc_nametbl_translate(name->type, name->instance, &destnode); |
1306 | msg_set_destnode(msg, destnode); | 1246 | msg_set_destnode(msg, destnode); |
1307 | msg_set_destport(msg, destport); | 1247 | msg_set_destport(msg, destport); |
1308 | 1248 | ||
1309 | if (likely(destport)) { | 1249 | if (likely(destport)) { |
1310 | p_ptr->sent++; | ||
1311 | if (likely(destnode == tipc_own_addr)) | 1250 | if (likely(destnode == tipc_own_addr)) |
1312 | return tipc_port_recv_sections(p_ptr, num_sect, msg_sect); | 1251 | res = tipc_port_recv_sections(p_ptr, num_sect, |
1313 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | 1252 | msg_sect, total_len); |
1314 | destnode); | 1253 | else |
1315 | if (likely(res != -ELINKCONG)) | 1254 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, |
1255 | num_sect, total_len, | ||
1256 | destnode); | ||
1257 | if (likely(res != -ELINKCONG)) { | ||
1258 | if (res > 0) | ||
1259 | p_ptr->sent++; | ||
1316 | return res; | 1260 | return res; |
1261 | } | ||
1317 | if (port_unreliable(p_ptr)) { | 1262 | if (port_unreliable(p_ptr)) { |
1318 | /* Just calculate msg length and return */ | 1263 | return total_len; |
1319 | return tipc_msg_calc_data_size(msg_sect, num_sect); | ||
1320 | } | 1264 | } |
1321 | return -ELINKCONG; | 1265 | return -ELINKCONG; |
1322 | } | 1266 | } |
1323 | return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, | 1267 | return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, |
1324 | TIPC_ERR_NO_NAME); | 1268 | total_len, TIPC_ERR_NO_NAME); |
1325 | } | 1269 | } |
1326 | 1270 | ||
1327 | /** | 1271 | /** |
1328 | * tipc_send2name - send message sections to port name | 1272 | * tipc_send2port - send message sections to port identity |
1329 | */ | ||
1330 | |||
1331 | int tipc_send2name(u32 ref, | ||
1332 | struct tipc_name const *name, | ||
1333 | unsigned int domain, | ||
1334 | unsigned int num_sect, | ||
1335 | struct iovec const *msg_sect) | ||
1336 | { | ||
1337 | struct tipc_portid orig; | ||
1338 | |||
1339 | orig.ref = ref; | ||
1340 | orig.node = tipc_own_addr; | ||
1341 | return tipc_forward2name(ref, name, domain, num_sect, msg_sect, &orig, | ||
1342 | TIPC_PORT_IMPORTANCE); | ||
1343 | } | ||
1344 | |||
1345 | /** | ||
1346 | * tipc_forward2port - forward message sections to port identity | ||
1347 | */ | 1273 | */ |
1348 | 1274 | ||
1349 | static int tipc_forward2port(u32 ref, | 1275 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, |
1350 | struct tipc_portid const *dest, | 1276 | unsigned int num_sect, struct iovec const *msg_sect, |
1351 | unsigned int num_sect, | 1277 | unsigned int total_len) |
1352 | struct iovec const *msg_sect, | ||
1353 | struct tipc_portid const *orig, | ||
1354 | unsigned int importance) | ||
1355 | { | 1278 | { |
1356 | struct port *p_ptr; | 1279 | struct tipc_port *p_ptr; |
1357 | struct tipc_msg *msg; | 1280 | struct tipc_msg *msg; |
1358 | int res; | 1281 | int res; |
1359 | 1282 | ||
1360 | p_ptr = tipc_port_deref(ref); | 1283 | p_ptr = tipc_port_deref(ref); |
1361 | if (!p_ptr || p_ptr->publ.connected) | 1284 | if (!p_ptr || p_ptr->connected) |
1362 | return -EINVAL; | 1285 | return -EINVAL; |
1363 | 1286 | ||
1364 | msg = &p_ptr->publ.phdr; | 1287 | msg = &p_ptr->phdr; |
1365 | msg_set_type(msg, TIPC_DIRECT_MSG); | 1288 | msg_set_type(msg, TIPC_DIRECT_MSG); |
1366 | msg_set_orignode(msg, orig->node); | 1289 | msg_set_lookup_scope(msg, 0); |
1367 | msg_set_origport(msg, orig->ref); | 1290 | msg_set_orignode(msg, tipc_own_addr); |
1291 | msg_set_origport(msg, ref); | ||
1368 | msg_set_destnode(msg, dest->node); | 1292 | msg_set_destnode(msg, dest->node); |
1369 | msg_set_destport(msg, dest->ref); | 1293 | msg_set_destport(msg, dest->ref); |
1370 | msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); | 1294 | msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); |
1371 | if (importance <= TIPC_CRITICAL_IMPORTANCE) | 1295 | |
1372 | msg_set_importance(msg, importance); | ||
1373 | p_ptr->sent++; | ||
1374 | if (dest->node == tipc_own_addr) | 1296 | if (dest->node == tipc_own_addr) |
1375 | return tipc_port_recv_sections(p_ptr, num_sect, msg_sect); | 1297 | res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, |
1376 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, dest->node); | 1298 | total_len); |
1377 | if (likely(res != -ELINKCONG)) | 1299 | else |
1300 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, | ||
1301 | total_len, dest->node); | ||
1302 | if (likely(res != -ELINKCONG)) { | ||
1303 | if (res > 0) | ||
1304 | p_ptr->sent++; | ||
1378 | return res; | 1305 | return res; |
1306 | } | ||
1379 | if (port_unreliable(p_ptr)) { | 1307 | if (port_unreliable(p_ptr)) { |
1380 | /* Just calculate msg length and return */ | 1308 | return total_len; |
1381 | return tipc_msg_calc_data_size(msg_sect, num_sect); | ||
1382 | } | 1309 | } |
1383 | return -ELINKCONG; | 1310 | return -ELINKCONG; |
1384 | } | 1311 | } |
1385 | 1312 | ||
1386 | /** | 1313 | /** |
1387 | * tipc_send2port - send message sections to port identity | 1314 | * tipc_send_buf2port - send message buffer to port identity |
1388 | */ | 1315 | */ |
1389 | 1316 | ||
1390 | int tipc_send2port(u32 ref, | 1317 | int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, |
1391 | struct tipc_portid const *dest, | 1318 | struct sk_buff *buf, unsigned int dsz) |
1392 | unsigned int num_sect, | ||
1393 | struct iovec const *msg_sect) | ||
1394 | { | ||
1395 | struct tipc_portid orig; | ||
1396 | |||
1397 | orig.ref = ref; | ||
1398 | orig.node = tipc_own_addr; | ||
1399 | return tipc_forward2port(ref, dest, num_sect, msg_sect, &orig, | ||
1400 | TIPC_PORT_IMPORTANCE); | ||
1401 | } | ||
1402 | |||
1403 | /** | ||
1404 | * tipc_forward_buf2port - forward message buffer to port identity | ||
1405 | */ | ||
1406 | static int tipc_forward_buf2port(u32 ref, | ||
1407 | struct tipc_portid const *dest, | ||
1408 | struct sk_buff *buf, | ||
1409 | unsigned int dsz, | ||
1410 | struct tipc_portid const *orig, | ||
1411 | unsigned int importance) | ||
1412 | { | 1319 | { |
1413 | struct port *p_ptr; | 1320 | struct tipc_port *p_ptr; |
1414 | struct tipc_msg *msg; | 1321 | struct tipc_msg *msg; |
1415 | int res; | 1322 | int res; |
1416 | 1323 | ||
1417 | p_ptr = (struct port *)tipc_ref_deref(ref); | 1324 | p_ptr = (struct tipc_port *)tipc_ref_deref(ref); |
1418 | if (!p_ptr || p_ptr->publ.connected) | 1325 | if (!p_ptr || p_ptr->connected) |
1419 | return -EINVAL; | 1326 | return -EINVAL; |
1420 | 1327 | ||
1421 | msg = &p_ptr->publ.phdr; | 1328 | msg = &p_ptr->phdr; |
1422 | msg_set_type(msg, TIPC_DIRECT_MSG); | 1329 | msg_set_type(msg, TIPC_DIRECT_MSG); |
1423 | msg_set_orignode(msg, orig->node); | 1330 | msg_set_orignode(msg, tipc_own_addr); |
1424 | msg_set_origport(msg, orig->ref); | 1331 | msg_set_origport(msg, ref); |
1425 | msg_set_destnode(msg, dest->node); | 1332 | msg_set_destnode(msg, dest->node); |
1426 | msg_set_destport(msg, dest->ref); | 1333 | msg_set_destport(msg, dest->ref); |
1427 | msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); | 1334 | msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); |
1428 | if (importance <= TIPC_CRITICAL_IMPORTANCE) | ||
1429 | msg_set_importance(msg, importance); | ||
1430 | msg_set_size(msg, DIR_MSG_H_SIZE + dsz); | 1335 | msg_set_size(msg, DIR_MSG_H_SIZE + dsz); |
1431 | if (skb_cow(buf, DIR_MSG_H_SIZE)) | 1336 | if (skb_cow(buf, DIR_MSG_H_SIZE)) |
1432 | return -ENOMEM; | 1337 | return -ENOMEM; |
1433 | 1338 | ||
1434 | skb_push(buf, DIR_MSG_H_SIZE); | 1339 | skb_push(buf, DIR_MSG_H_SIZE); |
1435 | skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE); | 1340 | skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE); |
1436 | msg_dbg(msg, "buf2port: "); | 1341 | |
1437 | p_ptr->sent++; | ||
1438 | if (dest->node == tipc_own_addr) | 1342 | if (dest->node == tipc_own_addr) |
1439 | return tipc_port_recv_msg(buf); | 1343 | res = tipc_port_recv_msg(buf); |
1440 | res = tipc_send_buf_fast(buf, dest->node); | 1344 | else |
1441 | if (likely(res != -ELINKCONG)) | 1345 | res = tipc_send_buf_fast(buf, dest->node); |
1346 | if (likely(res != -ELINKCONG)) { | ||
1347 | if (res > 0) | ||
1348 | p_ptr->sent++; | ||
1442 | return res; | 1349 | return res; |
1350 | } | ||
1443 | if (port_unreliable(p_ptr)) | 1351 | if (port_unreliable(p_ptr)) |
1444 | return dsz; | 1352 | return dsz; |
1445 | return -ELINKCONG; | 1353 | return -ELINKCONG; |
1446 | } | 1354 | } |
1447 | 1355 | ||
1448 | /** | ||
1449 | * tipc_send_buf2port - send message buffer to port identity | ||
1450 | */ | ||
1451 | |||
1452 | int tipc_send_buf2port(u32 ref, | ||
1453 | struct tipc_portid const *dest, | ||
1454 | struct sk_buff *buf, | ||
1455 | unsigned int dsz) | ||
1456 | { | ||
1457 | struct tipc_portid orig; | ||
1458 | |||
1459 | orig.ref = ref; | ||
1460 | orig.node = tipc_own_addr; | ||
1461 | return tipc_forward_buf2port(ref, dest, buf, dsz, &orig, | ||
1462 | TIPC_PORT_IMPORTANCE); | ||
1463 | } | ||
1464 | |||