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.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}