diff options
Diffstat (limited to 'net/tipc/port.c')
| -rw-r--r-- | net/tipc/port.c | 301 |
1 files changed, 97 insertions, 204 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c index b742b2654525..5c14c7801ee6 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 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, 2014, Ericsson AB |
| 5 | * Copyright (c) 2004-2008, 2010-2013, Wind River Systems | 5 | * Copyright (c) 2004-2008, 2010-2013, Wind River Systems |
| 6 | * All rights reserved. | 6 | * All rights reserved. |
| 7 | * | 7 | * |
| @@ -38,6 +38,7 @@ | |||
| 38 | #include "config.h" | 38 | #include "config.h" |
| 39 | #include "port.h" | 39 | #include "port.h" |
| 40 | #include "name_table.h" | 40 | #include "name_table.h" |
| 41 | #include "socket.h" | ||
| 41 | 42 | ||
| 42 | /* Connection management: */ | 43 | /* Connection management: */ |
| 43 | #define PROBING_INTERVAL 3600000 /* [ms] => 1 h */ | 44 | #define PROBING_INTERVAL 3600000 /* [ms] => 1 h */ |
| @@ -54,17 +55,6 @@ static struct sk_buff *port_build_self_abort_msg(struct tipc_port *, u32 err); | |||
| 54 | static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err); | 55 | static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err); |
| 55 | static void port_timeout(unsigned long ref); | 56 | static void port_timeout(unsigned long ref); |
| 56 | 57 | ||
| 57 | |||
| 58 | static u32 port_peernode(struct tipc_port *p_ptr) | ||
| 59 | { | ||
| 60 | return msg_destnode(&p_ptr->phdr); | ||
| 61 | } | ||
| 62 | |||
| 63 | static u32 port_peerport(struct tipc_port *p_ptr) | ||
| 64 | { | ||
| 65 | return msg_destport(&p_ptr->phdr); | ||
| 66 | } | ||
| 67 | |||
| 68 | /** | 58 | /** |
| 69 | * tipc_port_peer_msg - verify message was sent by connected port's peer | 59 | * tipc_port_peer_msg - verify message was sent by connected port's peer |
| 70 | * | 60 | * |
| @@ -76,33 +66,32 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg) | |||
| 76 | u32 peernode; | 66 | u32 peernode; |
| 77 | u32 orignode; | 67 | u32 orignode; |
| 78 | 68 | ||
| 79 | if (msg_origport(msg) != port_peerport(p_ptr)) | 69 | if (msg_origport(msg) != tipc_port_peerport(p_ptr)) |
| 80 | return 0; | 70 | return 0; |
| 81 | 71 | ||
| 82 | orignode = msg_orignode(msg); | 72 | orignode = msg_orignode(msg); |
| 83 | peernode = port_peernode(p_ptr); | 73 | peernode = tipc_port_peernode(p_ptr); |
| 84 | return (orignode == peernode) || | 74 | return (orignode == peernode) || |
| 85 | (!orignode && (peernode == tipc_own_addr)) || | 75 | (!orignode && (peernode == tipc_own_addr)) || |
| 86 | (!peernode && (orignode == tipc_own_addr)); | 76 | (!peernode && (orignode == tipc_own_addr)); |
| 87 | } | 77 | } |
| 88 | 78 | ||
| 89 | /** | 79 | /** |
| 90 | * tipc_multicast - send a multicast message to local and remote destinations | 80 | * tipc_port_mcast_xmit - send a multicast message to local and remote |
| 81 | * destinations | ||
| 91 | */ | 82 | */ |
| 92 | int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | 83 | int tipc_port_mcast_xmit(struct tipc_port *oport, |
| 93 | struct iovec const *msg_sect, unsigned int len) | 84 | struct tipc_name_seq const *seq, |
| 85 | struct iovec const *msg_sect, | ||
| 86 | unsigned int len) | ||
| 94 | { | 87 | { |
| 95 | struct tipc_msg *hdr; | 88 | struct tipc_msg *hdr; |
| 96 | struct sk_buff *buf; | 89 | struct sk_buff *buf; |
| 97 | struct sk_buff *ibuf = NULL; | 90 | struct sk_buff *ibuf = NULL; |
| 98 | struct tipc_port_list dports = {0, NULL, }; | 91 | struct tipc_port_list dports = {0, NULL, }; |
| 99 | struct tipc_port *oport = tipc_port_deref(ref); | ||
| 100 | int ext_targets; | 92 | int ext_targets; |
| 101 | int res; | 93 | int res; |
| 102 | 94 | ||
| 103 | if (unlikely(!oport)) | ||
| 104 | return -EINVAL; | ||
| 105 | |||
| 106 | /* Create multicast message */ | 95 | /* Create multicast message */ |
| 107 | hdr = &oport->phdr; | 96 | hdr = &oport->phdr; |
| 108 | msg_set_type(hdr, TIPC_MCAST_MSG); | 97 | msg_set_type(hdr, TIPC_MCAST_MSG); |
| @@ -131,7 +120,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
| 131 | return -ENOMEM; | 120 | return -ENOMEM; |
| 132 | } | 121 | } |
| 133 | } | 122 | } |
| 134 | res = tipc_bclink_send_msg(buf); | 123 | res = tipc_bclink_xmit(buf); |
| 135 | if ((res < 0) && (dports.count != 0)) | 124 | if ((res < 0) && (dports.count != 0)) |
| 136 | kfree_skb(ibuf); | 125 | kfree_skb(ibuf); |
| 137 | } else { | 126 | } else { |
| @@ -140,7 +129,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
| 140 | 129 | ||
| 141 | if (res >= 0) { | 130 | if (res >= 0) { |
| 142 | if (ibuf) | 131 | if (ibuf) |
| 143 | tipc_port_recv_mcast(ibuf, &dports); | 132 | tipc_port_mcast_rcv(ibuf, &dports); |
| 144 | } else { | 133 | } else { |
| 145 | tipc_port_list_free(&dports); | 134 | tipc_port_list_free(&dports); |
| 146 | } | 135 | } |
| @@ -148,11 +137,11 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, | |||
| 148 | } | 137 | } |
| 149 | 138 | ||
| 150 | /** | 139 | /** |
| 151 | * tipc_port_recv_mcast - deliver multicast message to all destination ports | 140 | * tipc_port_mcast_rcv - deliver multicast message to all destination ports |
| 152 | * | 141 | * |
| 153 | * If there is no port list, perform a lookup to create one | 142 | * If there is no port list, perform a lookup to create one |
| 154 | */ | 143 | */ |
| 155 | void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) | 144 | void tipc_port_mcast_rcv(struct sk_buff *buf, struct tipc_port_list *dp) |
| 156 | { | 145 | { |
| 157 | struct tipc_msg *msg; | 146 | struct tipc_msg *msg; |
| 158 | struct tipc_port_list dports = {0, NULL, }; | 147 | struct tipc_port_list dports = {0, NULL, }; |
| @@ -176,7 +165,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) | |||
| 176 | msg_set_destnode(msg, tipc_own_addr); | 165 | msg_set_destnode(msg, tipc_own_addr); |
| 177 | if (dp->count == 1) { | 166 | if (dp->count == 1) { |
| 178 | msg_set_destport(msg, dp->ports[0]); | 167 | msg_set_destport(msg, dp->ports[0]); |
| 179 | tipc_port_recv_msg(buf); | 168 | tipc_port_rcv(buf); |
| 180 | tipc_port_list_free(dp); | 169 | tipc_port_list_free(dp); |
| 181 | return; | 170 | return; |
| 182 | } | 171 | } |
| @@ -191,7 +180,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) | |||
| 191 | if ((index == 0) && (cnt != 0)) | 180 | if ((index == 0) && (cnt != 0)) |
| 192 | item = item->next; | 181 | item = item->next; |
| 193 | msg_set_destport(buf_msg(b), item->ports[index]); | 182 | msg_set_destport(buf_msg(b), item->ports[index]); |
| 194 | tipc_port_recv_msg(b); | 183 | tipc_port_rcv(b); |
| 195 | } | 184 | } |
| 196 | } | 185 | } |
| 197 | exit: | 186 | exit: |
| @@ -199,40 +188,32 @@ exit: | |||
| 199 | tipc_port_list_free(dp); | 188 | tipc_port_list_free(dp); |
| 200 | } | 189 | } |
| 201 | 190 | ||
| 202 | /** | 191 | |
| 203 | * tipc_createport - create a generic TIPC port | 192 | void tipc_port_wakeup(struct tipc_port *port) |
| 193 | { | ||
| 194 | tipc_sock_wakeup(tipc_port_to_sock(port)); | ||
| 195 | } | ||
| 196 | |||
| 197 | /* tipc_port_init - intiate TIPC port and lock it | ||
| 204 | * | 198 | * |
| 205 | * Returns pointer to (locked) TIPC port, or NULL if unable to create it | 199 | * Returns obtained reference if initialization is successful, zero otherwise |
| 206 | */ | 200 | */ |
| 207 | struct tipc_port *tipc_createport(struct sock *sk, | 201 | u32 tipc_port_init(struct tipc_port *p_ptr, |
| 208 | u32 (*dispatcher)(struct tipc_port *, | 202 | const unsigned int importance) |
| 209 | struct sk_buff *), | ||
| 210 | void (*wakeup)(struct tipc_port *), | ||
| 211 | const u32 importance) | ||
| 212 | { | 203 | { |
| 213 | struct tipc_port *p_ptr; | ||
| 214 | struct tipc_msg *msg; | 204 | struct tipc_msg *msg; |
| 215 | u32 ref; | 205 | u32 ref; |
| 216 | 206 | ||
| 217 | p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); | ||
| 218 | if (!p_ptr) { | ||
| 219 | pr_warn("Port creation failed, no memory\n"); | ||
| 220 | return NULL; | ||
| 221 | } | ||
| 222 | ref = tipc_ref_acquire(p_ptr, &p_ptr->lock); | 207 | ref = tipc_ref_acquire(p_ptr, &p_ptr->lock); |
| 223 | if (!ref) { | 208 | if (!ref) { |
| 224 | pr_warn("Port creation failed, ref. table exhausted\n"); | 209 | pr_warn("Port registration failed, ref. table exhausted\n"); |
| 225 | kfree(p_ptr); | 210 | return 0; |
| 226 | return NULL; | ||
| 227 | } | 211 | } |
| 228 | 212 | ||
| 229 | p_ptr->sk = sk; | ||
| 230 | p_ptr->max_pkt = MAX_PKT_DEFAULT; | 213 | p_ptr->max_pkt = MAX_PKT_DEFAULT; |
| 231 | p_ptr->ref = ref; | 214 | p_ptr->ref = ref; |
| 232 | INIT_LIST_HEAD(&p_ptr->wait_list); | 215 | INIT_LIST_HEAD(&p_ptr->wait_list); |
| 233 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); | 216 | INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); |
| 234 | p_ptr->dispatcher = dispatcher; | ||
| 235 | p_ptr->wakeup = wakeup; | ||
| 236 | k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref); | 217 | k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref); |
| 237 | INIT_LIST_HEAD(&p_ptr->publications); | 218 | INIT_LIST_HEAD(&p_ptr->publications); |
| 238 | INIT_LIST_HEAD(&p_ptr->port_list); | 219 | INIT_LIST_HEAD(&p_ptr->port_list); |
| @@ -248,10 +229,10 @@ struct tipc_port *tipc_createport(struct sock *sk, | |||
| 248 | msg_set_origport(msg, ref); | 229 | msg_set_origport(msg, ref); |
| 249 | list_add_tail(&p_ptr->port_list, &ports); | 230 | list_add_tail(&p_ptr->port_list, &ports); |
| 250 | spin_unlock_bh(&tipc_port_list_lock); | 231 | spin_unlock_bh(&tipc_port_list_lock); |
| 251 | return p_ptr; | 232 | return ref; |
| 252 | } | 233 | } |
| 253 | 234 | ||
| 254 | int tipc_deleteport(struct tipc_port *p_ptr) | 235 | void tipc_port_destroy(struct tipc_port *p_ptr) |
| 255 | { | 236 | { |
| 256 | struct sk_buff *buf = NULL; | 237 | struct sk_buff *buf = NULL; |
| 257 | 238 | ||
| @@ -272,67 +253,7 @@ int tipc_deleteport(struct tipc_port *p_ptr) | |||
| 272 | list_del(&p_ptr->wait_list); | 253 | list_del(&p_ptr->wait_list); |
| 273 | spin_unlock_bh(&tipc_port_list_lock); | 254 | spin_unlock_bh(&tipc_port_list_lock); |
| 274 | k_term_timer(&p_ptr->timer); | 255 | k_term_timer(&p_ptr->timer); |
| 275 | kfree(p_ptr); | ||
| 276 | tipc_net_route_msg(buf); | 256 | tipc_net_route_msg(buf); |
| 277 | return 0; | ||
| 278 | } | ||
| 279 | |||
| 280 | static int port_unreliable(struct tipc_port *p_ptr) | ||
| 281 | { | ||
| 282 | return msg_src_droppable(&p_ptr->phdr); | ||
| 283 | } | ||
| 284 | |||
| 285 | int tipc_portunreliable(u32 ref, unsigned int *isunreliable) | ||
| 286 | { | ||
| 287 | struct tipc_port *p_ptr; | ||
| 288 | |||
| 289 | p_ptr = tipc_port_lock(ref); | ||
| 290 | if (!p_ptr) | ||
| 291 | return -EINVAL; | ||
| 292 | *isunreliable = port_unreliable(p_ptr); | ||
| 293 | tipc_port_unlock(p_ptr); | ||
| 294 | return 0; | ||
| 295 | } | ||
| 296 | |||
| 297 | int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) | ||
| 298 | { | ||
| 299 | struct tipc_port *p_ptr; | ||
| 300 | |||
| 301 | p_ptr = tipc_port_lock(ref); | ||
| 302 | if (!p_ptr) | ||
| 303 | return -EINVAL; | ||
| 304 | msg_set_src_droppable(&p_ptr->phdr, (isunreliable != 0)); | ||
| 305 | tipc_port_unlock(p_ptr); | ||
| 306 | return 0; | ||
| 307 | } | ||
| 308 | |||
| 309 | static int port_unreturnable(struct tipc_port *p_ptr) | ||
| 310 | { | ||
| 311 | return msg_dest_droppable(&p_ptr->phdr); | ||
| 312 | } | ||
| 313 | |||
| 314 | int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) | ||
| 315 | { | ||
| 316 | struct tipc_port *p_ptr; | ||
| 317 | |||
| 318 | p_ptr = tipc_port_lock(ref); | ||
| 319 | if (!p_ptr) | ||
| 320 | return -EINVAL; | ||
| 321 | *isunrejectable = port_unreturnable(p_ptr); | ||
| 322 | tipc_port_unlock(p_ptr); | ||
| 323 | return 0; | ||
| 324 | } | ||
| 325 | |||
| 326 | int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) | ||
| 327 | { | ||
| 328 | struct tipc_port *p_ptr; | ||
| 329 | |||
| 330 | p_ptr = tipc_port_lock(ref); | ||
| 331 | if (!p_ptr) | ||
| 332 | return -EINVAL; | ||
| 333 | msg_set_dest_droppable(&p_ptr->phdr, (isunrejectable != 0)); | ||
| 334 | tipc_port_unlock(p_ptr); | ||
| 335 | return 0; | ||
| 336 | } | 257 | } |
| 337 | 258 | ||
| 338 | /* | 259 | /* |
| @@ -350,8 +271,8 @@ static struct sk_buff *port_build_proto_msg(struct tipc_port *p_ptr, | |||
| 350 | if (buf) { | 271 | if (buf) { |
| 351 | msg = buf_msg(buf); | 272 | msg = buf_msg(buf); |
| 352 | tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE, | 273 | tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE, |
| 353 | port_peernode(p_ptr)); | 274 | tipc_port_peernode(p_ptr)); |
| 354 | msg_set_destport(msg, port_peerport(p_ptr)); | 275 | msg_set_destport(msg, tipc_port_peerport(p_ptr)); |
| 355 | msg_set_origport(msg, p_ptr->ref); | 276 | msg_set_origport(msg, p_ptr->ref); |
| 356 | msg_set_msgcnt(msg, ack); | 277 | msg_set_msgcnt(msg, ack); |
| 357 | } | 278 | } |
| @@ -422,17 +343,17 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
| 422 | /* send returned message & dispose of rejected message */ | 343 | /* send returned message & dispose of rejected message */ |
| 423 | src_node = msg_prevnode(msg); | 344 | src_node = msg_prevnode(msg); |
| 424 | if (in_own_node(src_node)) | 345 | if (in_own_node(src_node)) |
| 425 | tipc_port_recv_msg(rbuf); | 346 | tipc_port_rcv(rbuf); |
| 426 | else | 347 | else |
| 427 | tipc_link_send(rbuf, src_node, msg_link_selector(rmsg)); | 348 | tipc_link_xmit(rbuf, src_node, msg_link_selector(rmsg)); |
| 428 | exit: | 349 | exit: |
| 429 | kfree_skb(buf); | 350 | kfree_skb(buf); |
| 430 | return data_sz; | 351 | return data_sz; |
| 431 | } | 352 | } |
| 432 | 353 | ||
| 433 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, | 354 | int tipc_port_iovec_reject(struct tipc_port *p_ptr, struct tipc_msg *hdr, |
| 434 | struct iovec const *msg_sect, unsigned int len, | 355 | struct iovec const *msg_sect, unsigned int len, |
| 435 | int err) | 356 | int err) |
| 436 | { | 357 | { |
| 437 | struct sk_buff *buf; | 358 | struct sk_buff *buf; |
| 438 | int res; | 359 | int res; |
| @@ -519,7 +440,7 @@ static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 er | |||
| 519 | return buf; | 440 | return buf; |
| 520 | } | 441 | } |
| 521 | 442 | ||
| 522 | void tipc_port_recv_proto_msg(struct sk_buff *buf) | 443 | void tipc_port_proto_rcv(struct sk_buff *buf) |
| 523 | { | 444 | { |
| 524 | struct tipc_msg *msg = buf_msg(buf); | 445 | struct tipc_msg *msg = buf_msg(buf); |
| 525 | struct tipc_port *p_ptr; | 446 | struct tipc_port *p_ptr; |
| @@ -547,13 +468,12 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) | |||
| 547 | /* Process protocol message sent by peer */ | 468 | /* Process protocol message sent by peer */ |
| 548 | switch (msg_type(msg)) { | 469 | switch (msg_type(msg)) { |
| 549 | case CONN_ACK: | 470 | case CONN_ACK: |
| 550 | wakeable = tipc_port_congested(p_ptr) && p_ptr->congested && | 471 | wakeable = tipc_port_congested(p_ptr) && p_ptr->congested; |
| 551 | p_ptr->wakeup; | ||
| 552 | p_ptr->acked += msg_msgcnt(msg); | 472 | p_ptr->acked += msg_msgcnt(msg); |
| 553 | if (!tipc_port_congested(p_ptr)) { | 473 | if (!tipc_port_congested(p_ptr)) { |
| 554 | p_ptr->congested = 0; | 474 | p_ptr->congested = 0; |
| 555 | if (wakeable) | 475 | if (wakeable) |
| 556 | p_ptr->wakeup(p_ptr); | 476 | tipc_port_wakeup(p_ptr); |
| 557 | } | 477 | } |
| 558 | break; | 478 | break; |
| 559 | case CONN_PROBE: | 479 | case CONN_PROBE: |
| @@ -584,8 +504,8 @@ static int port_print(struct tipc_port *p_ptr, char *buf, int len, int full_id) | |||
| 584 | ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref); | 504 | ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref); |
| 585 | 505 | ||
| 586 | if (p_ptr->connected) { | 506 | if (p_ptr->connected) { |
| 587 | u32 dport = port_peerport(p_ptr); | 507 | u32 dport = tipc_port_peerport(p_ptr); |
| 588 | u32 destnode = port_peernode(p_ptr); | 508 | u32 destnode = tipc_port_peernode(p_ptr); |
| 589 | 509 | ||
| 590 | ret += tipc_snprintf(buf + ret, len - ret, | 510 | ret += tipc_snprintf(buf + ret, len - ret, |
| 591 | " connected to <%u.%u.%u:%u>", | 511 | " connected to <%u.%u.%u:%u>", |
| @@ -673,34 +593,6 @@ void tipc_acknowledge(u32 ref, u32 ack) | |||
| 673 | tipc_net_route_msg(buf); | 593 | tipc_net_route_msg(buf); |
| 674 | } | 594 | } |
| 675 | 595 | ||
| 676 | int tipc_portimportance(u32 ref, unsigned int *importance) | ||
| 677 | { | ||
| 678 | struct tipc_port *p_ptr; | ||
| 679 | |||
| 680 | p_ptr = tipc_port_lock(ref); | ||
| 681 | if (!p_ptr) | ||
| 682 | return -EINVAL; | ||
| 683 | *importance = (unsigned int)msg_importance(&p_ptr->phdr); | ||
| 684 | tipc_port_unlock(p_ptr); | ||
| 685 | return 0; | ||
| 686 | } | ||
| 687 | |||
| 688 | int tipc_set_portimportance(u32 ref, unsigned int imp) | ||
| 689 | { | ||
| 690 | struct tipc_port *p_ptr; | ||
| 691 | |||
| 692 | if (imp > TIPC_CRITICAL_IMPORTANCE) | ||
| 693 | return -EINVAL; | ||
| 694 | |||
| 695 | p_ptr = tipc_port_lock(ref); | ||
| 696 | if (!p_ptr) | ||
| 697 | return -EINVAL; | ||
| 698 | msg_set_importance(&p_ptr->phdr, (u32)imp); | ||
| 699 | tipc_port_unlock(p_ptr); | ||
| 700 | return 0; | ||
| 701 | } | ||
| 702 | |||
| 703 | |||
| 704 | int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, | 596 | int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, |
| 705 | struct tipc_name_seq const *seq) | 597 | struct tipc_name_seq const *seq) |
| 706 | { | 598 | { |
| @@ -760,7 +652,7 @@ int tipc_withdraw(struct tipc_port *p_ptr, unsigned int scope, | |||
| 760 | return res; | 652 | return res; |
| 761 | } | 653 | } |
| 762 | 654 | ||
| 763 | int tipc_connect(u32 ref, struct tipc_portid const *peer) | 655 | int tipc_port_connect(u32 ref, struct tipc_portid const *peer) |
| 764 | { | 656 | { |
| 765 | struct tipc_port *p_ptr; | 657 | struct tipc_port *p_ptr; |
| 766 | int res; | 658 | int res; |
| @@ -768,17 +660,17 @@ int tipc_connect(u32 ref, struct tipc_portid const *peer) | |||
| 768 | p_ptr = tipc_port_lock(ref); | 660 | p_ptr = tipc_port_lock(ref); |
| 769 | if (!p_ptr) | 661 | if (!p_ptr) |
| 770 | return -EINVAL; | 662 | return -EINVAL; |
| 771 | res = __tipc_connect(ref, p_ptr, peer); | 663 | res = __tipc_port_connect(ref, p_ptr, peer); |
| 772 | tipc_port_unlock(p_ptr); | 664 | tipc_port_unlock(p_ptr); |
| 773 | return res; | 665 | return res; |
| 774 | } | 666 | } |
| 775 | 667 | ||
| 776 | /* | 668 | /* |
| 777 | * __tipc_connect - connect to a remote peer | 669 | * __tipc_port_connect - connect to a remote peer |
| 778 | * | 670 | * |
| 779 | * Port must be locked. | 671 | * Port must be locked. |
| 780 | */ | 672 | */ |
| 781 | int __tipc_connect(u32 ref, struct tipc_port *p_ptr, | 673 | int __tipc_port_connect(u32 ref, struct tipc_port *p_ptr, |
| 782 | struct tipc_portid const *peer) | 674 | struct tipc_portid const *peer) |
| 783 | { | 675 | { |
| 784 | struct tipc_msg *msg; | 676 | struct tipc_msg *msg; |
| @@ -815,7 +707,7 @@ exit: | |||
| 815 | * | 707 | * |
| 816 | * Port must be locked. | 708 | * Port must be locked. |
| 817 | */ | 709 | */ |
| 818 | int __tipc_disconnect(struct tipc_port *tp_ptr) | 710 | int __tipc_port_disconnect(struct tipc_port *tp_ptr) |
| 819 | { | 711 | { |
| 820 | if (tp_ptr->connected) { | 712 | if (tp_ptr->connected) { |
| 821 | tp_ptr->connected = 0; | 713 | tp_ptr->connected = 0; |
| @@ -828,10 +720,10 @@ int __tipc_disconnect(struct tipc_port *tp_ptr) | |||
| 828 | } | 720 | } |
| 829 | 721 | ||
| 830 | /* | 722 | /* |
| 831 | * tipc_disconnect(): Disconnect port form peer. | 723 | * tipc_port_disconnect(): Disconnect port form peer. |
| 832 | * This is a node local operation. | 724 | * This is a node local operation. |
| 833 | */ | 725 | */ |
| 834 | int tipc_disconnect(u32 ref) | 726 | int tipc_port_disconnect(u32 ref) |
| 835 | { | 727 | { |
| 836 | struct tipc_port *p_ptr; | 728 | struct tipc_port *p_ptr; |
| 837 | int res; | 729 | int res; |
| @@ -839,15 +731,15 @@ int tipc_disconnect(u32 ref) | |||
| 839 | p_ptr = tipc_port_lock(ref); | 731 | p_ptr = tipc_port_lock(ref); |
| 840 | if (!p_ptr) | 732 | if (!p_ptr) |
| 841 | return -EINVAL; | 733 | return -EINVAL; |
| 842 | res = __tipc_disconnect(p_ptr); | 734 | res = __tipc_port_disconnect(p_ptr); |
| 843 | tipc_port_unlock(p_ptr); | 735 | tipc_port_unlock(p_ptr); |
| 844 | return res; | 736 | return res; |
| 845 | } | 737 | } |
| 846 | 738 | ||
| 847 | /* | 739 | /* |
| 848 | * tipc_shutdown(): Send a SHUTDOWN msg to peer and disconnect | 740 | * tipc_port_shutdown(): Send a SHUTDOWN msg to peer and disconnect |
| 849 | */ | 741 | */ |
| 850 | int tipc_shutdown(u32 ref) | 742 | int tipc_port_shutdown(u32 ref) |
| 851 | { | 743 | { |
| 852 | struct tipc_port *p_ptr; | 744 | struct tipc_port *p_ptr; |
| 853 | struct sk_buff *buf = NULL; | 745 | struct sk_buff *buf = NULL; |
| @@ -859,13 +751,13 @@ int tipc_shutdown(u32 ref) | |||
| 859 | buf = port_build_peer_abort_msg(p_ptr, TIPC_CONN_SHUTDOWN); | 751 | buf = port_build_peer_abort_msg(p_ptr, TIPC_CONN_SHUTDOWN); |
| 860 | tipc_port_unlock(p_ptr); | 752 | tipc_port_unlock(p_ptr); |
| 861 | tipc_net_route_msg(buf); | 753 | tipc_net_route_msg(buf); |
| 862 | return tipc_disconnect(ref); | 754 | return tipc_port_disconnect(ref); |
| 863 | } | 755 | } |
| 864 | 756 | ||
| 865 | /** | 757 | /** |
| 866 | * tipc_port_recv_msg - receive message from lower layer and deliver to port user | 758 | * tipc_port_rcv - receive message from lower layer and deliver to port user |
| 867 | */ | 759 | */ |
| 868 | int tipc_port_recv_msg(struct sk_buff *buf) | 760 | int tipc_port_rcv(struct sk_buff *buf) |
| 869 | { | 761 | { |
| 870 | struct tipc_port *p_ptr; | 762 | struct tipc_port *p_ptr; |
| 871 | struct tipc_msg *msg = buf_msg(buf); | 763 | struct tipc_msg *msg = buf_msg(buf); |
| @@ -882,7 +774,7 @@ int tipc_port_recv_msg(struct sk_buff *buf) | |||
| 882 | /* validate destination & pass to port, otherwise reject message */ | 774 | /* validate destination & pass to port, otherwise reject message */ |
| 883 | p_ptr = tipc_port_lock(destport); | 775 | p_ptr = tipc_port_lock(destport); |
| 884 | if (likely(p_ptr)) { | 776 | if (likely(p_ptr)) { |
| 885 | err = p_ptr->dispatcher(p_ptr, buf); | 777 | err = tipc_sk_rcv(&tipc_port_to_sock(p_ptr)->sk, buf); |
| 886 | tipc_port_unlock(p_ptr); | 778 | tipc_port_unlock(p_ptr); |
| 887 | if (likely(!err)) | 779 | if (likely(!err)) |
| 888 | return dsz; | 780 | return dsz; |
| @@ -894,43 +786,43 @@ int tipc_port_recv_msg(struct sk_buff *buf) | |||
| 894 | } | 786 | } |
| 895 | 787 | ||
| 896 | /* | 788 | /* |
| 897 | * tipc_port_recv_sections(): Concatenate and deliver sectioned | 789 | * tipc_port_iovec_rcv: Concatenate and deliver sectioned |
| 898 | * message for this node. | 790 | * message for this node. |
| 899 | */ | 791 | */ |
| 900 | static int tipc_port_recv_sections(struct tipc_port *sender, | 792 | static int tipc_port_iovec_rcv(struct tipc_port *sender, |
| 901 | struct iovec const *msg_sect, | 793 | struct iovec const *msg_sect, |
| 902 | unsigned int len) | 794 | unsigned int len) |
| 903 | { | 795 | { |
| 904 | struct sk_buff *buf; | 796 | struct sk_buff *buf; |
| 905 | int res; | 797 | int res; |
| 906 | 798 | ||
| 907 | res = tipc_msg_build(&sender->phdr, msg_sect, len, MAX_MSG_SIZE, &buf); | 799 | res = tipc_msg_build(&sender->phdr, msg_sect, len, MAX_MSG_SIZE, &buf); |
| 908 | if (likely(buf)) | 800 | if (likely(buf)) |
| 909 | tipc_port_recv_msg(buf); | 801 | tipc_port_rcv(buf); |
| 910 | return res; | 802 | return res; |
| 911 | } | 803 | } |
| 912 | 804 | ||
| 913 | /** | 805 | /** |
| 914 | * tipc_send - send message sections on connection | 806 | * tipc_send - send message sections on connection |
| 915 | */ | 807 | */ |
| 916 | int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len) | 808 | int tipc_send(struct tipc_port *p_ptr, |
| 809 | struct iovec const *msg_sect, | ||
| 810 | unsigned int len) | ||
| 917 | { | 811 | { |
| 918 | struct tipc_port *p_ptr; | ||
| 919 | u32 destnode; | 812 | u32 destnode; |
| 920 | int res; | 813 | int res; |
| 921 | 814 | ||
| 922 | p_ptr = tipc_port_deref(ref); | 815 | if (!p_ptr->connected) |
| 923 | if (!p_ptr || !p_ptr->connected) | ||
| 924 | return -EINVAL; | 816 | return -EINVAL; |
| 925 | 817 | ||
| 926 | p_ptr->congested = 1; | 818 | p_ptr->congested = 1; |
| 927 | if (!tipc_port_congested(p_ptr)) { | 819 | if (!tipc_port_congested(p_ptr)) { |
| 928 | destnode = port_peernode(p_ptr); | 820 | destnode = tipc_port_peernode(p_ptr); |
| 929 | if (likely(!in_own_node(destnode))) | 821 | if (likely(!in_own_node(destnode))) |
| 930 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, | 822 | res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len, |
| 931 | len, destnode); | 823 | destnode); |
| 932 | else | 824 | else |
| 933 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); | 825 | res = tipc_port_iovec_rcv(p_ptr, msg_sect, len); |
| 934 | 826 | ||
| 935 | if (likely(res != -ELINKCONG)) { | 827 | if (likely(res != -ELINKCONG)) { |
| 936 | p_ptr->congested = 0; | 828 | p_ptr->congested = 0; |
| @@ -939,7 +831,7 @@ int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len) | |||
| 939 | return res; | 831 | return res; |
| 940 | } | 832 | } |
| 941 | } | 833 | } |
| 942 | if (port_unreliable(p_ptr)) { | 834 | if (tipc_port_unreliable(p_ptr)) { |
| 943 | p_ptr->congested = 0; | 835 | p_ptr->congested = 0; |
| 944 | return len; | 836 | return len; |
| 945 | } | 837 | } |
| @@ -949,17 +841,18 @@ int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len) | |||
| 949 | /** | 841 | /** |
| 950 | * tipc_send2name - send message sections to port name | 842 | * tipc_send2name - send message sections to port name |
| 951 | */ | 843 | */ |
| 952 | int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | 844 | int tipc_send2name(struct tipc_port *p_ptr, |
| 953 | struct iovec const *msg_sect, unsigned int len) | 845 | struct tipc_name const *name, |
| 846 | unsigned int domain, | ||
| 847 | struct iovec const *msg_sect, | ||
| 848 | unsigned int len) | ||
| 954 | { | 849 | { |
| 955 | struct tipc_port *p_ptr; | ||
| 956 | struct tipc_msg *msg; | 850 | struct tipc_msg *msg; |
| 957 | u32 destnode = domain; | 851 | u32 destnode = domain; |
| 958 | u32 destport; | 852 | u32 destport; |
| 959 | int res; | 853 | int res; |
| 960 | 854 | ||
| 961 | p_ptr = tipc_port_deref(ref); | 855 | if (p_ptr->connected) |
| 962 | if (!p_ptr || p_ptr->connected) | ||
| 963 | return -EINVAL; | 856 | return -EINVAL; |
| 964 | 857 | ||
| 965 | msg = &p_ptr->phdr; | 858 | msg = &p_ptr->phdr; |
| @@ -974,39 +867,39 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, | |||
| 974 | 867 | ||
| 975 | if (likely(destport || destnode)) { | 868 | if (likely(destport || destnode)) { |
| 976 | if (likely(in_own_node(destnode))) | 869 | if (likely(in_own_node(destnode))) |
| 977 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); | 870 | res = tipc_port_iovec_rcv(p_ptr, msg_sect, len); |
| 978 | else if (tipc_own_addr) | 871 | else if (tipc_own_addr) |
| 979 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, | 872 | res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len, |
| 980 | len, destnode); | 873 | destnode); |
| 981 | else | 874 | else |
| 982 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, | 875 | res = tipc_port_iovec_reject(p_ptr, msg, msg_sect, |
| 983 | len, TIPC_ERR_NO_NODE); | 876 | len, TIPC_ERR_NO_NODE); |
| 984 | if (likely(res != -ELINKCONG)) { | 877 | if (likely(res != -ELINKCONG)) { |
| 985 | if (res > 0) | 878 | if (res > 0) |
| 986 | p_ptr->sent++; | 879 | p_ptr->sent++; |
| 987 | return res; | 880 | return res; |
| 988 | } | 881 | } |
| 989 | if (port_unreliable(p_ptr)) { | 882 | if (tipc_port_unreliable(p_ptr)) |
| 990 | return len; | 883 | return len; |
| 991 | } | 884 | |
| 992 | return -ELINKCONG; | 885 | return -ELINKCONG; |
| 993 | } | 886 | } |
| 994 | return tipc_port_reject_sections(p_ptr, msg, msg_sect, len, | 887 | return tipc_port_iovec_reject(p_ptr, msg, msg_sect, len, |
| 995 | TIPC_ERR_NO_NAME); | 888 | TIPC_ERR_NO_NAME); |
| 996 | } | 889 | } |
| 997 | 890 | ||
| 998 | /** | 891 | /** |
| 999 | * tipc_send2port - send message sections to port identity | 892 | * tipc_send2port - send message sections to port identity |
| 1000 | */ | 893 | */ |
| 1001 | int tipc_send2port(u32 ref, struct tipc_portid const *dest, | 894 | int tipc_send2port(struct tipc_port *p_ptr, |
| 1002 | struct iovec const *msg_sect, unsigned int len) | 895 | struct tipc_portid const *dest, |
| 896 | struct iovec const *msg_sect, | ||
| 897 | unsigned int len) | ||
| 1003 | { | 898 | { |
| 1004 | struct tipc_port *p_ptr; | ||
| 1005 | struct tipc_msg *msg; | 899 | struct tipc_msg *msg; |
| 1006 | int res; | 900 | int res; |
| 1007 | 901 | ||
| 1008 | p_ptr = tipc_port_deref(ref); | 902 | if (p_ptr->connected) |
| 1009 | if (!p_ptr || p_ptr->connected) | ||
| 1010 | return -EINVAL; | 903 | return -EINVAL; |
| 1011 | 904 | ||
| 1012 | msg = &p_ptr->phdr; | 905 | msg = &p_ptr->phdr; |
| @@ -1017,20 +910,20 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest, | |||
| 1017 | msg_set_hdr_sz(msg, BASIC_H_SIZE); | 910 | msg_set_hdr_sz(msg, BASIC_H_SIZE); |
| 1018 | 911 | ||
| 1019 | if (in_own_node(dest->node)) | 912 | if (in_own_node(dest->node)) |
| 1020 | res = tipc_port_recv_sections(p_ptr, msg_sect, len); | 913 | res = tipc_port_iovec_rcv(p_ptr, msg_sect, len); |
| 1021 | else if (tipc_own_addr) | 914 | else if (tipc_own_addr) |
| 1022 | res = tipc_link_send_sections_fast(p_ptr, msg_sect, len, | 915 | res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len, |
| 1023 | dest->node); | 916 | dest->node); |
| 1024 | else | 917 | else |
| 1025 | res = tipc_port_reject_sections(p_ptr, msg, msg_sect, len, | 918 | res = tipc_port_iovec_reject(p_ptr, msg, msg_sect, len, |
| 1026 | TIPC_ERR_NO_NODE); | 919 | TIPC_ERR_NO_NODE); |
| 1027 | if (likely(res != -ELINKCONG)) { | 920 | if (likely(res != -ELINKCONG)) { |
| 1028 | if (res > 0) | 921 | if (res > 0) |
| 1029 | p_ptr->sent++; | 922 | p_ptr->sent++; |
| 1030 | return res; | 923 | return res; |
| 1031 | } | 924 | } |
| 1032 | if (port_unreliable(p_ptr)) { | 925 | if (tipc_port_unreliable(p_ptr)) |
| 1033 | return len; | 926 | return len; |
| 1034 | } | 927 | |
| 1035 | return -ELINKCONG; | 928 | return -ELINKCONG; |
| 1036 | } | 929 | } |
