Lines Matching refs:tsk

140 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope,
142 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope,
144 static int tipc_sk_leave(struct tipc_sock *tsk);
146 static int tipc_sk_insert(struct tipc_sock *tsk);
147 static void tipc_sk_remove(struct tipc_sock *tsk);
150 static void tipc_sk_push_backlog(struct tipc_sock *tsk, bool nagle_ack);
158 static u32 tsk_own_node(struct tipc_sock *tsk) in tsk_own_node() argument
160 return msg_prevnode(&tsk->phdr); in tsk_own_node()
163 static u32 tsk_peer_node(struct tipc_sock *tsk) in tsk_peer_node() argument
165 return msg_destnode(&tsk->phdr); in tsk_peer_node()
168 static u32 tsk_peer_port(struct tipc_sock *tsk) in tsk_peer_port() argument
170 return msg_destport(&tsk->phdr); in tsk_peer_port()
173 static bool tsk_unreliable(struct tipc_sock *tsk) in tsk_unreliable() argument
175 return msg_src_droppable(&tsk->phdr) != 0; in tsk_unreliable()
178 static void tsk_set_unreliable(struct tipc_sock *tsk, bool unreliable) in tsk_set_unreliable() argument
180 msg_set_src_droppable(&tsk->phdr, unreliable ? 1 : 0); in tsk_set_unreliable()
183 static bool tsk_unreturnable(struct tipc_sock *tsk) in tsk_unreturnable() argument
185 return msg_dest_droppable(&tsk->phdr) != 0; in tsk_unreturnable()
188 static void tsk_set_unreturnable(struct tipc_sock *tsk, bool unreturnable) in tsk_set_unreturnable() argument
190 msg_set_dest_droppable(&tsk->phdr, unreturnable ? 1 : 0); in tsk_set_unreturnable()
193 static int tsk_importance(struct tipc_sock *tsk) in tsk_importance() argument
195 return msg_importance(&tsk->phdr); in tsk_importance()
211 static bool tsk_conn_cong(struct tipc_sock *tsk) in tsk_conn_cong() argument
213 return tsk->snt_unacked > tsk->snd_win; in tsk_conn_cong()
234 static u16 tsk_inc(struct tipc_sock *tsk, int msglen) in tsk_inc() argument
236 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in tsk_inc()
243 static void tsk_set_nagle(struct tipc_sock *tsk) in tsk_set_nagle() argument
245 struct sock *sk = &tsk->sk; in tsk_set_nagle()
247 tsk->maxnagle = 0; in tsk_set_nagle()
250 if (tsk->nodelay) in tsk_set_nagle()
252 if (!(tsk->peer_caps & TIPC_NAGLE)) in tsk_set_nagle()
255 if (tsk->max_pkt == MAX_MSG_SIZE) in tsk_set_nagle()
256 tsk->maxnagle = 1500; in tsk_set_nagle()
258 tsk->maxnagle = tsk->max_pkt; in tsk_set_nagle()
322 static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) in tsk_peer_msg() argument
324 struct sock *sk = &tsk->sk; in tsk_peer_msg()
326 u32 peer_port = tsk_peer_port(tsk); in tsk_peer_msg()
336 peer_node = tsk_peer_node(tsk); in tsk_peer_msg()
451 struct tipc_sock *tsk; in tipc_sk_create() local
478 tsk = tipc_sk(sk); in tipc_sk_create()
479 tsk->max_pkt = MAX_PKT_DEFAULT; in tipc_sk_create()
480 tsk->maxnagle = 0; in tipc_sk_create()
481 tsk->nagle_start = NAGLE_START_INIT; in tipc_sk_create()
482 INIT_LIST_HEAD(&tsk->publications); in tipc_sk_create()
483 INIT_LIST_HEAD(&tsk->cong_links); in tipc_sk_create()
484 msg = &tsk->phdr; in tipc_sk_create()
490 if (tipc_sk_insert(tsk)) { in tipc_sk_create()
501 msg_set_origport(msg, tsk->portid); in tipc_sk_create()
509 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; in tipc_sk_create()
510 tsk->group_is_open = true; in tipc_sk_create()
511 atomic_set(&tsk->dupl_rcvcnt, 0); in tipc_sk_create()
514 tsk->snd_win = tsk_adv_blocks(RCVBUF_MIN); in tipc_sk_create()
515 tsk->rcv_win = tsk->snd_win; in tipc_sk_create()
518 tsk_set_unreturnable(tsk, true); in tipc_sk_create()
520 tsk_set_unreliable(tsk, true); in tipc_sk_create()
522 __skb_queue_head_init(&tsk->mc_method.deferredq); in tipc_sk_create()
529 struct tipc_sock *tsk = container_of(head, struct tipc_sock, rcu); in tipc_sk_callback() local
531 sock_put(&tsk->sk); in tipc_sk_callback()
538 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_shutdown() local
541 u32 dnode = tsk_peer_node(tsk); in __tipc_shutdown()
545 tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt && in __tipc_shutdown()
546 !tsk_conn_cong(tsk))); in __tipc_shutdown()
549 tipc_sk_push_backlog(tsk, false); in __tipc_shutdown()
570 tipc_node_remove_conn(net, dnode, tsk->portid); in __tipc_shutdown()
580 tsk_own_node(tsk), tsk_peer_port(tsk), in __tipc_shutdown()
581 tsk->portid, error); in __tipc_shutdown()
583 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); in __tipc_shutdown()
614 struct tipc_sock *tsk; in tipc_release() local
623 tsk = tipc_sk(sk); in tipc_release()
629 tipc_sk_leave(tsk); in tipc_release()
630 tipc_sk_withdraw(tsk, 0, NULL); in tipc_release()
631 __skb_queue_purge(&tsk->mc_method.deferredq); in tipc_release()
633 tipc_sk_remove(tsk); in tipc_release()
638 tipc_dest_list_purge(&tsk->cong_links); in tipc_release()
639 tsk->cong_link_cnt = 0; in tipc_release()
640 call_rcu(&tsk->rcu, tipc_sk_callback); in tipc_release()
666 struct tipc_sock *tsk = tipc_sk(sk); in tipc_bind() local
671 res = tipc_sk_withdraw(tsk, 0, NULL); in tipc_bind()
674 if (tsk->group) { in tipc_bind()
702 tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : in tipc_bind()
703 tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); in tipc_bind()
726 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getname() local
733 addr->addr.id.ref = tsk_peer_port(tsk); in tipc_getname()
734 addr->addr.id.node = tsk_peer_node(tsk); in tipc_getname()
736 addr->addr.id.ref = tsk->portid; in tipc_getname()
770 struct tipc_sock *tsk = tipc_sk(sk); in tipc_poll() local
783 if (!tsk->cong_link_cnt && !tsk_conn_cong(tsk)) in tipc_poll()
792 if (tsk->group_is_open && !tsk->cong_link_cnt) in tipc_poll()
822 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sendmcast() local
823 struct tipc_msg *hdr = &tsk->phdr; in tipc_sendmcast()
826 struct tipc_mc_method *method = &tsk->mc_method; in tipc_sendmcast()
831 if (tsk->group) in tipc_sendmcast()
835 rc = tipc_wait_for_cond(sock, &timeout, !tsk->cong_link_cnt); in tipc_sendmcast()
865 &tsk->cong_link_cnt); in tipc_sendmcast()
882 static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, in tipc_send_group_msg() argument
886 u16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group); in tipc_send_group_msg()
887 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_msg()
889 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_msg()
902 mtu = tipc_node_get_mtu(net, dnode, tsk->portid, false); in tipc_send_group_msg()
908 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in tipc_send_group_msg()
910 tipc_dest_push(&tsk->cong_links, dnode, 0); in tipc_send_group_msg()
911 tsk->cong_link_cnt++; in tipc_send_group_msg()
939 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_unicast() local
952 !tipc_dest_find(&tsk->cong_links, node, 0) && in tipc_send_group_unicast()
953 tsk->group && in tipc_send_group_unicast()
954 !tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_unicast()
962 rc = tipc_send_group_msg(net, tsk, m, mb, node, port, dlen); in tipc_send_group_unicast()
982 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_anycast() local
983 struct list_head *cong_links = &tsk->cong_links; in tipc_send_group_anycast()
985 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_anycast()
1003 exclude = tipc_group_exclude(tsk->group); in tipc_send_group_anycast()
1013 cong = tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_anycast()
1033 tsk->group && in tipc_send_group_anycast()
1034 !tipc_group_cong(tsk->group, node, port, in tipc_send_group_anycast()
1047 rc = tipc_send_group_msg(net, tsk, m, mbr, node, port, dlen); in tipc_send_group_anycast()
1068 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_bcast() local
1070 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_bcast()
1073 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_bcast()
1080 !tsk->cong_link_cnt && tsk->group && in tipc_send_group_bcast()
1081 !tipc_group_bc_cong(tsk->group, blks)); in tipc_send_group_bcast()
1085 dsts = tipc_group_dests(tsk->group); in tipc_send_group_bcast()
1100 msg_set_grp_bc_seqno(hdr, tipc_group_bc_snd_nxt(tsk->group)); in tipc_send_group_bcast()
1112 rc = tipc_mcast_xmit(net, &pkts, method, dsts, &tsk->cong_link_cnt); in tipc_send_group_bcast()
1117 tipc_group_update_bc_members(tsk->group, blks, ack); in tipc_send_group_bcast()
1141 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_mcast() local
1142 struct tipc_group *grp = tsk->group; in tipc_send_group_mcast()
1143 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_mcast()
1259 static void tipc_sk_push_backlog(struct tipc_sock *tsk, bool nagle_ack) in tipc_sk_push_backlog() argument
1261 struct sk_buff_head *txq = &tsk->sk.sk_write_queue; in tipc_sk_push_backlog()
1263 struct net *net = sock_net(&tsk->sk); in tipc_sk_push_backlog()
1264 u32 dnode = tsk_peer_node(tsk); in tipc_sk_push_backlog()
1268 tsk->pkt_cnt += skb_queue_len(txq); in tipc_sk_push_backlog()
1269 if (!tsk->pkt_cnt || tsk->msg_acc / tsk->pkt_cnt < 2) { in tipc_sk_push_backlog()
1270 tsk->oneway = 0; in tipc_sk_push_backlog()
1271 if (tsk->nagle_start < NAGLE_START_MAX) in tipc_sk_push_backlog()
1272 tsk->nagle_start *= 2; in tipc_sk_push_backlog()
1273 tsk->expect_ack = false; in tipc_sk_push_backlog()
1275 tsk->portid, tsk->msg_acc, tsk->pkt_cnt, in tipc_sk_push_backlog()
1276 tsk->nagle_start); in tipc_sk_push_backlog()
1278 tsk->nagle_start = NAGLE_START_INIT; in tipc_sk_push_backlog()
1281 tsk->expect_ack = true; in tipc_sk_push_backlog()
1283 tsk->expect_ack = false; in tipc_sk_push_backlog()
1286 tsk->msg_acc = 0; in tipc_sk_push_backlog()
1287 tsk->pkt_cnt = 0; in tipc_sk_push_backlog()
1290 if (!skb || tsk->cong_link_cnt) in tipc_sk_push_backlog()
1297 if (tsk->msg_acc) in tipc_sk_push_backlog()
1298 tsk->pkt_cnt += skb_queue_len(txq); in tipc_sk_push_backlog()
1299 tsk->snt_unacked += tsk->snd_backlog; in tipc_sk_push_backlog()
1300 tsk->snd_backlog = 0; in tipc_sk_push_backlog()
1301 rc = tipc_node_xmit(net, txq, dnode, tsk->portid); in tipc_sk_push_backlog()
1303 tsk->cong_link_cnt = 1; in tipc_sk_push_backlog()
1311 static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb, in tipc_sk_conn_proto_rcv() argument
1316 u32 onode = tsk_own_node(tsk); in tipc_sk_conn_proto_rcv()
1317 struct sock *sk = &tsk->sk; in tipc_sk_conn_proto_rcv()
1322 if (!tsk_peer_msg(tsk, hdr)) { in tipc_sk_conn_proto_rcv()
1329 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk), in tipc_sk_conn_proto_rcv()
1330 tsk_peer_port(tsk)); in tipc_sk_conn_proto_rcv()
1344 tsk->probe_unacked = false; in tipc_sk_conn_proto_rcv()
1352 was_cong = tsk_conn_cong(tsk); in tipc_sk_conn_proto_rcv()
1353 tipc_sk_push_backlog(tsk, msg_nagle_ack(hdr)); in tipc_sk_conn_proto_rcv()
1354 tsk->snt_unacked -= msg_conn_ack(hdr); in tipc_sk_conn_proto_rcv()
1355 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_conn_proto_rcv()
1356 tsk->snd_win = msg_adv_win(hdr); in tipc_sk_conn_proto_rcv()
1357 if (was_cong && !tsk_conn_cong(tsk)) in tipc_sk_conn_proto_rcv()
1396 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendmsg() local
1399 struct list_head *clinks = &tsk->cong_links; in __tipc_sendmsg()
1401 struct tipc_group *grp = tsk->group; in __tipc_sendmsg()
1402 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendmsg()
1432 dest = &tsk->peer; in __tipc_sendmsg()
1442 if (tsk->published) in __tipc_sendmsg()
1445 tsk->conn_type = dest->addr.name.name.type; in __tipc_sendmsg()
1446 tsk->conn_instance = dest->addr.name.name.instance; in __tipc_sendmsg()
1491 mtu = tipc_node_get_mtu(net, dnode, tsk->portid, true); in __tipc_sendmsg()
1501 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in __tipc_sendmsg()
1504 tsk->cong_link_cnt++; in __tipc_sendmsg()
1543 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendstream() local
1544 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendstream()
1547 u32 dnode = tsk_peer_node(tsk); in __tipc_sendstream()
1548 int maxnagle = tsk->maxnagle; in __tipc_sendstream()
1549 int maxpkt = tsk->max_pkt; in __tipc_sendstream()
1560 tsk->peer_caps = tipc_node_get_capabilities(net, dnode); in __tipc_sendstream()
1561 tsk->snt_unacked = tsk_inc(tsk, dlen + msg_hdr_sz(hdr)); in __tipc_sendstream()
1568 (!tsk->cong_link_cnt && in __tipc_sendstream()
1569 !tsk_conn_cong(tsk) && in __tipc_sendstream()
1574 blocks = tsk->snd_backlog; in __tipc_sendstream()
1575 if (tsk->oneway++ >= tsk->nagle_start && maxnagle && in __tipc_sendstream()
1581 tsk->msg_acc++; in __tipc_sendstream()
1582 if (blocks <= 64 && tsk->expect_ack) { in __tipc_sendstream()
1583 tsk->snd_backlog = blocks; in __tipc_sendstream()
1587 tsk->pkt_cnt += skb_queue_len(txq); in __tipc_sendstream()
1592 tsk->expect_ack = true; in __tipc_sendstream()
1594 tsk->expect_ack = false; in __tipc_sendstream()
1596 tsk->msg_acc = 0; in __tipc_sendstream()
1597 tsk->pkt_cnt = 0; in __tipc_sendstream()
1603 blocks += tsk_inc(tsk, send + MIN_H_SIZE); in __tipc_sendstream()
1607 rc = tipc_node_xmit(net, txq, dnode, tsk->portid); in __tipc_sendstream()
1609 tsk->cong_link_cnt = 1; in __tipc_sendstream()
1613 tsk->snt_unacked += blocks; in __tipc_sendstream()
1614 tsk->snd_backlog = 0; in __tipc_sendstream()
1642 static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, in tipc_sk_finish_conn() argument
1645 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1647 struct tipc_msg *msg = &tsk->phdr; in tipc_sk_finish_conn()
1658 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); in tipc_sk_finish_conn()
1659 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid, true); in tipc_sk_finish_conn()
1660 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node); in tipc_sk_finish_conn()
1661 tsk_set_nagle(tsk); in tipc_sk_finish_conn()
1663 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_finish_conn()
1667 tsk->rcv_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1668 tsk->snd_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1718 struct tipc_sock *tsk) in tipc_sk_anc_data_recv() argument
1766 has_name = (tsk->conn_type != 0); in tipc_sk_anc_data_recv()
1767 anc_data[0] = tsk->conn_type; in tipc_sk_anc_data_recv()
1768 anc_data[1] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1769 anc_data[2] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1783 static struct sk_buff *tipc_sk_build_ack(struct tipc_sock *tsk) in tipc_sk_build_ack() argument
1785 struct sock *sk = &tsk->sk; in tipc_sk_build_ack()
1788 u32 peer_port = tsk_peer_port(tsk); in tipc_sk_build_ack()
1789 u32 dnode = tsk_peer_node(tsk); in tipc_sk_build_ack()
1794 dnode, tsk_own_node(tsk), peer_port, in tipc_sk_build_ack()
1795 tsk->portid, TIPC_OK); in tipc_sk_build_ack()
1799 msg_set_conn_ack(msg, tsk->rcv_unacked); in tipc_sk_build_ack()
1800 tsk->rcv_unacked = 0; in tipc_sk_build_ack()
1803 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) { in tipc_sk_build_ack()
1804 tsk->rcv_win = tsk_adv_blocks(tsk->sk.sk_rcvbuf); in tipc_sk_build_ack()
1805 msg_set_adv_win(msg, tsk->rcv_win); in tipc_sk_build_ack()
1810 static void tipc_sk_send_ack(struct tipc_sock *tsk) in tipc_sk_send_ack() argument
1814 skb = tipc_sk_build_ack(tsk); in tipc_sk_send_ack()
1818 tipc_node_xmit_skb(sock_net(&tsk->sk), skb, tsk_peer_node(tsk), in tipc_sk_send_ack()
1879 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvmsg() local
1916 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvmsg()
1949 if (tsk->group && msg_in_group(hdr) && !grp_evt) { in tipc_recvmsg()
1951 tipc_group_update_rcv_win(tsk->group, tsk_blocks(hlen + dlen), in tipc_recvmsg()
1963 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvmsg()
1964 if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE) in tipc_recvmsg()
1965 tipc_sk_send_ack(tsk); in tipc_recvmsg()
1986 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvstream() local
2029 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvstream()
2063 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvstream()
2064 if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE) in tipc_recvstream()
2065 tipc_sk_send_ack(tsk); in tipc_recvstream()
2119 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_proto_rcv() local
2121 struct tipc_group *grp = tsk->group; in tipc_sk_proto_rcv()
2126 tipc_sk_conn_proto_rcv(tsk, skb, inputq, xmitq); in tipc_sk_proto_rcv()
2129 tipc_dest_del(&tsk->cong_links, msg_orignode(hdr), 0); in tipc_sk_proto_rcv()
2132 tsk->cong_link_cnt--; in tipc_sk_proto_rcv()
2134 tipc_sk_push_backlog(tsk, false); in tipc_sk_proto_rcv()
2140 tipc_group_member_evt(tsk->group, &wakeup, &sk->sk_rcvbuf, in tipc_sk_proto_rcv()
2160 static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, in tipc_sk_filter_connect() argument
2163 struct sock *sk = &tsk->sk; in tipc_sk_filter_connect()
2167 u32 pport = tsk_peer_port(tsk); in tipc_sk_filter_connect()
2168 u32 pnode = tsk_peer_node(tsk); in tipc_sk_filter_connect()
2176 tsk->oneway = 0; in tipc_sk_filter_connect()
2184 tipc_sk_finish_conn(tsk, oport, onode); in tipc_sk_filter_connect()
2185 msg_set_importance(&tsk->phdr, msg_importance(hdr)); in tipc_sk_filter_connect()
2206 delay %= (tsk->conn_timeout / 4); in tipc_sk_filter_connect()
2223 tipc_sk_push_backlog(tsk, false); in tipc_sk_filter_connect()
2230 skb = tipc_sk_build_ack(tsk); in tipc_sk_filter_connect()
2238 if (!tsk_peer_msg(tsk, hdr)) in tipc_sk_filter_connect()
2243 tipc_node_remove_conn(net, pnode, tsk->portid); in tipc_sk_filter_connect()
2276 struct tipc_sock *tsk = tipc_sk(sk); in rcvbuf_limit() local
2285 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in rcvbuf_limit()
2306 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_filter_rcv() local
2307 struct tipc_group *grp = tsk->group; in tipc_sk_filter_rcv()
2326 tipc_mcast_filter_msg(net, &tsk->mc_method.deferredq, &inputq); in tipc_sk_filter_rcv()
2332 if ((sk_conn && !tipc_sk_filter_connect(tsk, skb, xmitq)) || in tipc_sk_filter_rcv()
2451 struct tipc_sock *tsk; in tipc_sk_rcv() local
2458 tsk = tipc_sk_lookup(net, dport); in tipc_sk_rcv()
2460 if (likely(tsk)) { in tipc_sk_rcv()
2461 sk = &tsk->sk; in tipc_sk_rcv()
2540 struct tipc_sock *tsk = tipc_sk(sk); in tipc_connect() local
2543 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; in tipc_connect()
2552 if (tsk->group) { in tipc_connect()
2558 memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc)); in tipc_connect()
2569 memcpy(&tsk->peer, dest, destlen); in tipc_connect()
2793 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_check_probing_state() local
2794 u32 pnode = tsk_peer_node(tsk); in tipc_sk_check_probing_state()
2795 u32 pport = tsk_peer_port(tsk); in tipc_sk_check_probing_state()
2796 u32 self = tsk_own_node(tsk); in tipc_sk_check_probing_state()
2797 u32 oport = tsk->portid; in tipc_sk_check_probing_state()
2800 if (tsk->probe_unacked) { in tipc_sk_check_probing_state()
2812 tsk->probe_unacked = true; in tipc_sk_check_probing_state()
2818 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_retry_connect() local
2821 if (tsk->cong_link_cnt) { in tipc_sk_retry_connect()
2832 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_timeout() local
2833 u32 pnode = tsk_peer_node(tsk); in tipc_sk_timeout()
2856 rc = tipc_node_xmit(sock_net(sk), &list, pnode, tsk->portid); in tipc_sk_timeout()
2860 tipc_dest_push(&tsk->cong_links, pnode, 0); in tipc_sk_timeout()
2861 tsk->cong_link_cnt = 1; in tipc_sk_timeout()
2866 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, in tipc_sk_publish() argument
2869 struct sock *sk = &tsk->sk; in tipc_sk_publish()
2879 key = tsk->portid + tsk->pub_count + 1; in tipc_sk_publish()
2880 if (key == tsk->portid) in tipc_sk_publish()
2884 scope, tsk->portid, key); in tipc_sk_publish()
2888 list_add(&publ->binding_sock, &tsk->publications); in tipc_sk_publish()
2889 tsk->pub_count++; in tipc_sk_publish()
2890 tsk->published = 1; in tipc_sk_publish()
2894 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, in tipc_sk_withdraw() argument
2897 struct net *net = sock_net(&tsk->sk); in tipc_sk_withdraw()
2905 list_for_each_entry_safe(publ, safe, &tsk->publications, binding_sock) { in tipc_sk_withdraw()
2924 if (list_empty(&tsk->publications)) in tipc_sk_withdraw()
2925 tsk->published = 0; in tipc_sk_withdraw()
2936 struct tipc_sock *tsk; in tipc_sk_reinit() local
2944 while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) { in tipc_sk_reinit()
2945 sock_hold(&tsk->sk); in tipc_sk_reinit()
2947 lock_sock(&tsk->sk); in tipc_sk_reinit()
2948 msg = &tsk->phdr; in tipc_sk_reinit()
2951 release_sock(&tsk->sk); in tipc_sk_reinit()
2953 sock_put(&tsk->sk); in tipc_sk_reinit()
2957 } while (tsk == ERR_PTR(-EAGAIN)); in tipc_sk_reinit()
2965 struct tipc_sock *tsk; in tipc_sk_lookup() local
2968 tsk = rhashtable_lookup(&tn->sk_rht, &portid, tsk_rht_params); in tipc_sk_lookup()
2969 if (tsk) in tipc_sk_lookup()
2970 sock_hold(&tsk->sk); in tipc_sk_lookup()
2973 return tsk; in tipc_sk_lookup()
2976 static int tipc_sk_insert(struct tipc_sock *tsk) in tipc_sk_insert() argument
2978 struct sock *sk = &tsk->sk; in tipc_sk_insert()
2988 tsk->portid = portid; in tipc_sk_insert()
2989 sock_hold(&tsk->sk); in tipc_sk_insert()
2990 if (!rhashtable_lookup_insert_fast(&tn->sk_rht, &tsk->node, in tipc_sk_insert()
2993 sock_put(&tsk->sk); in tipc_sk_insert()
2999 static void tipc_sk_remove(struct tipc_sock *tsk) in tipc_sk_remove() argument
3001 struct sock *sk = &tsk->sk; in tipc_sk_remove()
3004 if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { in tipc_sk_remove()
3037 static int tipc_sk_join(struct tipc_sock *tsk, struct tipc_group_req *mreq) in tipc_sk_join() argument
3039 struct net *net = sock_net(&tsk->sk); in tipc_sk_join()
3040 struct tipc_group *grp = tsk->group; in tipc_sk_join()
3041 struct tipc_msg *hdr = &tsk->phdr; in tipc_sk_join()
3051 grp = tipc_group_create(net, tsk->portid, mreq, &tsk->group_is_open); in tipc_sk_join()
3054 tsk->group = grp; in tipc_sk_join()
3062 rc = tipc_sk_publish(tsk, mreq->scope, &seq); in tipc_sk_join()
3065 tsk->group = NULL; in tipc_sk_join()
3069 tsk->mc_method.rcast = true; in tipc_sk_join()
3070 tsk->mc_method.mandatory = true; in tipc_sk_join()
3071 tipc_group_join(net, grp, &tsk->sk.sk_rcvbuf); in tipc_sk_join()
3075 static int tipc_sk_leave(struct tipc_sock *tsk) in tipc_sk_leave() argument
3077 struct net *net = sock_net(&tsk->sk); in tipc_sk_leave()
3078 struct tipc_group *grp = tsk->group; in tipc_sk_leave()
3086 tsk->group = NULL; in tipc_sk_leave()
3087 tipc_sk_withdraw(tsk, scope, &seq); in tipc_sk_leave()
3108 struct tipc_sock *tsk = tipc_sk(sk); in tipc_setsockopt() local
3148 tsk_set_unreliable(tsk, value); in tipc_setsockopt()
3153 tsk_set_unreturnable(tsk, value); in tipc_setsockopt()
3159 tsk->mc_method.rcast = false; in tipc_setsockopt()
3160 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3163 tsk->mc_method.rcast = true; in tipc_setsockopt()
3164 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3167 res = tipc_sk_join(tsk, &mreq); in tipc_setsockopt()
3170 res = tipc_sk_leave(tsk); in tipc_setsockopt()
3173 tsk->nodelay = !!value; in tipc_setsockopt()
3174 tsk_set_nagle(tsk); in tipc_setsockopt()
3202 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getsockopt() local
3220 value = tsk_importance(tsk); in tipc_getsockopt()
3223 value = tsk_unreliable(tsk); in tipc_getsockopt()
3226 value = tsk_unreturnable(tsk); in tipc_getsockopt()
3229 value = tsk->conn_timeout; in tipc_getsockopt()
3243 if (tsk->group) in tipc_getsockopt()
3244 tipc_group_self(tsk->group, &seq, &scope); in tipc_getsockopt()
3432 static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) in __tipc_nl_add_sk_con() argument
3438 peer_node = tsk_peer_node(tsk); in __tipc_nl_add_sk_con()
3439 peer_port = tsk_peer_port(tsk); in __tipc_nl_add_sk_con()
3450 if (tsk->conn_type != 0) { in __tipc_nl_add_sk_con()
3453 if (nla_put_u32(skb, TIPC_NLA_CON_TYPE, tsk->conn_type)) in __tipc_nl_add_sk_con()
3455 if (nla_put_u32(skb, TIPC_NLA_CON_INST, tsk->conn_instance)) in __tipc_nl_add_sk_con()
3469 *tsk) in __tipc_nl_add_sk_info()
3472 struct sock *sk = &tsk->sk; in __tipc_nl_add_sk_info()
3474 if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid) || in __tipc_nl_add_sk_info()
3479 if (__tipc_nl_add_sk_con(skb, tsk)) in __tipc_nl_add_sk_info()
3481 } else if (!list_empty(&tsk->publications)) { in __tipc_nl_add_sk_info()
3490 struct tipc_sock *tsk) in __tipc_nl_add_sk() argument
3504 if (__tipc_nl_add_sk_info(skb, tsk)) in __tipc_nl_add_sk()
3523 struct tipc_sock *tsk)) in tipc_nl_sk_walk() argument
3526 struct tipc_sock *tsk; in tipc_nl_sk_walk() local
3530 while ((tsk = rhashtable_walk_next(iter)) != NULL) { in tipc_nl_sk_walk()
3531 if (IS_ERR(tsk)) { in tipc_nl_sk_walk()
3532 err = PTR_ERR(tsk); in tipc_nl_sk_walk()
3540 sock_hold(&tsk->sk); in tipc_nl_sk_walk()
3542 lock_sock(&tsk->sk); in tipc_nl_sk_walk()
3543 err = skb_handler(skb, cb, tsk); in tipc_nl_sk_walk()
3545 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3546 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3549 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3551 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3594 struct tipc_sock *tsk, u32 sk_filter_state, in tipc_sk_fill_sock_diag() argument
3597 struct sock *sk = &tsk->sk; in tipc_sk_fill_sock_diag()
3609 if (__tipc_nl_add_sk_info(skb, tsk)) in tipc_sk_fill_sock_diag()
3635 if (tsk->cong_link_cnt && in tipc_sk_fill_sock_diag()
3639 if (tsk_conn_cong(tsk) && in tipc_sk_fill_sock_diag()
3645 if (tsk->group) in tipc_sk_fill_sock_diag()
3646 if (tipc_group_fill_sock_diag(tsk->group, skb)) in tipc_sk_fill_sock_diag()
3709 struct tipc_sock *tsk, u32 *last_publ) in __tipc_nl_list_sk_publ() argument
3715 list_for_each_entry(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3731 p = list_first_entry(&tsk->publications, struct publication, in __tipc_nl_list_sk_publ()
3735 list_for_each_entry_from(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3754 struct tipc_sock *tsk; in tipc_nl_publ_dump() local
3778 tsk = tipc_sk_lookup(net, tsk_portid); in tipc_nl_publ_dump()
3779 if (!tsk) in tipc_nl_publ_dump()
3782 lock_sock(&tsk->sk); in tipc_nl_publ_dump()
3783 err = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ); in tipc_nl_publ_dump()
3786 release_sock(&tsk->sk); in tipc_nl_publ_dump()
3787 sock_put(&tsk->sk); in tipc_nl_publ_dump()
3808 struct tipc_sock *tsk; in tipc_sk_filtering() local
3816 tsk = tipc_sk(sk); in tipc_sk_filtering()
3828 return (_port == tsk->portid); in tipc_sk_filtering()
3833 if (tsk->published) { in tipc_sk_filtering()
3834 p = list_first_entry_or_null(&tsk->publications, in tipc_sk_filtering()
3844 type = tsk->conn_type; in tipc_sk_filtering()
3845 lower = tsk->conn_instance; in tipc_sk_filtering()
3846 upper = tsk->conn_instance; in tipc_sk_filtering()
3911 struct tipc_sock *tsk; in tipc_sk_dump() local
3920 tsk = tipc_sk(sk); in tipc_sk_dump()
3925 i += scnprintf(buf + i, sz - i, " %x", tsk_own_node(tsk)); in tipc_sk_dump()
3926 i += scnprintf(buf + i, sz - i, " %u", tsk->portid); in tipc_sk_dump()
3929 i += scnprintf(buf + i, sz - i, " %x", tsk_peer_node(tsk)); in tipc_sk_dump()
3930 i += scnprintf(buf + i, sz - i, " %u", tsk_peer_port(tsk)); in tipc_sk_dump()
3931 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_type); in tipc_sk_dump()
3932 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_instance); in tipc_sk_dump()
3934 i += scnprintf(buf + i, sz - i, " | %u", tsk->published); in tipc_sk_dump()
3935 if (tsk->published) { in tipc_sk_dump()
3936 p = list_first_entry_or_null(&tsk->publications, in tipc_sk_dump()
3942 i += scnprintf(buf + i, sz - i, " | %u", tsk->snd_win); in tipc_sk_dump()
3943 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_win); in tipc_sk_dump()
3944 i += scnprintf(buf + i, sz - i, " %u", tsk->max_pkt); in tipc_sk_dump()
3945 i += scnprintf(buf + i, sz - i, " %x", tsk->peer_caps); in tipc_sk_dump()
3946 i += scnprintf(buf + i, sz - i, " %u", tsk->cong_link_cnt); in tipc_sk_dump()
3947 i += scnprintf(buf + i, sz - i, " %u", tsk->snt_unacked); in tipc_sk_dump()
3948 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_unacked); in tipc_sk_dump()
3949 i += scnprintf(buf + i, sz - i, " %u", atomic_read(&tsk->dupl_rcvcnt)); in tipc_sk_dump()