aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/port.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 21:02:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 21:02:35 -0400
commit334d094504c2fe1c44211ecb49146ae6bca8c321 (patch)
treed3c0f68e4b9f8e3d2ccc39e7dfe5de0534a5fad9 /net/tipc/port.c
parentd1a4be630fb068f251d64b62919f143c49ca8057 (diff)
parentd1643d24c61b725bef399cc1cf2944b4c9c23177 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.26
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.26: (1090 commits) [NET]: Fix and allocate less memory for ->priv'less netdevices [IPV6]: Fix dangling references on error in fib6_add(). [NETLABEL]: Fix NULL deref in netlbl_unlabel_staticlist_gen() if ifindex not found [PKT_SCHED]: Fix datalen check in tcf_simp_init(). [INET]: Uninline the __inet_inherit_port call. [INET]: Drop the inet_inherit_port() call. SCTP: Initialize partial_bytes_acked to 0, when all of the data is acked. [netdrvr] forcedeth: internal simplifications; changelog removal phylib: factor out get_phy_id from within get_phy_device PHY: add BCM5464 support to broadcom PHY driver cxgb3: Fix __must_check warning with dev_dbg. tc35815: Statistics cleanup natsemi: fix MMIO for PPC 44x platforms [TIPC]: Cleanup of TIPC reference table code [TIPC]: Optimized initialization of TIPC reference table [TIPC]: Remove inlining of reference table locking routines e1000: convert uint16_t style integers to u16 ixgb: convert uint16_t style integers to u16 sb1000.c: make const arrays static sb1000.c: stop inlining largish static functions ...
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r--net/tipc/port.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index f508614ca59b..2f5806410c64 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -242,7 +242,8 @@ u32 tipc_createport_raw(void *usr_handle,
242 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; 242 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT;
243 p_ptr->publ.ref = ref; 243 p_ptr->publ.ref = ref;
244 msg = &p_ptr->publ.phdr; 244 msg = &p_ptr->publ.phdr;
245 msg_init(msg, DATA_LOW, TIPC_NAMED_MSG, TIPC_OK, LONG_H_SIZE, 0); 245 msg_init(msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG, TIPC_OK, LONG_H_SIZE,
246 0);
246 msg_set_orignode(msg, tipc_own_addr); 247 msg_set_orignode(msg, tipc_own_addr);
247 msg_set_prevnode(msg, tipc_own_addr); 248 msg_set_prevnode(msg, tipc_own_addr);
248 msg_set_origport(msg, ref); 249 msg_set_origport(msg, ref);
@@ -413,13 +414,6 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
413 return buf; 414 return buf;
414} 415}
415 416
416int tipc_set_msg_option(struct tipc_port *tp_ptr, const char *opt, const u32 sz)
417{
418 msg_expand(&tp_ptr->phdr, msg_destnode(&tp_ptr->phdr));
419 msg_set_options(&tp_ptr->phdr, opt, sz);
420 return TIPC_OK;
421}
422
423int tipc_reject_msg(struct sk_buff *buf, u32 err) 417int tipc_reject_msg(struct sk_buff *buf, u32 err)
424{ 418{
425 struct tipc_msg *msg = buf_msg(buf); 419 struct tipc_msg *msg = buf_msg(buf);
@@ -632,7 +626,7 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
632 msg_orignode(msg), 626 msg_orignode(msg),
633 msg_destport(msg), 627 msg_destport(msg),
634 tipc_own_addr, 628 tipc_own_addr,
635 DATA_HIGH, 629 TIPC_HIGH_IMPORTANCE,
636 TIPC_CONN_MSG, 630 TIPC_CONN_MSG,
637 err, 631 err,
638 0, 632 0,
@@ -1246,6 +1240,28 @@ exit:
1246 return res; 1240 return res;
1247} 1241}
1248 1242
1243/**
1244 * tipc_disconnect_port - disconnect port from peer
1245 *
1246 * Port must be locked.
1247 */
1248
1249int tipc_disconnect_port(struct tipc_port *tp_ptr)
1250{
1251 int res;
1252
1253 if (tp_ptr->connected) {
1254 tp_ptr->connected = 0;
1255 /* let timer expire on it's own to avoid deadlock! */
1256 tipc_nodesub_unsubscribe(
1257 &((struct port *)tp_ptr)->subscription);
1258 res = TIPC_OK;
1259 } else {
1260 res = -ENOTCONN;
1261 }
1262 return res;
1263}
1264
1249/* 1265/*
1250 * tipc_disconnect(): Disconnect port form peer. 1266 * tipc_disconnect(): Disconnect port form peer.
1251 * This is a node local operation. 1267 * This is a node local operation.
@@ -1254,17 +1270,12 @@ exit:
1254int tipc_disconnect(u32 ref) 1270int tipc_disconnect(u32 ref)
1255{ 1271{
1256 struct port *p_ptr; 1272 struct port *p_ptr;
1257 int res = -ENOTCONN; 1273 int res;
1258 1274
1259 p_ptr = tipc_port_lock(ref); 1275 p_ptr = tipc_port_lock(ref);
1260 if (!p_ptr) 1276 if (!p_ptr)
1261 return -EINVAL; 1277 return -EINVAL;
1262 if (p_ptr->publ.connected) { 1278 res = tipc_disconnect_port((struct tipc_port *)p_ptr);
1263 p_ptr->publ.connected = 0;
1264 /* let timer expire on it's own to avoid deadlock! */
1265 tipc_nodesub_unsubscribe(&p_ptr->subscription);
1266 res = TIPC_OK;
1267 }
1268 tipc_port_unlock(p_ptr); 1279 tipc_port_unlock(p_ptr);
1269 return res; 1280 return res;
1270} 1281}