Lines Matching refs:tsk
150 static int tipc_sk_publish(struct tipc_sock *tsk, struct tipc_uaddr *ua);
151 static int tipc_sk_withdraw(struct tipc_sock *tsk, struct tipc_uaddr *ua);
152 static int tipc_sk_leave(struct tipc_sock *tsk);
154 static int tipc_sk_insert(struct tipc_sock *tsk);
155 static void tipc_sk_remove(struct tipc_sock *tsk);
158 static void tipc_sk_push_backlog(struct tipc_sock *tsk, bool nagle_ack);
167 static u32 tsk_own_node(struct tipc_sock *tsk) in tsk_own_node() argument
169 return msg_prevnode(&tsk->phdr); in tsk_own_node()
172 static u32 tsk_peer_node(struct tipc_sock *tsk) in tsk_peer_node() argument
174 return msg_destnode(&tsk->phdr); in tsk_peer_node()
177 static u32 tsk_peer_port(struct tipc_sock *tsk) in tsk_peer_port() argument
179 return msg_destport(&tsk->phdr); in tsk_peer_port()
182 static bool tsk_unreliable(struct tipc_sock *tsk) in tsk_unreliable() argument
184 return msg_src_droppable(&tsk->phdr) != 0; in tsk_unreliable()
187 static void tsk_set_unreliable(struct tipc_sock *tsk, bool unreliable) in tsk_set_unreliable() argument
189 msg_set_src_droppable(&tsk->phdr, unreliable ? 1 : 0); in tsk_set_unreliable()
192 static bool tsk_unreturnable(struct tipc_sock *tsk) in tsk_unreturnable() argument
194 return msg_dest_droppable(&tsk->phdr) != 0; in tsk_unreturnable()
197 static void tsk_set_unreturnable(struct tipc_sock *tsk, bool unreturnable) in tsk_set_unreturnable() argument
199 msg_set_dest_droppable(&tsk->phdr, unreturnable ? 1 : 0); in tsk_set_unreturnable()
202 static int tsk_importance(struct tipc_sock *tsk) in tsk_importance() argument
204 return msg_importance(&tsk->phdr); in tsk_importance()
220 static bool tsk_conn_cong(struct tipc_sock *tsk) in tsk_conn_cong() argument
222 return tsk->snt_unacked > tsk->snd_win; in tsk_conn_cong()
243 static u16 tsk_inc(struct tipc_sock *tsk, int msglen) in tsk_inc() argument
245 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in tsk_inc()
252 static void tsk_set_nagle(struct tipc_sock *tsk) in tsk_set_nagle() argument
254 struct sock *sk = &tsk->sk; in tsk_set_nagle()
256 tsk->maxnagle = 0; in tsk_set_nagle()
259 if (tsk->nodelay) in tsk_set_nagle()
261 if (!(tsk->peer_caps & TIPC_NAGLE)) in tsk_set_nagle()
264 if (tsk->max_pkt == MAX_MSG_SIZE) in tsk_set_nagle()
265 tsk->maxnagle = 1500; in tsk_set_nagle()
267 tsk->maxnagle = tsk->max_pkt; in tsk_set_nagle()
334 static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) in tsk_peer_msg() argument
336 struct sock *sk = &tsk->sk; in tsk_peer_msg()
338 u32 peer_port = tsk_peer_port(tsk); in tsk_peer_msg()
348 peer_node = tsk_peer_node(tsk); in tsk_peer_msg()
463 struct tipc_sock *tsk; in tipc_sk_create() local
490 tsk = tipc_sk(sk); in tipc_sk_create()
491 tsk->max_pkt = MAX_PKT_DEFAULT; in tipc_sk_create()
492 tsk->maxnagle = 0; in tipc_sk_create()
493 tsk->nagle_start = NAGLE_START_INIT; in tipc_sk_create()
494 INIT_LIST_HEAD(&tsk->publications); in tipc_sk_create()
495 INIT_LIST_HEAD(&tsk->cong_links); in tipc_sk_create()
496 msg = &tsk->phdr; in tipc_sk_create()
502 if (tipc_sk_insert(tsk)) { in tipc_sk_create()
514 msg_set_origport(msg, tsk->portid); in tipc_sk_create()
522 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; in tipc_sk_create()
523 tsk->group_is_open = true; in tipc_sk_create()
524 atomic_set(&tsk->dupl_rcvcnt, 0); in tipc_sk_create()
527 tsk->snd_win = tsk_adv_blocks(RCVBUF_MIN); in tipc_sk_create()
528 tsk->rcv_win = tsk->snd_win; in tipc_sk_create()
531 tsk_set_unreturnable(tsk, true); in tipc_sk_create()
533 tsk_set_unreliable(tsk, true); in tipc_sk_create()
535 __skb_queue_head_init(&tsk->mc_method.deferredq); in tipc_sk_create()
542 struct tipc_sock *tsk = container_of(head, struct tipc_sock, rcu); in tipc_sk_callback() local
544 sock_put(&tsk->sk); in tipc_sk_callback()
551 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_shutdown() local
554 u32 dnode = tsk_peer_node(tsk); in __tipc_shutdown()
558 tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt && in __tipc_shutdown()
559 !tsk_conn_cong(tsk))); in __tipc_shutdown()
562 tipc_sk_push_backlog(tsk, false); in __tipc_shutdown()
583 tipc_node_remove_conn(net, dnode, tsk->portid); in __tipc_shutdown()
593 tsk_own_node(tsk), tsk_peer_port(tsk), in __tipc_shutdown()
594 tsk->portid, error); in __tipc_shutdown()
596 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); in __tipc_shutdown()
627 struct tipc_sock *tsk; in tipc_release() local
636 tsk = tipc_sk(sk); in tipc_release()
642 tipc_sk_leave(tsk); in tipc_release()
643 tipc_sk_withdraw(tsk, NULL); in tipc_release()
644 __skb_queue_purge(&tsk->mc_method.deferredq); in tipc_release()
646 tipc_sk_remove(tsk); in tipc_release()
651 tipc_dest_list_purge(&tsk->cong_links); in tipc_release()
652 tsk->cong_link_cnt = 0; in tipc_release()
653 call_rcu(&tsk->rcu, tipc_sk_callback); in tipc_release()
677 struct tipc_sock *tsk = tipc_sk(sock->sk); in __tipc_bind() local
681 return tipc_sk_withdraw(tsk, NULL); in __tipc_bind()
695 if (tsk->group) in __tipc_bind()
699 return tipc_sk_withdraw(tsk, ua); in __tipc_bind()
700 return tipc_sk_publish(tsk, ua); in __tipc_bind()
749 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getname() local
756 addr->addr.id.ref = tsk_peer_port(tsk); in tipc_getname()
757 addr->addr.id.node = tsk_peer_node(tsk); in tipc_getname()
759 addr->addr.id.ref = tsk->portid; in tipc_getname()
793 struct tipc_sock *tsk = tipc_sk(sk); in tipc_poll() local
806 if (!tsk->cong_link_cnt && !tsk_conn_cong(tsk)) in tipc_poll()
815 if (tsk->group_is_open && !tsk->cong_link_cnt) in tipc_poll()
845 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sendmcast() local
846 struct tipc_msg *hdr = &tsk->phdr; in tipc_sendmcast()
853 if (tsk->group) in tipc_sendmcast()
857 rc = tipc_wait_for_cond(sock, &timeout, !tsk->cong_link_cnt); in tipc_sendmcast()
885 rc = tipc_mcast_xmit(net, &pkts, &tsk->mc_method, &dsts, in tipc_sendmcast()
886 &tsk->cong_link_cnt); in tipc_sendmcast()
904 static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, in tipc_send_group_msg() argument
908 u16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group); in tipc_send_group_msg()
909 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_msg()
911 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_msg()
924 mtu = tipc_node_get_mtu(net, dnode, tsk->portid, false); in tipc_send_group_msg()
930 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in tipc_send_group_msg()
932 tipc_dest_push(&tsk->cong_links, dnode, 0); in tipc_send_group_msg()
933 tsk->cong_link_cnt++; in tipc_send_group_msg()
961 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_unicast() local
974 !tipc_dest_find(&tsk->cong_links, node, 0) && in tipc_send_group_unicast()
975 tsk->group && in tipc_send_group_unicast()
976 !tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_unicast()
984 rc = tipc_send_group_msg(net, tsk, m, mb, node, port, dlen); in tipc_send_group_unicast()
1004 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_anycast() local
1005 struct list_head *cong_links = &tsk->cong_links; in tipc_send_group_anycast()
1007 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_anycast()
1021 exclude = tipc_group_exclude(tsk->group); in tipc_send_group_anycast()
1031 cong = tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_anycast()
1051 tsk->group && in tipc_send_group_anycast()
1052 !tipc_group_cong(tsk->group, node, port, in tipc_send_group_anycast()
1065 rc = tipc_send_group_msg(net, tsk, m, mbr, node, port, dlen); in tipc_send_group_anycast()
1086 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_bcast() local
1088 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_bcast()
1091 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_bcast()
1098 !tsk->cong_link_cnt && tsk->group && in tipc_send_group_bcast()
1099 !tipc_group_bc_cong(tsk->group, blks)); in tipc_send_group_bcast()
1103 dsts = tipc_group_dests(tsk->group); in tipc_send_group_bcast()
1118 msg_set_grp_bc_seqno(hdr, tipc_group_bc_snd_nxt(tsk->group)); in tipc_send_group_bcast()
1130 rc = tipc_mcast_xmit(net, &pkts, method, dsts, &tsk->cong_link_cnt); in tipc_send_group_bcast()
1135 tipc_group_update_bc_members(tsk->group, blks, ack); in tipc_send_group_bcast()
1159 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_mcast() local
1160 struct tipc_group *grp = tsk->group; in tipc_send_group_mcast()
1161 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_mcast()
1270 static void tipc_sk_push_backlog(struct tipc_sock *tsk, bool nagle_ack) in tipc_sk_push_backlog() argument
1272 struct sk_buff_head *txq = &tsk->sk.sk_write_queue; in tipc_sk_push_backlog()
1274 struct net *net = sock_net(&tsk->sk); in tipc_sk_push_backlog()
1275 u32 dnode = tsk_peer_node(tsk); in tipc_sk_push_backlog()
1279 tsk->pkt_cnt += skb_queue_len(txq); in tipc_sk_push_backlog()
1280 if (!tsk->pkt_cnt || tsk->msg_acc / tsk->pkt_cnt < 2) { in tipc_sk_push_backlog()
1281 tsk->oneway = 0; in tipc_sk_push_backlog()
1282 if (tsk->nagle_start < NAGLE_START_MAX) in tipc_sk_push_backlog()
1283 tsk->nagle_start *= 2; in tipc_sk_push_backlog()
1284 tsk->expect_ack = false; in tipc_sk_push_backlog()
1286 tsk->portid, tsk->msg_acc, tsk->pkt_cnt, in tipc_sk_push_backlog()
1287 tsk->nagle_start); in tipc_sk_push_backlog()
1289 tsk->nagle_start = NAGLE_START_INIT; in tipc_sk_push_backlog()
1292 tsk->expect_ack = true; in tipc_sk_push_backlog()
1294 tsk->expect_ack = false; in tipc_sk_push_backlog()
1297 tsk->msg_acc = 0; in tipc_sk_push_backlog()
1298 tsk->pkt_cnt = 0; in tipc_sk_push_backlog()
1301 if (!skb || tsk->cong_link_cnt) in tipc_sk_push_backlog()
1308 if (tsk->msg_acc) in tipc_sk_push_backlog()
1309 tsk->pkt_cnt += skb_queue_len(txq); in tipc_sk_push_backlog()
1310 tsk->snt_unacked += tsk->snd_backlog; in tipc_sk_push_backlog()
1311 tsk->snd_backlog = 0; in tipc_sk_push_backlog()
1312 rc = tipc_node_xmit(net, txq, dnode, tsk->portid); in tipc_sk_push_backlog()
1314 tsk->cong_link_cnt = 1; in tipc_sk_push_backlog()
1324 static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb, in tipc_sk_conn_proto_rcv() argument
1329 u32 onode = tsk_own_node(tsk); in tipc_sk_conn_proto_rcv()
1330 struct sock *sk = &tsk->sk; in tipc_sk_conn_proto_rcv()
1335 if (!tsk_peer_msg(tsk, hdr)) { in tipc_sk_conn_proto_rcv()
1342 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk), in tipc_sk_conn_proto_rcv()
1343 tsk_peer_port(tsk)); in tipc_sk_conn_proto_rcv()
1357 tsk->probe_unacked = false; in tipc_sk_conn_proto_rcv()
1365 was_cong = tsk_conn_cong(tsk); in tipc_sk_conn_proto_rcv()
1366 tipc_sk_push_backlog(tsk, msg_nagle_ack(hdr)); in tipc_sk_conn_proto_rcv()
1367 tsk->snt_unacked -= msg_conn_ack(hdr); in tipc_sk_conn_proto_rcv()
1368 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_conn_proto_rcv()
1369 tsk->snd_win = msg_adv_win(hdr); in tipc_sk_conn_proto_rcv()
1370 if (was_cong && !tsk_conn_cong(tsk)) in tipc_sk_conn_proto_rcv()
1409 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendmsg() local
1412 struct list_head *clinks = &tsk->cong_links; in __tipc_sendmsg()
1414 struct tipc_group *grp = tsk->group; in __tipc_sendmsg()
1415 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendmsg()
1443 ua = (struct tipc_uaddr *)&tsk->peer; in __tipc_sendmsg()
1454 if (tsk->published) in __tipc_sendmsg()
1457 tsk->conn_addrtype = atype; in __tipc_sendmsg()
1500 mtu = tipc_node_get_mtu(net, skaddr.node, tsk->portid, true); in __tipc_sendmsg()
1511 rc = tipc_node_xmit(net, &pkts, skaddr.node, tsk->portid); in __tipc_sendmsg()
1514 tsk->cong_link_cnt++; in __tipc_sendmsg()
1558 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendstream() local
1559 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendstream()
1562 u32 dnode = tsk_peer_node(tsk); in __tipc_sendstream()
1563 int maxnagle = tsk->maxnagle; in __tipc_sendstream()
1564 int maxpkt = tsk->max_pkt; in __tipc_sendstream()
1575 tsk->peer_caps = tipc_node_get_capabilities(net, dnode); in __tipc_sendstream()
1576 tsk->snt_unacked = tsk_inc(tsk, dlen + msg_hdr_sz(hdr)); in __tipc_sendstream()
1583 (!tsk->cong_link_cnt && in __tipc_sendstream()
1584 !tsk_conn_cong(tsk) && in __tipc_sendstream()
1589 blocks = tsk->snd_backlog; in __tipc_sendstream()
1590 if (tsk->oneway++ >= tsk->nagle_start && maxnagle && in __tipc_sendstream()
1596 tsk->msg_acc++; in __tipc_sendstream()
1597 if (blocks <= 64 && tsk->expect_ack) { in __tipc_sendstream()
1598 tsk->snd_backlog = blocks; in __tipc_sendstream()
1602 tsk->pkt_cnt += skb_queue_len(txq); in __tipc_sendstream()
1607 tsk->expect_ack = true; in __tipc_sendstream()
1609 tsk->expect_ack = false; in __tipc_sendstream()
1611 tsk->msg_acc = 0; in __tipc_sendstream()
1612 tsk->pkt_cnt = 0; in __tipc_sendstream()
1618 blocks += tsk_inc(tsk, send + MIN_H_SIZE); in __tipc_sendstream()
1622 rc = tipc_node_xmit(net, txq, dnode, tsk->portid); in __tipc_sendstream()
1624 tsk->cong_link_cnt = 1; in __tipc_sendstream()
1628 tsk->snt_unacked += blocks; in __tipc_sendstream()
1629 tsk->snd_backlog = 0; in __tipc_sendstream()
1657 static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, in tipc_sk_finish_conn() argument
1660 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1662 struct tipc_msg *msg = &tsk->phdr; in tipc_sk_finish_conn()
1673 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); in tipc_sk_finish_conn()
1674 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid, true); in tipc_sk_finish_conn()
1675 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node); in tipc_sk_finish_conn()
1676 tsk_set_nagle(tsk); in tipc_sk_finish_conn()
1678 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_finish_conn()
1682 tsk->rcv_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1683 tsk->snd_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1733 struct tipc_sock *tsk) in tipc_sk_anc_data_recv() argument
1776 has_addr = !!tsk->conn_addrtype; in tipc_sk_anc_data_recv()
1777 data[0] = msg_nametype(&tsk->phdr); in tipc_sk_anc_data_recv()
1778 data[1] = msg_nameinst(&tsk->phdr); in tipc_sk_anc_data_recv()
1789 static struct sk_buff *tipc_sk_build_ack(struct tipc_sock *tsk) in tipc_sk_build_ack() argument
1791 struct sock *sk = &tsk->sk; in tipc_sk_build_ack()
1794 u32 peer_port = tsk_peer_port(tsk); in tipc_sk_build_ack()
1795 u32 dnode = tsk_peer_node(tsk); in tipc_sk_build_ack()
1800 dnode, tsk_own_node(tsk), peer_port, in tipc_sk_build_ack()
1801 tsk->portid, TIPC_OK); in tipc_sk_build_ack()
1805 msg_set_conn_ack(msg, tsk->rcv_unacked); in tipc_sk_build_ack()
1806 tsk->rcv_unacked = 0; in tipc_sk_build_ack()
1809 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) { in tipc_sk_build_ack()
1810 tsk->rcv_win = tsk_adv_blocks(tsk->sk.sk_rcvbuf); in tipc_sk_build_ack()
1811 msg_set_adv_win(msg, tsk->rcv_win); in tipc_sk_build_ack()
1816 static void tipc_sk_send_ack(struct tipc_sock *tsk) in tipc_sk_send_ack() argument
1820 skb = tipc_sk_build_ack(tsk); in tipc_sk_send_ack()
1824 tipc_node_xmit_skb(sock_net(&tsk->sk), skb, tsk_peer_node(tsk), in tipc_sk_send_ack()
1886 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvmsg() local
1925 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvmsg()
1973 if (tsk->group && msg_in_group(hdr) && !grp_evt) { in tipc_recvmsg()
1975 tipc_group_update_rcv_win(tsk->group, tsk_blocks(hlen + dlen), in tipc_recvmsg()
1990 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvmsg()
1991 if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE) in tipc_recvmsg()
1992 tipc_sk_send_ack(tsk); in tipc_recvmsg()
2014 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvstream() local
2057 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvstream()
2091 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvstream()
2092 if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE) in tipc_recvstream()
2093 tipc_sk_send_ack(tsk); in tipc_recvstream()
2149 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_proto_rcv() local
2151 struct tipc_group *grp = tsk->group; in tipc_sk_proto_rcv()
2156 tipc_sk_conn_proto_rcv(tsk, skb, inputq, xmitq); in tipc_sk_proto_rcv()
2159 tipc_dest_del(&tsk->cong_links, msg_orignode(hdr), 0); in tipc_sk_proto_rcv()
2162 tsk->cong_link_cnt--; in tipc_sk_proto_rcv()
2164 tipc_sk_push_backlog(tsk, false); in tipc_sk_proto_rcv()
2170 tipc_group_member_evt(tsk->group, &wakeup, &sk->sk_rcvbuf, in tipc_sk_proto_rcv()
2190 static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, in tipc_sk_filter_connect() argument
2193 struct sock *sk = &tsk->sk; in tipc_sk_filter_connect()
2197 u32 pport = tsk_peer_port(tsk); in tipc_sk_filter_connect()
2198 u32 pnode = tsk_peer_node(tsk); in tipc_sk_filter_connect()
2206 tsk->oneway = 0; in tipc_sk_filter_connect()
2214 tipc_sk_finish_conn(tsk, oport, onode); in tipc_sk_filter_connect()
2215 msg_set_importance(&tsk->phdr, msg_importance(hdr)); in tipc_sk_filter_connect()
2236 delay %= (tsk->conn_timeout / 4); in tipc_sk_filter_connect()
2253 tipc_sk_push_backlog(tsk, false); in tipc_sk_filter_connect()
2260 skb = tipc_sk_build_ack(tsk); in tipc_sk_filter_connect()
2268 if (!tsk_peer_msg(tsk, hdr)) in tipc_sk_filter_connect()
2273 tipc_node_remove_conn(net, pnode, tsk->portid); in tipc_sk_filter_connect()
2306 struct tipc_sock *tsk = tipc_sk(sk); in rcvbuf_limit() local
2315 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in rcvbuf_limit()
2336 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_filter_rcv() local
2337 struct tipc_group *grp = tsk->group; in tipc_sk_filter_rcv()
2356 tipc_mcast_filter_msg(net, &tsk->mc_method.deferredq, &inputq); in tipc_sk_filter_rcv()
2362 if ((sk_conn && !tipc_sk_filter_connect(tsk, skb, xmitq)) || in tipc_sk_filter_rcv()
2483 struct tipc_sock *tsk; in tipc_sk_rcv() local
2490 tsk = tipc_sk_lookup(net, dport); in tipc_sk_rcv()
2492 if (likely(tsk)) { in tipc_sk_rcv()
2493 sk = &tsk->sk; in tipc_sk_rcv()
2572 struct tipc_sock *tsk = tipc_sk(sk); in tipc_connect() local
2575 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; in tipc_connect()
2584 if (tsk->group) { in tipc_connect()
2590 memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc)); in tipc_connect()
2601 memcpy(&tsk->peer, dest, destlen); in tipc_connect()
2826 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_check_probing_state() local
2827 u32 pnode = tsk_peer_node(tsk); in tipc_sk_check_probing_state()
2828 u32 pport = tsk_peer_port(tsk); in tipc_sk_check_probing_state()
2829 u32 self = tsk_own_node(tsk); in tipc_sk_check_probing_state()
2830 u32 oport = tsk->portid; in tipc_sk_check_probing_state()
2833 if (tsk->probe_unacked) { in tipc_sk_check_probing_state()
2845 tsk->probe_unacked = true; in tipc_sk_check_probing_state()
2851 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_retry_connect() local
2854 if (tsk->cong_link_cnt) { in tipc_sk_retry_connect()
2866 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_timeout() local
2867 u32 pnode = tsk_peer_node(tsk); in tipc_sk_timeout()
2890 rc = tipc_node_xmit(sock_net(sk), &list, pnode, tsk->portid); in tipc_sk_timeout()
2894 tipc_dest_push(&tsk->cong_links, pnode, 0); in tipc_sk_timeout()
2895 tsk->cong_link_cnt = 1; in tipc_sk_timeout()
2900 static int tipc_sk_publish(struct tipc_sock *tsk, struct tipc_uaddr *ua) in tipc_sk_publish() argument
2902 struct sock *sk = &tsk->sk; in tipc_sk_publish()
2910 key = tsk->portid + tsk->pub_count + 1; in tipc_sk_publish()
2911 if (key == tsk->portid) in tipc_sk_publish()
2913 skaddr.ref = tsk->portid; in tipc_sk_publish()
2919 list_add(&p->binding_sock, &tsk->publications); in tipc_sk_publish()
2920 tsk->pub_count++; in tipc_sk_publish()
2921 tsk->published = true; in tipc_sk_publish()
2925 static int tipc_sk_withdraw(struct tipc_sock *tsk, struct tipc_uaddr *ua) in tipc_sk_withdraw() argument
2927 struct net *net = sock_net(&tsk->sk); in tipc_sk_withdraw()
2932 list_for_each_entry_safe(p, safe, &tsk->publications, binding_sock) { in tipc_sk_withdraw()
2952 if (list_empty(&tsk->publications)) { in tipc_sk_withdraw()
2953 tsk->published = 0; in tipc_sk_withdraw()
2966 struct tipc_sock *tsk; in tipc_sk_reinit() local
2974 while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) { in tipc_sk_reinit()
2975 sock_hold(&tsk->sk); in tipc_sk_reinit()
2977 lock_sock(&tsk->sk); in tipc_sk_reinit()
2978 msg = &tsk->phdr; in tipc_sk_reinit()
2981 release_sock(&tsk->sk); in tipc_sk_reinit()
2983 sock_put(&tsk->sk); in tipc_sk_reinit()
2987 } while (tsk == ERR_PTR(-EAGAIN)); in tipc_sk_reinit()
2995 struct tipc_sock *tsk; in tipc_sk_lookup() local
2998 tsk = rhashtable_lookup(&tn->sk_rht, &portid, tsk_rht_params); in tipc_sk_lookup()
2999 if (tsk) in tipc_sk_lookup()
3000 sock_hold(&tsk->sk); in tipc_sk_lookup()
3003 return tsk; in tipc_sk_lookup()
3006 static int tipc_sk_insert(struct tipc_sock *tsk) in tipc_sk_insert() argument
3008 struct sock *sk = &tsk->sk; in tipc_sk_insert()
3018 tsk->portid = portid; in tipc_sk_insert()
3019 sock_hold(&tsk->sk); in tipc_sk_insert()
3020 if (!rhashtable_lookup_insert_fast(&tn->sk_rht, &tsk->node, in tipc_sk_insert()
3023 sock_put(&tsk->sk); in tipc_sk_insert()
3029 static void tipc_sk_remove(struct tipc_sock *tsk) in tipc_sk_remove() argument
3031 struct sock *sk = &tsk->sk; in tipc_sk_remove()
3034 if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { in tipc_sk_remove()
3067 static int tipc_sk_join(struct tipc_sock *tsk, struct tipc_group_req *mreq) in tipc_sk_join() argument
3069 struct net *net = sock_net(&tsk->sk); in tipc_sk_join()
3070 struct tipc_group *grp = tsk->group; in tipc_sk_join()
3071 struct tipc_msg *hdr = &tsk->phdr; in tipc_sk_join()
3083 grp = tipc_group_create(net, tsk->portid, mreq, &tsk->group_is_open); in tipc_sk_join()
3086 tsk->group = grp; in tipc_sk_join()
3093 rc = tipc_sk_publish(tsk, &ua); in tipc_sk_join()
3096 tsk->group = NULL; in tipc_sk_join()
3100 tsk->mc_method.rcast = true; in tipc_sk_join()
3101 tsk->mc_method.mandatory = true; in tipc_sk_join()
3102 tipc_group_join(net, grp, &tsk->sk.sk_rcvbuf); in tipc_sk_join()
3106 static int tipc_sk_leave(struct tipc_sock *tsk) in tipc_sk_leave() argument
3108 struct net *net = sock_net(&tsk->sk); in tipc_sk_leave()
3109 struct tipc_group *grp = tsk->group; in tipc_sk_leave()
3119 tsk->group = NULL; in tipc_sk_leave()
3120 tipc_sk_withdraw(tsk, &ua); in tipc_sk_leave()
3141 struct tipc_sock *tsk = tipc_sk(sk); in tipc_setsockopt() local
3181 tsk_set_unreliable(tsk, value); in tipc_setsockopt()
3186 tsk_set_unreturnable(tsk, value); in tipc_setsockopt()
3192 tsk->mc_method.rcast = false; in tipc_setsockopt()
3193 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3196 tsk->mc_method.rcast = true; in tipc_setsockopt()
3197 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3200 res = tipc_sk_join(tsk, &mreq); in tipc_setsockopt()
3203 res = tipc_sk_leave(tsk); in tipc_setsockopt()
3206 tsk->nodelay = !!value; in tipc_setsockopt()
3207 tsk_set_nagle(tsk); in tipc_setsockopt()
3235 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getsockopt() local
3253 value = tsk_importance(tsk); in tipc_getsockopt()
3256 value = tsk_unreliable(tsk); in tipc_getsockopt()
3259 value = tsk_unreturnable(tsk); in tipc_getsockopt()
3262 value = tsk->conn_timeout; in tipc_getsockopt()
3276 if (tsk->group) in tipc_getsockopt()
3277 tipc_group_self(tsk->group, &seq, &scope); in tipc_getsockopt()
3462 static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) in __tipc_nl_add_sk_con() argument
3468 peer_node = tsk_peer_node(tsk); in __tipc_nl_add_sk_con()
3469 peer_port = tsk_peer_port(tsk); in __tipc_nl_add_sk_con()
3470 conn_type = msg_nametype(&tsk->phdr); in __tipc_nl_add_sk_con()
3471 conn_instance = msg_nameinst(&tsk->phdr); in __tipc_nl_add_sk_con()
3481 if (tsk->conn_addrtype != 0) { in __tipc_nl_add_sk_con()
3500 *tsk) in __tipc_nl_add_sk_info()
3503 struct sock *sk = &tsk->sk; in __tipc_nl_add_sk_info()
3505 if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid) || in __tipc_nl_add_sk_info()
3510 if (__tipc_nl_add_sk_con(skb, tsk)) in __tipc_nl_add_sk_info()
3512 } else if (!list_empty(&tsk->publications)) { in __tipc_nl_add_sk_info()
3521 struct tipc_sock *tsk) in __tipc_nl_add_sk() argument
3535 if (__tipc_nl_add_sk_info(skb, tsk)) in __tipc_nl_add_sk()
3554 struct tipc_sock *tsk)) in tipc_nl_sk_walk() argument
3557 struct tipc_sock *tsk; in tipc_nl_sk_walk() local
3561 while ((tsk = rhashtable_walk_next(iter)) != NULL) { in tipc_nl_sk_walk()
3562 if (IS_ERR(tsk)) { in tipc_nl_sk_walk()
3563 if (PTR_ERR(tsk) == -EAGAIN) in tipc_nl_sk_walk()
3568 sock_hold(&tsk->sk); in tipc_nl_sk_walk()
3570 lock_sock(&tsk->sk); in tipc_nl_sk_walk()
3571 err = skb_handler(skb, cb, tsk); in tipc_nl_sk_walk()
3573 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3574 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3577 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3579 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3622 struct tipc_sock *tsk, u32 sk_filter_state, in tipc_sk_fill_sock_diag() argument
3625 struct sock *sk = &tsk->sk; in tipc_sk_fill_sock_diag()
3637 if (__tipc_nl_add_sk_info(skb, tsk)) in tipc_sk_fill_sock_diag()
3663 if (tsk->cong_link_cnt && in tipc_sk_fill_sock_diag()
3667 if (tsk_conn_cong(tsk) && in tipc_sk_fill_sock_diag()
3673 if (tsk->group) in tipc_sk_fill_sock_diag()
3674 if (tipc_group_fill_sock_diag(tsk->group, skb)) in tipc_sk_fill_sock_diag()
3737 struct tipc_sock *tsk, u32 *last_publ) in __tipc_nl_list_sk_publ() argument
3743 list_for_each_entry(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3747 if (list_entry_is_head(p, &tsk->publications, binding_sock)) { in __tipc_nl_list_sk_publ()
3759 p = list_first_entry(&tsk->publications, struct publication, in __tipc_nl_list_sk_publ()
3763 list_for_each_entry_from(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3782 struct tipc_sock *tsk; in tipc_nl_publ_dump() local
3806 tsk = tipc_sk_lookup(net, tsk_portid); in tipc_nl_publ_dump()
3807 if (!tsk) in tipc_nl_publ_dump()
3810 lock_sock(&tsk->sk); in tipc_nl_publ_dump()
3811 err = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ); in tipc_nl_publ_dump()
3814 release_sock(&tsk->sk); in tipc_nl_publ_dump()
3815 sock_put(&tsk->sk); in tipc_nl_publ_dump()
3837 struct tipc_sock *tsk; in tipc_sk_filtering() local
3845 tsk = tipc_sk(sk); in tipc_sk_filtering()
3857 return (_port == tsk->portid); in tipc_sk_filtering()
3862 if (tsk->published) { in tipc_sk_filtering()
3863 p = list_first_entry_or_null(&tsk->publications, in tipc_sk_filtering()
3873 type = msg_nametype(&tsk->phdr); in tipc_sk_filtering()
3874 lower = msg_nameinst(&tsk->phdr); in tipc_sk_filtering()
3941 struct tipc_sock *tsk; in tipc_sk_dump() local
3950 tsk = tipc_sk(sk); in tipc_sk_dump()
3955 i += scnprintf(buf + i, sz - i, " %x", tsk_own_node(tsk)); in tipc_sk_dump()
3956 i += scnprintf(buf + i, sz - i, " %u", tsk->portid); in tipc_sk_dump()
3959 i += scnprintf(buf + i, sz - i, " %x", tsk_peer_node(tsk)); in tipc_sk_dump()
3960 i += scnprintf(buf + i, sz - i, " %u", tsk_peer_port(tsk)); in tipc_sk_dump()
3961 conn_type = msg_nametype(&tsk->phdr); in tipc_sk_dump()
3962 conn_instance = msg_nameinst(&tsk->phdr); in tipc_sk_dump()
3966 i += scnprintf(buf + i, sz - i, " | %u", tsk->published); in tipc_sk_dump()
3967 if (tsk->published) { in tipc_sk_dump()
3968 p = list_first_entry_or_null(&tsk->publications, in tipc_sk_dump()
3974 i += scnprintf(buf + i, sz - i, " | %u", tsk->snd_win); in tipc_sk_dump()
3975 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_win); in tipc_sk_dump()
3976 i += scnprintf(buf + i, sz - i, " %u", tsk->max_pkt); in tipc_sk_dump()
3977 i += scnprintf(buf + i, sz - i, " %x", tsk->peer_caps); in tipc_sk_dump()
3978 i += scnprintf(buf + i, sz - i, " %u", tsk->cong_link_cnt); in tipc_sk_dump()
3979 i += scnprintf(buf + i, sz - i, " %u", tsk->snt_unacked); in tipc_sk_dump()
3980 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_unacked); in tipc_sk_dump()
3981 i += scnprintf(buf + i, sz - i, " %u", atomic_read(&tsk->dupl_rcvcnt)); in tipc_sk_dump()