aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/port.c
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2010-10-13 09:20:35 -0400
committerDavid S. Miller <davem@davemloft.net>2010-10-16 14:13:24 -0400
commit31e3c3f6f1f9b154981a0e6620df700463db30ee (patch)
tree5ed74529c528cc9a09d6f8c9a5083aaf4849b62e /net/tipc/port.c
parent15419227f773b6c1b5fae44bde876078a9204caa (diff)
tipc: cleanup function namespace
Do some cleanups of TIPC based on make namespacecheck 1. Don't export unused symbols 2. Eliminate dead code 3. Make functions and variables local 4. Rename buf_acquire to tipc_buf_acquire since it is used in several files Compile tested only. This make break out of tree kernel modules that depend on TIPC routines. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Acked-by: Jon Maloy <jon.maloy@ericsson.com> Acked-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r--net/tipc/port.c234
1 files changed, 23 insertions, 211 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 5c4285b2d55..82092eaa153 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -293,34 +293,6 @@ int tipc_deleteport(u32 ref)
293 return 0; 293 return 0;
294} 294}
295 295
296/**
297 * tipc_get_port() - return port associated with 'ref'
298 *
299 * Note: Port is not locked.
300 */
301
302struct tipc_port *tipc_get_port(const u32 ref)
303{
304 return (struct tipc_port *)tipc_ref_deref(ref);
305}
306
307/**
308 * tipc_get_handle - return user handle associated to port 'ref'
309 */
310
311void *tipc_get_handle(const u32 ref)
312{
313 struct port *p_ptr;
314 void * handle;
315
316 p_ptr = tipc_port_lock(ref);
317 if (!p_ptr)
318 return NULL;
319 handle = p_ptr->publ.usr_handle;
320 tipc_port_unlock(p_ptr);
321 return handle;
322}
323
324static int port_unreliable(struct port *p_ptr) 296static int port_unreliable(struct port *p_ptr)
325{ 297{
326 return msg_src_droppable(&p_ptr->publ.phdr); 298 return msg_src_droppable(&p_ptr->publ.phdr);
@@ -392,7 +364,7 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
392 struct sk_buff *buf; 364 struct sk_buff *buf;
393 struct tipc_msg *msg; 365 struct tipc_msg *msg;
394 366
395 buf = buf_acquire(LONG_H_SIZE); 367 buf = tipc_buf_acquire(LONG_H_SIZE);
396 if (buf) { 368 if (buf) {
397 msg = buf_msg(buf); 369 msg = buf_msg(buf);
398 tipc_msg_init(msg, usr, type, LONG_H_SIZE, destnode); 370 tipc_msg_init(msg, usr, type, LONG_H_SIZE, destnode);
@@ -433,7 +405,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
433 hdr_sz = MCAST_H_SIZE; 405 hdr_sz = MCAST_H_SIZE;
434 else 406 else
435 hdr_sz = LONG_H_SIZE; 407 hdr_sz = LONG_H_SIZE;
436 rbuf = buf_acquire(data_sz + hdr_sz); 408 rbuf = tipc_buf_acquire(data_sz + hdr_sz);
437 if (rbuf == NULL) { 409 if (rbuf == NULL) {
438 buf_discard(buf); 410 buf_discard(buf);
439 return data_sz; 411 return data_sz;
@@ -1242,50 +1214,13 @@ int tipc_shutdown(u32 ref)
1242 return tipc_disconnect(ref); 1214 return tipc_disconnect(ref);
1243} 1215}
1244 1216
1245int tipc_isconnected(u32 ref, int *isconnected)
1246{
1247 struct port *p_ptr;
1248
1249 p_ptr = tipc_port_lock(ref);
1250 if (!p_ptr)
1251 return -EINVAL;
1252 *isconnected = p_ptr->publ.connected;
1253 tipc_port_unlock(p_ptr);
1254 return 0;
1255}
1256
1257int tipc_peer(u32 ref, struct tipc_portid *peer)
1258{
1259 struct port *p_ptr;
1260 int res;
1261
1262 p_ptr = tipc_port_lock(ref);
1263 if (!p_ptr)
1264 return -EINVAL;
1265 if (p_ptr->publ.connected) {
1266 peer->ref = port_peerport(p_ptr);
1267 peer->node = port_peernode(p_ptr);
1268 res = 0;
1269 } else
1270 res = -ENOTCONN;
1271 tipc_port_unlock(p_ptr);
1272 return res;
1273}
1274
1275int tipc_ref_valid(u32 ref)
1276{
1277 /* Works irrespective of type */
1278 return !!tipc_ref_deref(ref);
1279}
1280
1281
1282/* 1217/*
1283 * tipc_port_recv_sections(): Concatenate and deliver sectioned 1218 * tipc_port_recv_sections(): Concatenate and deliver sectioned
1284 * message for this node. 1219 * message for this node.
1285 */ 1220 */
1286 1221
1287int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, 1222static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect,
1288 struct iovec const *msg_sect) 1223 struct iovec const *msg_sect)
1289{ 1224{
1290 struct sk_buff *buf; 1225 struct sk_buff *buf;
1291 int res; 1226 int res;
@@ -1336,65 +1271,16 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1336} 1271}
1337 1272
1338/** 1273/**
1339 * tipc_send_buf - send message buffer on connection
1340 */
1341
1342int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz)
1343{
1344 struct port *p_ptr;
1345 struct tipc_msg *msg;
1346 u32 destnode;
1347 u32 hsz;
1348 u32 sz;
1349 u32 res;
1350
1351 p_ptr = tipc_port_deref(ref);
1352 if (!p_ptr || !p_ptr->publ.connected)
1353 return -EINVAL;
1354
1355 msg = &p_ptr->publ.phdr;
1356 hsz = msg_hdr_sz(msg);
1357 sz = hsz + dsz;
1358 msg_set_size(msg, sz);
1359 if (skb_cow(buf, hsz))
1360 return -ENOMEM;
1361
1362 skb_push(buf, hsz);
1363 skb_copy_to_linear_data(buf, msg, hsz);
1364 destnode = msg_destnode(msg);
1365 p_ptr->publ.congested = 1;
1366 if (!tipc_port_congested(p_ptr)) {
1367 if (likely(destnode != tipc_own_addr))
1368 res = tipc_send_buf_fast(buf, destnode);
1369 else {
1370 tipc_port_recv_msg(buf);
1371 res = sz;
1372 }
1373 if (likely(res != -ELINKCONG)) {
1374 port_incr_out_seqno(p_ptr);
1375 p_ptr->sent++;
1376 p_ptr->publ.congested = 0;
1377 return res;
1378 }
1379 }
1380 if (port_unreliable(p_ptr)) {
1381 p_ptr->publ.congested = 0;
1382 return dsz;
1383 }
1384 return -ELINKCONG;
1385}
1386
1387/**
1388 * tipc_forward2name - forward message sections to port name 1274 * tipc_forward2name - forward message sections to port name
1389 */ 1275 */
1390 1276
1391int tipc_forward2name(u32 ref, 1277static int tipc_forward2name(u32 ref,
1392 struct tipc_name const *name, 1278 struct tipc_name const *name,
1393 u32 domain, 1279 u32 domain,
1394 u32 num_sect, 1280 u32 num_sect,
1395 struct iovec const *msg_sect, 1281 struct iovec const *msg_sect,
1396 struct tipc_portid const *orig, 1282 struct tipc_portid const *orig,
1397 unsigned int importance) 1283 unsigned int importance)
1398{ 1284{
1399 struct port *p_ptr; 1285 struct port *p_ptr;
1400 struct tipc_msg *msg; 1286 struct tipc_msg *msg;
@@ -1457,89 +1343,15 @@ int tipc_send2name(u32 ref,
1457} 1343}
1458 1344
1459/** 1345/**
1460 * tipc_forward_buf2name - forward message buffer to port name
1461 */
1462
1463int tipc_forward_buf2name(u32 ref,
1464 struct tipc_name const *name,
1465 u32 domain,
1466 struct sk_buff *buf,
1467 unsigned int dsz,
1468 struct tipc_portid const *orig,
1469 unsigned int importance)
1470{
1471 struct port *p_ptr;
1472 struct tipc_msg *msg;
1473 u32 destnode = domain;
1474 u32 destport;
1475 int res;
1476
1477 p_ptr = (struct port *)tipc_ref_deref(ref);
1478 if (!p_ptr || p_ptr->publ.connected)
1479 return -EINVAL;
1480
1481 msg = &p_ptr->publ.phdr;
1482 if (importance <= TIPC_CRITICAL_IMPORTANCE)
1483 msg_set_importance(msg, importance);
1484 msg_set_type(msg, TIPC_NAMED_MSG);
1485 msg_set_orignode(msg, orig->node);
1486 msg_set_origport(msg, orig->ref);
1487 msg_set_nametype(msg, name->type);
1488 msg_set_nameinst(msg, name->instance);
1489 msg_set_lookup_scope(msg, tipc_addr_scope(domain));
1490 msg_set_hdr_sz(msg, LONG_H_SIZE);
1491 msg_set_size(msg, LONG_H_SIZE + dsz);
1492 destport = tipc_nametbl_translate(name->type, name->instance, &destnode);
1493 msg_set_destnode(msg, destnode);
1494 msg_set_destport(msg, destport);
1495 msg_dbg(msg, "forw2name ==> ");
1496 if (skb_cow(buf, LONG_H_SIZE))
1497 return -ENOMEM;
1498 skb_push(buf, LONG_H_SIZE);
1499 skb_copy_to_linear_data(buf, msg, LONG_H_SIZE);
1500 msg_dbg(buf_msg(buf),"PREP:");
1501 if (likely(destport)) {
1502 p_ptr->sent++;
1503 if (destnode == tipc_own_addr)
1504 return tipc_port_recv_msg(buf);
1505 res = tipc_send_buf_fast(buf, destnode);
1506 if (likely(res != -ELINKCONG))
1507 return res;
1508 if (port_unreliable(p_ptr))
1509 return dsz;
1510 return -ELINKCONG;
1511 }
1512 return tipc_reject_msg(buf, TIPC_ERR_NO_NAME);
1513}
1514
1515/**
1516 * tipc_send_buf2name - send message buffer to port name
1517 */
1518
1519int tipc_send_buf2name(u32 ref,
1520 struct tipc_name const *dest,
1521 u32 domain,
1522 struct sk_buff *buf,
1523 unsigned int dsz)
1524{
1525 struct tipc_portid orig;
1526
1527 orig.ref = ref;
1528 orig.node = tipc_own_addr;
1529 return tipc_forward_buf2name(ref, dest, domain, buf, dsz, &orig,
1530 TIPC_PORT_IMPORTANCE);
1531}
1532
1533/**
1534 * tipc_forward2port - forward message sections to port identity 1346 * tipc_forward2port - forward message sections to port identity
1535 */ 1347 */
1536 1348
1537int tipc_forward2port(u32 ref, 1349static int tipc_forward2port(u32 ref,
1538 struct tipc_portid const *dest, 1350 struct tipc_portid const *dest,
1539 unsigned int num_sect, 1351 unsigned int num_sect,
1540 struct iovec const *msg_sect, 1352 struct iovec const *msg_sect,
1541 struct tipc_portid const *orig, 1353 struct tipc_portid const *orig,
1542 unsigned int importance) 1354 unsigned int importance)
1543{ 1355{
1544 struct port *p_ptr; 1356 struct port *p_ptr;
1545 struct tipc_msg *msg; 1357 struct tipc_msg *msg;
@@ -1591,12 +1403,12 @@ int tipc_send2port(u32 ref,
1591/** 1403/**
1592 * tipc_forward_buf2port - forward message buffer to port identity 1404 * tipc_forward_buf2port - forward message buffer to port identity
1593 */ 1405 */
1594int tipc_forward_buf2port(u32 ref, 1406static int tipc_forward_buf2port(u32 ref,
1595 struct tipc_portid const *dest, 1407 struct tipc_portid const *dest,
1596 struct sk_buff *buf, 1408 struct sk_buff *buf,
1597 unsigned int dsz, 1409 unsigned int dsz,
1598 struct tipc_portid const *orig, 1410 struct tipc_portid const *orig,
1599 unsigned int importance) 1411 unsigned int importance)
1600{ 1412{
1601 struct port *p_ptr; 1413 struct port *p_ptr;
1602 struct tipc_msg *msg; 1414 struct tipc_msg *msg;