aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/port.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r--net/tipc/port.c170
1 files changed, 31 insertions, 139 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 82092eaa1536..067bab2a0b98 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -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,16 +46,16 @@
53 46
54#define MAX_REJECT_SIZE 1024 47#define MAX_REJECT_SIZE 1024
55 48
56static struct sk_buff *msg_queue_head = NULL; 49static struct sk_buff *msg_queue_head;
57static struct sk_buff *msg_queue_tail = NULL; 50static struct sk_buff *msg_queue_tail;
58 51
59DEFINE_SPINLOCK(tipc_port_list_lock); 52DEFINE_SPINLOCK(tipc_port_list_lock);
60static DEFINE_SPINLOCK(queue_lock); 53static DEFINE_SPINLOCK(queue_lock);
61 54
62static LIST_HEAD(ports); 55static LIST_HEAD(ports);
63static void port_handle_node_down(unsigned long ref); 56static void port_handle_node_down(unsigned long ref);
64static struct sk_buff* port_build_self_abort_msg(struct port *,u32 err); 57static struct sk_buff *port_build_self_abort_msg(struct port *, u32 err);
65static struct sk_buff* port_build_peer_abort_msg(struct port *,u32 err); 58static struct sk_buff *port_build_peer_abort_msg(struct port *, u32 err);
66static void port_timeout(unsigned long ref); 59static void port_timeout(unsigned long ref);
67 60
68 61
@@ -94,7 +87,7 @@ static void port_incr_out_seqno(struct port *p_ptr)
94 * tipc_multicast - send a multicast message to local and remote destinations 87 * tipc_multicast - send a multicast message to local and remote destinations
95 */ 88 */
96 89
97int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, 90int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
98 u32 num_sect, struct iovec const *msg_sect) 91 u32 num_sect, struct iovec const *msg_sect)
99{ 92{
100 struct tipc_msg *hdr; 93 struct tipc_msg *hdr;
@@ -138,9 +131,8 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain,
138 } 131 }
139 } 132 }
140 res = tipc_bclink_send_msg(buf); 133 res = tipc_bclink_send_msg(buf);
141 if ((res < 0) && (dports.count != 0)) { 134 if ((res < 0) && (dports.count != 0))
142 buf_discard(ibuf); 135 buf_discard(ibuf);
143 }
144 } else { 136 } else {
145 ibuf = buf; 137 ibuf = buf;
146 } 138 }
@@ -162,7 +154,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain,
162 154
163void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp) 155void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp)
164{ 156{
165 struct tipc_msg* msg; 157 struct tipc_msg *msg;
166 struct port_list dports = {0, NULL, }; 158 struct port_list dports = {0, NULL, };
167 struct port_list *item = dp; 159 struct port_list *item = dp;
168 int cnt = 0; 160 int cnt = 0;
@@ -195,13 +187,11 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp)
195 187
196 if (b == NULL) { 188 if (b == NULL) {
197 warn("Unable to deliver multicast message(s)\n"); 189 warn("Unable to deliver multicast message(s)\n");
198 msg_dbg(msg, "LOST:");
199 goto exit; 190 goto exit;
200 } 191 }
201 if ((index == 0) && (cnt != 0)) { 192 if ((index == 0) && (cnt != 0))
202 item = item->next; 193 item = item->next;
203 } 194 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); 195 tipc_port_recv_msg(b);
206 } 196 }
207 } 197 }
@@ -277,10 +267,7 @@ int tipc_deleteport(u32 ref)
277 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT); 267 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT);
278 tipc_nodesub_unsubscribe(&p_ptr->subscription); 268 tipc_nodesub_unsubscribe(&p_ptr->subscription);
279 } 269 }
280 if (p_ptr->user_port) { 270 kfree(p_ptr->user_port);
281 tipc_reg_remove_port(p_ptr->user_port);
282 kfree(p_ptr->user_port);
283 }
284 271
285 spin_lock_bh(&tipc_port_list_lock); 272 spin_lock_bh(&tipc_port_list_lock);
286 list_del(&p_ptr->port_list); 273 list_del(&p_ptr->port_list);
@@ -288,7 +275,6 @@ int tipc_deleteport(u32 ref)
288 spin_unlock_bh(&tipc_port_list_lock); 275 spin_unlock_bh(&tipc_port_list_lock);
289 k_term_timer(&p_ptr->timer); 276 k_term_timer(&p_ptr->timer);
290 kfree(p_ptr); 277 kfree(p_ptr);
291 dbg("Deleted port %u\n", ref);
292 tipc_net_route_msg(buf); 278 tipc_net_route_msg(buf);
293 return 0; 279 return 0;
294} 280}
@@ -374,7 +360,6 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
374 msg_set_orignode(msg, orignode); 360 msg_set_orignode(msg, orignode);
375 msg_set_transp_seqno(msg, seqno); 361 msg_set_transp_seqno(msg, seqno);
376 msg_set_msgcnt(msg, ack); 362 msg_set_msgcnt(msg, ack);
377 msg_dbg(msg, "PORT>SEND>:");
378 } 363 }
379 return buf; 364 return buf;
380} 365}
@@ -392,7 +377,6 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
392 data_sz = MAX_REJECT_SIZE; 377 data_sz = MAX_REJECT_SIZE;
393 if (msg_connected(msg) && (imp < TIPC_CRITICAL_IMPORTANCE)) 378 if (msg_connected(msg) && (imp < TIPC_CRITICAL_IMPORTANCE))
394 imp++; 379 imp++;
395 msg_dbg(msg, "port->rej: ");
396 380
397 /* discard rejected message if it shouldn't be returned to sender */ 381 /* discard rejected message if it shouldn't be returned to sender */
398 if (msg_errcode(msg) || msg_dest_droppable(msg)) { 382 if (msg_errcode(msg) || msg_dest_droppable(msg)) {
@@ -498,7 +482,7 @@ static void port_timeout(unsigned long ref)
498static void port_handle_node_down(unsigned long ref) 482static void port_handle_node_down(unsigned long ref)
499{ 483{
500 struct port *p_ptr = tipc_port_lock(ref); 484 struct port *p_ptr = tipc_port_lock(ref);
501 struct sk_buff* buf = NULL; 485 struct sk_buff *buf = NULL;
502 486
503 if (!p_ptr) 487 if (!p_ptr)
504 return; 488 return;
@@ -555,8 +539,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
555 struct sk_buff *r_buf = NULL; 539 struct sk_buff *r_buf = NULL;
556 struct sk_buff *abort_buf = NULL; 540 struct sk_buff *abort_buf = NULL;
557 541
558 msg_dbg(msg, "PORT<RECV<:");
559
560 if (!p_ptr) { 542 if (!p_ptr) {
561 err = TIPC_ERR_NO_PORT; 543 err = TIPC_ERR_NO_PORT;
562 } else if (p_ptr->publ.connected) { 544 } else if (p_ptr->publ.connected) {
@@ -636,8 +618,7 @@ static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id)
636 tipc_printf(buf, " via {%u,%u}", 618 tipc_printf(buf, " via {%u,%u}",
637 p_ptr->publ.conn_type, 619 p_ptr->publ.conn_type,
638 p_ptr->publ.conn_instance); 620 p_ptr->publ.conn_instance);
639 } 621 } else if (p_ptr->publ.published) {
640 else if (p_ptr->publ.published) {
641 tipc_printf(buf, " bound to"); 622 tipc_printf(buf, " bound to");
642 list_for_each_entry(publ, &p_ptr->publications, pport_list) { 623 list_for_each_entry(publ, &p_ptr->publications, pport_list) {
643 if (publ->lower == publ->upper) 624 if (publ->lower == publ->upper)
@@ -940,12 +921,10 @@ void tipc_acknowledge(u32 ref, u32 ack)
940} 921}
941 922
942/* 923/*
943 * tipc_createport(): user level call. Will add port to 924 * tipc_createport(): user level call.
944 * registry if non-zero user_ref.
945 */ 925 */
946 926
947int tipc_createport(u32 user_ref, 927int tipc_createport(void *usr_handle,
948 void *usr_handle,
949 unsigned int importance, 928 unsigned int importance,
950 tipc_msg_err_event error_cb, 929 tipc_msg_err_event error_cb,
951 tipc_named_msg_err_event named_error_cb, 930 tipc_named_msg_err_event named_error_cb,
@@ -972,7 +951,6 @@ int tipc_createport(u32 user_ref,
972 } 951 }
973 952
974 p_ptr->user_port = up_ptr; 953 p_ptr->user_port = up_ptr;
975 up_ptr->user_ref = user_ref;
976 up_ptr->usr_handle = usr_handle; 954 up_ptr->usr_handle = usr_handle;
977 up_ptr->ref = p_ptr->publ.ref; 955 up_ptr->ref = p_ptr->publ.ref;
978 up_ptr->err_cb = error_cb; 956 up_ptr->err_cb = error_cb;
@@ -982,20 +960,11 @@ int tipc_createport(u32 user_ref,
982 up_ptr->named_msg_cb = named_msg_cb; 960 up_ptr->named_msg_cb = named_msg_cb;
983 up_ptr->conn_msg_cb = conn_msg_cb; 961 up_ptr->conn_msg_cb = conn_msg_cb;
984 up_ptr->continue_event_cb = continue_event_cb; 962 up_ptr->continue_event_cb = continue_event_cb;
985 INIT_LIST_HEAD(&up_ptr->uport_list);
986 tipc_reg_add_port(up_ptr);
987 *portref = p_ptr->publ.ref; 963 *portref = p_ptr->publ.ref;
988 tipc_port_unlock(p_ptr); 964 tipc_port_unlock(p_ptr);
989 return 0; 965 return 0;
990} 966}
991 967
992int tipc_ownidentity(u32 ref, struct tipc_portid *id)
993{
994 id->ref = ref;
995 id->node = tipc_own_addr;
996 return 0;
997}
998
999int tipc_portimportance(u32 ref, unsigned int *importance) 968int tipc_portimportance(u32 ref, unsigned int *importance)
1000{ 969{
1001 struct port *p_ptr; 970 struct port *p_ptr;
@@ -1035,9 +1004,6 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1035 if (!p_ptr) 1004 if (!p_ptr)
1036 return -EINVAL; 1005 return -EINVAL;
1037 1006
1038 dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, "
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) 1007 if (p_ptr->publ.connected)
1042 goto exit; 1008 goto exit;
1043 if (seq->lower > seq->upper) 1009 if (seq->lower > seq->upper)
@@ -1123,17 +1089,14 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
1123 msg_set_origport(msg, p_ptr->publ.ref); 1089 msg_set_origport(msg, p_ptr->publ.ref);
1124 msg_set_transp_seqno(msg, 42); 1090 msg_set_transp_seqno(msg, 42);
1125 msg_set_type(msg, TIPC_CONN_MSG); 1091 msg_set_type(msg, TIPC_CONN_MSG);
1126 if (!may_route(peer->node)) 1092 msg_set_hdr_sz(msg, SHORT_H_SIZE);
1127 msg_set_hdr_sz(msg, SHORT_H_SIZE);
1128 else
1129 msg_set_hdr_sz(msg, LONG_H_SIZE);
1130 1093
1131 p_ptr->probing_interval = PROBING_INTERVAL; 1094 p_ptr->probing_interval = PROBING_INTERVAL;
1132 p_ptr->probing_state = CONFIRMED; 1095 p_ptr->probing_state = CONFIRMED;
1133 p_ptr->publ.connected = 1; 1096 p_ptr->publ.connected = 1;
1134 k_start_timer(&p_ptr->timer, p_ptr->probing_interval); 1097 k_start_timer(&p_ptr->timer, p_ptr->probing_interval);
1135 1098
1136 tipc_nodesub_subscribe(&p_ptr->subscription,peer->node, 1099 tipc_nodesub_subscribe(&p_ptr->subscription, peer->node,
1137 (void *)(unsigned long)ref, 1100 (void *)(unsigned long)ref,
1138 (net_ev_handler)port_handle_node_down); 1101 (net_ev_handler)port_handle_node_down);
1139 res = 0; 1102 res = 0;
@@ -1271,16 +1234,11 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1271} 1234}
1272 1235
1273/** 1236/**
1274 * tipc_forward2name - forward message sections to port name 1237 * tipc_send2name - send message sections to port name
1275 */ 1238 */
1276 1239
1277static int tipc_forward2name(u32 ref, 1240int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1278 struct tipc_name const *name, 1241 unsigned int num_sect, struct iovec const *msg_sect)
1279 u32 domain,
1280 u32 num_sect,
1281 struct iovec const *msg_sect,
1282 struct tipc_portid const *orig,
1283 unsigned int importance)
1284{ 1242{
1285 struct port *p_ptr; 1243 struct port *p_ptr;
1286 struct tipc_msg *msg; 1244 struct tipc_msg *msg;
@@ -1294,14 +1252,12 @@ static int tipc_forward2name(u32 ref,
1294 1252
1295 msg = &p_ptr->publ.phdr; 1253 msg = &p_ptr->publ.phdr;
1296 msg_set_type(msg, TIPC_NAMED_MSG); 1254 msg_set_type(msg, TIPC_NAMED_MSG);
1297 msg_set_orignode(msg, orig->node); 1255 msg_set_orignode(msg, tipc_own_addr);
1298 msg_set_origport(msg, orig->ref); 1256 msg_set_origport(msg, ref);
1299 msg_set_hdr_sz(msg, LONG_H_SIZE); 1257 msg_set_hdr_sz(msg, LONG_H_SIZE);
1300 msg_set_nametype(msg, name->type); 1258 msg_set_nametype(msg, name->type);
1301 msg_set_nameinst(msg, name->instance); 1259 msg_set_nameinst(msg, name->instance);
1302 msg_set_lookup_scope(msg, tipc_addr_scope(domain)); 1260 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); 1261 destport = tipc_nametbl_translate(name->type, name->instance, &destnode);
1306 msg_set_destnode(msg, destnode); 1262 msg_set_destnode(msg, destnode);
1307 msg_set_destport(msg, destport); 1263 msg_set_destport(msg, destport);
@@ -1325,33 +1281,11 @@ static int tipc_forward2name(u32 ref,
1325} 1281}
1326 1282
1327/** 1283/**
1328 * tipc_send2name - send message sections to port name 1284 * tipc_send2port - send message sections to port identity
1329 */
1330
1331int 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 */ 1285 */
1348 1286
1349static int tipc_forward2port(u32 ref, 1287int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1350 struct tipc_portid const *dest, 1288 unsigned int num_sect, struct iovec const *msg_sect)
1351 unsigned int num_sect,
1352 struct iovec const *msg_sect,
1353 struct tipc_portid const *orig,
1354 unsigned int importance)
1355{ 1289{
1356 struct port *p_ptr; 1290 struct port *p_ptr;
1357 struct tipc_msg *msg; 1291 struct tipc_msg *msg;
@@ -1363,13 +1297,11 @@ static int tipc_forward2port(u32 ref,
1363 1297
1364 msg = &p_ptr->publ.phdr; 1298 msg = &p_ptr->publ.phdr;
1365 msg_set_type(msg, TIPC_DIRECT_MSG); 1299 msg_set_type(msg, TIPC_DIRECT_MSG);
1366 msg_set_orignode(msg, orig->node); 1300 msg_set_orignode(msg, tipc_own_addr);
1367 msg_set_origport(msg, orig->ref); 1301 msg_set_origport(msg, ref);
1368 msg_set_destnode(msg, dest->node); 1302 msg_set_destnode(msg, dest->node);
1369 msg_set_destport(msg, dest->ref); 1303 msg_set_destport(msg, dest->ref);
1370 msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); 1304 msg_set_hdr_sz(msg, DIR_MSG_H_SIZE);
1371 if (importance <= TIPC_CRITICAL_IMPORTANCE)
1372 msg_set_importance(msg, importance);
1373 p_ptr->sent++; 1305 p_ptr->sent++;
1374 if (dest->node == tipc_own_addr) 1306 if (dest->node == tipc_own_addr)
1375 return tipc_port_recv_sections(p_ptr, num_sect, msg_sect); 1307 return tipc_port_recv_sections(p_ptr, num_sect, msg_sect);
@@ -1384,31 +1316,11 @@ static int tipc_forward2port(u32 ref,
1384} 1316}
1385 1317
1386/** 1318/**
1387 * tipc_send2port - send message sections to port identity 1319 * tipc_send_buf2port - send message buffer to port identity
1388 */ 1320 */
1389 1321
1390int tipc_send2port(u32 ref, 1322int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
1391 struct tipc_portid const *dest, 1323 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 */
1406static 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{ 1324{
1413 struct port *p_ptr; 1325 struct port *p_ptr;
1414 struct tipc_msg *msg; 1326 struct tipc_msg *msg;
@@ -1420,20 +1332,17 @@ static int tipc_forward_buf2port(u32 ref,
1420 1332
1421 msg = &p_ptr->publ.phdr; 1333 msg = &p_ptr->publ.phdr;
1422 msg_set_type(msg, TIPC_DIRECT_MSG); 1334 msg_set_type(msg, TIPC_DIRECT_MSG);
1423 msg_set_orignode(msg, orig->node); 1335 msg_set_orignode(msg, tipc_own_addr);
1424 msg_set_origport(msg, orig->ref); 1336 msg_set_origport(msg, ref);
1425 msg_set_destnode(msg, dest->node); 1337 msg_set_destnode(msg, dest->node);
1426 msg_set_destport(msg, dest->ref); 1338 msg_set_destport(msg, dest->ref);
1427 msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); 1339 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); 1340 msg_set_size(msg, DIR_MSG_H_SIZE + dsz);
1431 if (skb_cow(buf, DIR_MSG_H_SIZE)) 1341 if (skb_cow(buf, DIR_MSG_H_SIZE))
1432 return -ENOMEM; 1342 return -ENOMEM;
1433 1343
1434 skb_push(buf, DIR_MSG_H_SIZE); 1344 skb_push(buf, DIR_MSG_H_SIZE);
1435 skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE); 1345 skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE);
1436 msg_dbg(msg, "buf2port: ");
1437 p_ptr->sent++; 1346 p_ptr->sent++;
1438 if (dest->node == tipc_own_addr) 1347 if (dest->node == tipc_own_addr)
1439 return tipc_port_recv_msg(buf); 1348 return tipc_port_recv_msg(buf);
@@ -1445,20 +1354,3 @@ static int tipc_forward_buf2port(u32 ref,
1445 return -ELINKCONG; 1354 return -ELINKCONG;
1446} 1355}
1447 1356
1448/**
1449 * tipc_send_buf2port - send message buffer to port identity
1450 */
1451
1452int 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