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);
159 static u32 tsk_own_node(struct tipc_sock *tsk) in tsk_own_node() argument
161 return msg_prevnode(&tsk->phdr); in tsk_own_node()
164 static u32 tsk_peer_node(struct tipc_sock *tsk) in tsk_peer_node() argument
166 return msg_destnode(&tsk->phdr); in tsk_peer_node()
169 static u32 tsk_peer_port(struct tipc_sock *tsk) in tsk_peer_port() argument
171 return msg_destport(&tsk->phdr); in tsk_peer_port()
174 static bool tsk_unreliable(struct tipc_sock *tsk) in tsk_unreliable() argument
176 return msg_src_droppable(&tsk->phdr) != 0; in tsk_unreliable()
179 static void tsk_set_unreliable(struct tipc_sock *tsk, bool unreliable) in tsk_set_unreliable() argument
181 msg_set_src_droppable(&tsk->phdr, unreliable ? 1 : 0); in tsk_set_unreliable()
184 static bool tsk_unreturnable(struct tipc_sock *tsk) in tsk_unreturnable() argument
186 return msg_dest_droppable(&tsk->phdr) != 0; in tsk_unreturnable()
189 static void tsk_set_unreturnable(struct tipc_sock *tsk, bool unreturnable) in tsk_set_unreturnable() argument
191 msg_set_dest_droppable(&tsk->phdr, unreturnable ? 1 : 0); in tsk_set_unreturnable()
194 static int tsk_importance(struct tipc_sock *tsk) in tsk_importance() argument
196 return msg_importance(&tsk->phdr); in tsk_importance()
212 static bool tsk_conn_cong(struct tipc_sock *tsk) in tsk_conn_cong() argument
214 return tsk->snt_unacked > tsk->snd_win; in tsk_conn_cong()
235 static u16 tsk_inc(struct tipc_sock *tsk, int msglen) in tsk_inc() argument
237 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in tsk_inc()
244 static void tsk_set_nagle(struct tipc_sock *tsk) in tsk_set_nagle() argument
246 struct sock *sk = &tsk->sk; in tsk_set_nagle()
248 tsk->maxnagle = 0; in tsk_set_nagle()
251 if (tsk->nodelay) in tsk_set_nagle()
253 if (!(tsk->peer_caps & TIPC_NAGLE)) in tsk_set_nagle()
256 if (tsk->max_pkt == MAX_MSG_SIZE) in tsk_set_nagle()
257 tsk->maxnagle = 1500; in tsk_set_nagle()
259 tsk->maxnagle = tsk->max_pkt; in tsk_set_nagle()
323 static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) in tsk_peer_msg() argument
325 struct sock *sk = &tsk->sk; in tsk_peer_msg()
327 u32 peer_port = tsk_peer_port(tsk); in tsk_peer_msg()
337 peer_node = tsk_peer_node(tsk); in tsk_peer_msg()
452 struct tipc_sock *tsk; in tipc_sk_create() local
479 tsk = tipc_sk(sk); in tipc_sk_create()
480 tsk->max_pkt = MAX_PKT_DEFAULT; in tipc_sk_create()
481 tsk->maxnagle = 0; in tipc_sk_create()
482 tsk->nagle_start = NAGLE_START_INIT; in tipc_sk_create()
483 INIT_LIST_HEAD(&tsk->publications); in tipc_sk_create()
484 INIT_LIST_HEAD(&tsk->cong_links); in tipc_sk_create()
485 msg = &tsk->phdr; in tipc_sk_create()
491 if (tipc_sk_insert(tsk)) { in tipc_sk_create()
503 msg_set_origport(msg, tsk->portid); in tipc_sk_create()
511 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; in tipc_sk_create()
512 tsk->group_is_open = true; in tipc_sk_create()
513 atomic_set(&tsk->dupl_rcvcnt, 0); in tipc_sk_create()
516 tsk->snd_win = tsk_adv_blocks(RCVBUF_MIN); in tipc_sk_create()
517 tsk->rcv_win = tsk->snd_win; in tipc_sk_create()
520 tsk_set_unreturnable(tsk, true); in tipc_sk_create()
522 tsk_set_unreliable(tsk, true); in tipc_sk_create()
524 __skb_queue_head_init(&tsk->mc_method.deferredq); in tipc_sk_create()
531 struct tipc_sock *tsk = container_of(head, struct tipc_sock, rcu); in tipc_sk_callback() local
533 sock_put(&tsk->sk); in tipc_sk_callback()
540 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_shutdown() local
543 u32 dnode = tsk_peer_node(tsk); in __tipc_shutdown()
547 tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt && in __tipc_shutdown()
548 !tsk_conn_cong(tsk))); in __tipc_shutdown()
551 tipc_sk_push_backlog(tsk, false); in __tipc_shutdown()
572 tipc_node_remove_conn(net, dnode, tsk->portid); in __tipc_shutdown()
582 tsk_own_node(tsk), tsk_peer_port(tsk), in __tipc_shutdown()
583 tsk->portid, error); in __tipc_shutdown()
585 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); in __tipc_shutdown()
616 struct tipc_sock *tsk; in tipc_release() local
625 tsk = tipc_sk(sk); in tipc_release()
631 tipc_sk_leave(tsk); in tipc_release()
632 tipc_sk_withdraw(tsk, 0, NULL); in tipc_release()
633 __skb_queue_purge(&tsk->mc_method.deferredq); in tipc_release()
635 tipc_sk_remove(tsk); in tipc_release()
640 tipc_dest_list_purge(&tsk->cong_links); in tipc_release()
641 tsk->cong_link_cnt = 0; in tipc_release()
642 call_rcu(&tsk->rcu, tipc_sk_callback); in tipc_release()
668 struct tipc_sock *tsk = tipc_sk(sk); in tipc_bind() local
673 res = tipc_sk_withdraw(tsk, 0, NULL); in tipc_bind()
676 if (tsk->group) { in tipc_bind()
704 tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : in tipc_bind()
705 tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); in tipc_bind()
728 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getname() local
735 addr->addr.id.ref = tsk_peer_port(tsk); in tipc_getname()
736 addr->addr.id.node = tsk_peer_node(tsk); in tipc_getname()
738 addr->addr.id.ref = tsk->portid; in tipc_getname()
772 struct tipc_sock *tsk = tipc_sk(sk); in tipc_poll() local
785 if (!tsk->cong_link_cnt && !tsk_conn_cong(tsk)) in tipc_poll()
794 if (tsk->group_is_open && !tsk->cong_link_cnt) in tipc_poll()
824 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sendmcast() local
825 struct tipc_msg *hdr = &tsk->phdr; in tipc_sendmcast()
828 struct tipc_mc_method *method = &tsk->mc_method; in tipc_sendmcast()
833 if (tsk->group) in tipc_sendmcast()
837 rc = tipc_wait_for_cond(sock, &timeout, !tsk->cong_link_cnt); in tipc_sendmcast()
867 &tsk->cong_link_cnt); in tipc_sendmcast()
884 static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, in tipc_send_group_msg() argument
888 u16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group); in tipc_send_group_msg()
889 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_msg()
891 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_msg()
904 mtu = tipc_node_get_mtu(net, dnode, tsk->portid, false); in tipc_send_group_msg()
910 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in tipc_send_group_msg()
912 tipc_dest_push(&tsk->cong_links, dnode, 0); in tipc_send_group_msg()
913 tsk->cong_link_cnt++; in tipc_send_group_msg()
941 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_unicast() local
954 !tipc_dest_find(&tsk->cong_links, node, 0) && in tipc_send_group_unicast()
955 tsk->group && in tipc_send_group_unicast()
956 !tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_unicast()
964 rc = tipc_send_group_msg(net, tsk, m, mb, node, port, dlen); in tipc_send_group_unicast()
984 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_anycast() local
985 struct list_head *cong_links = &tsk->cong_links; in tipc_send_group_anycast()
987 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_anycast()
1005 exclude = tipc_group_exclude(tsk->group); in tipc_send_group_anycast()
1015 cong = tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_anycast()
1035 tsk->group && in tipc_send_group_anycast()
1036 !tipc_group_cong(tsk->group, node, port, in tipc_send_group_anycast()
1049 rc = tipc_send_group_msg(net, tsk, m, mbr, node, port, dlen); in tipc_send_group_anycast()
1070 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_bcast() local
1072 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_bcast()
1075 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_bcast()
1082 !tsk->cong_link_cnt && tsk->group && in tipc_send_group_bcast()
1083 !tipc_group_bc_cong(tsk->group, blks)); in tipc_send_group_bcast()
1087 dsts = tipc_group_dests(tsk->group); in tipc_send_group_bcast()
1102 msg_set_grp_bc_seqno(hdr, tipc_group_bc_snd_nxt(tsk->group)); in tipc_send_group_bcast()
1114 rc = tipc_mcast_xmit(net, &pkts, method, dsts, &tsk->cong_link_cnt); in tipc_send_group_bcast()
1119 tipc_group_update_bc_members(tsk->group, blks, ack); in tipc_send_group_bcast()
1143 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_mcast() local
1144 struct tipc_group *grp = tsk->group; in tipc_send_group_mcast()
1145 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_mcast()
1264 static void tipc_sk_push_backlog(struct tipc_sock *tsk, bool nagle_ack) in tipc_sk_push_backlog() argument
1266 struct sk_buff_head *txq = &tsk->sk.sk_write_queue; in tipc_sk_push_backlog()
1268 struct net *net = sock_net(&tsk->sk); in tipc_sk_push_backlog()
1269 u32 dnode = tsk_peer_node(tsk); in tipc_sk_push_backlog()
1273 tsk->pkt_cnt += skb_queue_len(txq); in tipc_sk_push_backlog()
1274 if (!tsk->pkt_cnt || tsk->msg_acc / tsk->pkt_cnt < 2) { in tipc_sk_push_backlog()
1275 tsk->oneway = 0; in tipc_sk_push_backlog()
1276 if (tsk->nagle_start < NAGLE_START_MAX) in tipc_sk_push_backlog()
1277 tsk->nagle_start *= 2; in tipc_sk_push_backlog()
1278 tsk->expect_ack = false; in tipc_sk_push_backlog()
1280 tsk->portid, tsk->msg_acc, tsk->pkt_cnt, in tipc_sk_push_backlog()
1281 tsk->nagle_start); in tipc_sk_push_backlog()
1283 tsk->nagle_start = NAGLE_START_INIT; in tipc_sk_push_backlog()
1286 tsk->expect_ack = true; in tipc_sk_push_backlog()
1288 tsk->expect_ack = false; in tipc_sk_push_backlog()
1291 tsk->msg_acc = 0; in tipc_sk_push_backlog()
1292 tsk->pkt_cnt = 0; in tipc_sk_push_backlog()
1295 if (!skb || tsk->cong_link_cnt) in tipc_sk_push_backlog()
1302 if (tsk->msg_acc) in tipc_sk_push_backlog()
1303 tsk->pkt_cnt += skb_queue_len(txq); in tipc_sk_push_backlog()
1304 tsk->snt_unacked += tsk->snd_backlog; in tipc_sk_push_backlog()
1305 tsk->snd_backlog = 0; in tipc_sk_push_backlog()
1306 rc = tipc_node_xmit(net, txq, dnode, tsk->portid); in tipc_sk_push_backlog()
1308 tsk->cong_link_cnt = 1; in tipc_sk_push_backlog()
1316 static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb, in tipc_sk_conn_proto_rcv() argument
1321 u32 onode = tsk_own_node(tsk); in tipc_sk_conn_proto_rcv()
1322 struct sock *sk = &tsk->sk; in tipc_sk_conn_proto_rcv()
1327 if (!tsk_peer_msg(tsk, hdr)) { in tipc_sk_conn_proto_rcv()
1334 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk), in tipc_sk_conn_proto_rcv()
1335 tsk_peer_port(tsk)); in tipc_sk_conn_proto_rcv()
1349 tsk->probe_unacked = false; in tipc_sk_conn_proto_rcv()
1357 was_cong = tsk_conn_cong(tsk); in tipc_sk_conn_proto_rcv()
1358 tipc_sk_push_backlog(tsk, msg_nagle_ack(hdr)); in tipc_sk_conn_proto_rcv()
1359 tsk->snt_unacked -= msg_conn_ack(hdr); in tipc_sk_conn_proto_rcv()
1360 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_conn_proto_rcv()
1361 tsk->snd_win = msg_adv_win(hdr); in tipc_sk_conn_proto_rcv()
1362 if (was_cong && !tsk_conn_cong(tsk)) in tipc_sk_conn_proto_rcv()
1401 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendmsg() local
1404 struct list_head *clinks = &tsk->cong_links; in __tipc_sendmsg()
1406 struct tipc_group *grp = tsk->group; in __tipc_sendmsg()
1407 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendmsg()
1437 dest = &tsk->peer; in __tipc_sendmsg()
1447 if (tsk->published) in __tipc_sendmsg()
1450 tsk->conn_type = dest->addr.name.name.type; in __tipc_sendmsg()
1451 tsk->conn_instance = dest->addr.name.name.instance; in __tipc_sendmsg()
1496 mtu = tipc_node_get_mtu(net, dnode, tsk->portid, true); in __tipc_sendmsg()
1506 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in __tipc_sendmsg()
1509 tsk->cong_link_cnt++; in __tipc_sendmsg()
1553 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendstream() local
1554 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendstream()
1557 u32 dnode = tsk_peer_node(tsk); in __tipc_sendstream()
1558 int maxnagle = tsk->maxnagle; in __tipc_sendstream()
1559 int maxpkt = tsk->max_pkt; in __tipc_sendstream()
1570 tsk->peer_caps = tipc_node_get_capabilities(net, dnode); in __tipc_sendstream()
1571 tsk->snt_unacked = tsk_inc(tsk, dlen + msg_hdr_sz(hdr)); in __tipc_sendstream()
1578 (!tsk->cong_link_cnt && in __tipc_sendstream()
1579 !tsk_conn_cong(tsk) && in __tipc_sendstream()
1584 blocks = tsk->snd_backlog; in __tipc_sendstream()
1585 if (tsk->oneway++ >= tsk->nagle_start && maxnagle && in __tipc_sendstream()
1591 tsk->msg_acc++; in __tipc_sendstream()
1592 if (blocks <= 64 && tsk->expect_ack) { in __tipc_sendstream()
1593 tsk->snd_backlog = blocks; in __tipc_sendstream()
1597 tsk->pkt_cnt += skb_queue_len(txq); in __tipc_sendstream()
1602 tsk->expect_ack = true; in __tipc_sendstream()
1604 tsk->expect_ack = false; in __tipc_sendstream()
1606 tsk->msg_acc = 0; in __tipc_sendstream()
1607 tsk->pkt_cnt = 0; in __tipc_sendstream()
1613 blocks += tsk_inc(tsk, send + MIN_H_SIZE); in __tipc_sendstream()
1617 rc = tipc_node_xmit(net, txq, dnode, tsk->portid); in __tipc_sendstream()
1619 tsk->cong_link_cnt = 1; in __tipc_sendstream()
1623 tsk->snt_unacked += blocks; in __tipc_sendstream()
1624 tsk->snd_backlog = 0; in __tipc_sendstream()
1652 static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, in tipc_sk_finish_conn() argument
1655 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1657 struct tipc_msg *msg = &tsk->phdr; in tipc_sk_finish_conn()
1668 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); in tipc_sk_finish_conn()
1669 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid, true); in tipc_sk_finish_conn()
1670 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node); in tipc_sk_finish_conn()
1671 tsk_set_nagle(tsk); in tipc_sk_finish_conn()
1673 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_finish_conn()
1677 tsk->rcv_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1678 tsk->snd_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1728 struct tipc_sock *tsk) in tipc_sk_anc_data_recv() argument
1776 has_name = (tsk->conn_type != 0); in tipc_sk_anc_data_recv()
1777 anc_data[0] = tsk->conn_type; in tipc_sk_anc_data_recv()
1778 anc_data[1] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1779 anc_data[2] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1793 static struct sk_buff *tipc_sk_build_ack(struct tipc_sock *tsk) in tipc_sk_build_ack() argument
1795 struct sock *sk = &tsk->sk; in tipc_sk_build_ack()
1798 u32 peer_port = tsk_peer_port(tsk); in tipc_sk_build_ack()
1799 u32 dnode = tsk_peer_node(tsk); in tipc_sk_build_ack()
1804 dnode, tsk_own_node(tsk), peer_port, in tipc_sk_build_ack()
1805 tsk->portid, TIPC_OK); in tipc_sk_build_ack()
1809 msg_set_conn_ack(msg, tsk->rcv_unacked); in tipc_sk_build_ack()
1810 tsk->rcv_unacked = 0; in tipc_sk_build_ack()
1813 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) { in tipc_sk_build_ack()
1814 tsk->rcv_win = tsk_adv_blocks(tsk->sk.sk_rcvbuf); in tipc_sk_build_ack()
1815 msg_set_adv_win(msg, tsk->rcv_win); in tipc_sk_build_ack()
1820 static void tipc_sk_send_ack(struct tipc_sock *tsk) in tipc_sk_send_ack() argument
1824 skb = tipc_sk_build_ack(tsk); in tipc_sk_send_ack()
1828 tipc_node_xmit_skb(sock_net(&tsk->sk), skb, tsk_peer_node(tsk), in tipc_sk_send_ack()
1889 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvmsg() local
1928 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvmsg()
1976 if (tsk->group && msg_in_group(hdr) && !grp_evt) { in tipc_recvmsg()
1978 tipc_group_update_rcv_win(tsk->group, tsk_blocks(hlen + dlen), in tipc_recvmsg()
1993 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvmsg()
1994 if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE) in tipc_recvmsg()
1995 tipc_sk_send_ack(tsk); in tipc_recvmsg()
2016 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvstream() local
2059 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvstream()
2093 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvstream()
2094 if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE) in tipc_recvstream()
2095 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()
2481 struct tipc_sock *tsk; in tipc_sk_rcv() local
2488 tsk = tipc_sk_lookup(net, dport); in tipc_sk_rcv()
2490 if (likely(tsk)) { in tipc_sk_rcv()
2491 sk = &tsk->sk; in tipc_sk_rcv()
2570 struct tipc_sock *tsk = tipc_sk(sk); in tipc_connect() local
2573 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; in tipc_connect()
2582 if (tsk->group) { in tipc_connect()
2588 memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc)); in tipc_connect()
2599 memcpy(&tsk->peer, dest, destlen); in tipc_connect()
2821 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_check_probing_state() local
2822 u32 pnode = tsk_peer_node(tsk); in tipc_sk_check_probing_state()
2823 u32 pport = tsk_peer_port(tsk); in tipc_sk_check_probing_state()
2824 u32 self = tsk_own_node(tsk); in tipc_sk_check_probing_state()
2825 u32 oport = tsk->portid; in tipc_sk_check_probing_state()
2828 if (tsk->probe_unacked) { in tipc_sk_check_probing_state()
2840 tsk->probe_unacked = true; in tipc_sk_check_probing_state()
2846 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_retry_connect() local
2849 if (tsk->cong_link_cnt) { in tipc_sk_retry_connect()
2861 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_timeout() local
2862 u32 pnode = tsk_peer_node(tsk); in tipc_sk_timeout()
2885 rc = tipc_node_xmit(sock_net(sk), &list, pnode, tsk->portid); in tipc_sk_timeout()
2889 tipc_dest_push(&tsk->cong_links, pnode, 0); in tipc_sk_timeout()
2890 tsk->cong_link_cnt = 1; in tipc_sk_timeout()
2895 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, in tipc_sk_publish() argument
2898 struct sock *sk = &tsk->sk; in tipc_sk_publish()
2908 key = tsk->portid + tsk->pub_count + 1; in tipc_sk_publish()
2909 if (key == tsk->portid) in tipc_sk_publish()
2913 scope, tsk->portid, key); in tipc_sk_publish()
2917 list_add(&publ->binding_sock, &tsk->publications); in tipc_sk_publish()
2918 tsk->pub_count++; in tipc_sk_publish()
2919 tsk->published = 1; in tipc_sk_publish()
2923 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, in tipc_sk_withdraw() argument
2926 struct net *net = sock_net(&tsk->sk); in tipc_sk_withdraw()
2934 list_for_each_entry_safe(publ, safe, &tsk->publications, binding_sock) { in tipc_sk_withdraw()
2953 if (list_empty(&tsk->publications)) in tipc_sk_withdraw()
2954 tsk->published = 0; in tipc_sk_withdraw()
2965 struct tipc_sock *tsk; in tipc_sk_reinit() local
2973 while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) { in tipc_sk_reinit()
2974 sock_hold(&tsk->sk); in tipc_sk_reinit()
2976 lock_sock(&tsk->sk); in tipc_sk_reinit()
2977 msg = &tsk->phdr; in tipc_sk_reinit()
2980 release_sock(&tsk->sk); in tipc_sk_reinit()
2982 sock_put(&tsk->sk); in tipc_sk_reinit()
2986 } while (tsk == ERR_PTR(-EAGAIN)); in tipc_sk_reinit()
2994 struct tipc_sock *tsk; in tipc_sk_lookup() local
2997 tsk = rhashtable_lookup(&tn->sk_rht, &portid, tsk_rht_params); in tipc_sk_lookup()
2998 if (tsk) in tipc_sk_lookup()
2999 sock_hold(&tsk->sk); in tipc_sk_lookup()
3002 return tsk; in tipc_sk_lookup()
3005 static int tipc_sk_insert(struct tipc_sock *tsk) in tipc_sk_insert() argument
3007 struct sock *sk = &tsk->sk; in tipc_sk_insert()
3017 tsk->portid = portid; in tipc_sk_insert()
3018 sock_hold(&tsk->sk); in tipc_sk_insert()
3019 if (!rhashtable_lookup_insert_fast(&tn->sk_rht, &tsk->node, in tipc_sk_insert()
3022 sock_put(&tsk->sk); in tipc_sk_insert()
3028 static void tipc_sk_remove(struct tipc_sock *tsk) in tipc_sk_remove() argument
3030 struct sock *sk = &tsk->sk; in tipc_sk_remove()
3033 if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { in tipc_sk_remove()
3066 static int tipc_sk_join(struct tipc_sock *tsk, struct tipc_group_req *mreq) in tipc_sk_join() argument
3068 struct net *net = sock_net(&tsk->sk); in tipc_sk_join()
3069 struct tipc_group *grp = tsk->group; in tipc_sk_join()
3070 struct tipc_msg *hdr = &tsk->phdr; in tipc_sk_join()
3080 grp = tipc_group_create(net, tsk->portid, mreq, &tsk->group_is_open); in tipc_sk_join()
3083 tsk->group = grp; in tipc_sk_join()
3091 rc = tipc_sk_publish(tsk, mreq->scope, &seq); in tipc_sk_join()
3094 tsk->group = NULL; in tipc_sk_join()
3098 tsk->mc_method.rcast = true; in tipc_sk_join()
3099 tsk->mc_method.mandatory = true; in tipc_sk_join()
3100 tipc_group_join(net, grp, &tsk->sk.sk_rcvbuf); in tipc_sk_join()
3104 static int tipc_sk_leave(struct tipc_sock *tsk) in tipc_sk_leave() argument
3106 struct net *net = sock_net(&tsk->sk); in tipc_sk_leave()
3107 struct tipc_group *grp = tsk->group; in tipc_sk_leave()
3115 tsk->group = NULL; in tipc_sk_leave()
3116 tipc_sk_withdraw(tsk, scope, &seq); in tipc_sk_leave()
3137 struct tipc_sock *tsk = tipc_sk(sk); in tipc_setsockopt() local
3177 tsk_set_unreliable(tsk, value); in tipc_setsockopt()
3182 tsk_set_unreturnable(tsk, value); in tipc_setsockopt()
3188 tsk->mc_method.rcast = false; in tipc_setsockopt()
3189 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3192 tsk->mc_method.rcast = true; in tipc_setsockopt()
3193 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3196 res = tipc_sk_join(tsk, &mreq); in tipc_setsockopt()
3199 res = tipc_sk_leave(tsk); in tipc_setsockopt()
3202 tsk->nodelay = !!value; in tipc_setsockopt()
3203 tsk_set_nagle(tsk); in tipc_setsockopt()
3231 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getsockopt() local
3249 value = tsk_importance(tsk); in tipc_getsockopt()
3252 value = tsk_unreliable(tsk); in tipc_getsockopt()
3255 value = tsk_unreturnable(tsk); in tipc_getsockopt()
3258 value = tsk->conn_timeout; in tipc_getsockopt()
3272 if (tsk->group) in tipc_getsockopt()
3273 tipc_group_self(tsk->group, &seq, &scope); in tipc_getsockopt()
3461 static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) in __tipc_nl_add_sk_con() argument
3467 peer_node = tsk_peer_node(tsk); in __tipc_nl_add_sk_con()
3468 peer_port = tsk_peer_port(tsk); in __tipc_nl_add_sk_con()
3479 if (tsk->conn_type != 0) { in __tipc_nl_add_sk_con()
3482 if (nla_put_u32(skb, TIPC_NLA_CON_TYPE, tsk->conn_type)) in __tipc_nl_add_sk_con()
3484 if (nla_put_u32(skb, TIPC_NLA_CON_INST, tsk->conn_instance)) in __tipc_nl_add_sk_con()
3498 *tsk) in __tipc_nl_add_sk_info()
3501 struct sock *sk = &tsk->sk; in __tipc_nl_add_sk_info()
3503 if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid) || in __tipc_nl_add_sk_info()
3508 if (__tipc_nl_add_sk_con(skb, tsk)) in __tipc_nl_add_sk_info()
3510 } else if (!list_empty(&tsk->publications)) { in __tipc_nl_add_sk_info()
3519 struct tipc_sock *tsk) in __tipc_nl_add_sk() argument
3533 if (__tipc_nl_add_sk_info(skb, tsk)) in __tipc_nl_add_sk()
3552 struct tipc_sock *tsk)) in tipc_nl_sk_walk() argument
3555 struct tipc_sock *tsk; in tipc_nl_sk_walk() local
3559 while ((tsk = rhashtable_walk_next(iter)) != NULL) { in tipc_nl_sk_walk()
3560 if (IS_ERR(tsk)) { in tipc_nl_sk_walk()
3561 err = PTR_ERR(tsk); in tipc_nl_sk_walk()
3569 sock_hold(&tsk->sk); in tipc_nl_sk_walk()
3571 lock_sock(&tsk->sk); in tipc_nl_sk_walk()
3572 err = skb_handler(skb, cb, tsk); in tipc_nl_sk_walk()
3574 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3575 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3578 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3580 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3623 struct tipc_sock *tsk, u32 sk_filter_state, in tipc_sk_fill_sock_diag() argument
3626 struct sock *sk = &tsk->sk; in tipc_sk_fill_sock_diag()
3638 if (__tipc_nl_add_sk_info(skb, tsk)) in tipc_sk_fill_sock_diag()
3664 if (tsk->cong_link_cnt && in tipc_sk_fill_sock_diag()
3668 if (tsk_conn_cong(tsk) && in tipc_sk_fill_sock_diag()
3674 if (tsk->group) in tipc_sk_fill_sock_diag()
3675 if (tipc_group_fill_sock_diag(tsk->group, skb)) in tipc_sk_fill_sock_diag()
3738 struct tipc_sock *tsk, u32 *last_publ) in __tipc_nl_list_sk_publ() argument
3744 list_for_each_entry(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3748 if (list_entry_is_head(p, &tsk->publications, binding_sock)) { in __tipc_nl_list_sk_publ()
3760 p = list_first_entry(&tsk->publications, struct publication, in __tipc_nl_list_sk_publ()
3764 list_for_each_entry_from(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3783 struct tipc_sock *tsk; in tipc_nl_publ_dump() local
3807 tsk = tipc_sk_lookup(net, tsk_portid); in tipc_nl_publ_dump()
3808 if (!tsk) in tipc_nl_publ_dump()
3811 lock_sock(&tsk->sk); in tipc_nl_publ_dump()
3812 err = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ); in tipc_nl_publ_dump()
3815 release_sock(&tsk->sk); in tipc_nl_publ_dump()
3816 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 = tsk->conn_type; in tipc_sk_filtering()
3874 lower = tsk->conn_instance; in tipc_sk_filtering()
3875 upper = tsk->conn_instance; in tipc_sk_filtering()
3940 struct tipc_sock *tsk; in tipc_sk_dump() local
3949 tsk = tipc_sk(sk); in tipc_sk_dump()
3954 i += scnprintf(buf + i, sz - i, " %x", tsk_own_node(tsk)); in tipc_sk_dump()
3955 i += scnprintf(buf + i, sz - i, " %u", tsk->portid); in tipc_sk_dump()
3958 i += scnprintf(buf + i, sz - i, " %x", tsk_peer_node(tsk)); in tipc_sk_dump()
3959 i += scnprintf(buf + i, sz - i, " %u", tsk_peer_port(tsk)); in tipc_sk_dump()
3960 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_type); in tipc_sk_dump()
3961 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_instance); in tipc_sk_dump()
3963 i += scnprintf(buf + i, sz - i, " | %u", tsk->published); in tipc_sk_dump()
3964 if (tsk->published) { in tipc_sk_dump()
3965 p = list_first_entry_or_null(&tsk->publications, in tipc_sk_dump()
3971 i += scnprintf(buf + i, sz - i, " | %u", tsk->snd_win); in tipc_sk_dump()
3972 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_win); in tipc_sk_dump()
3973 i += scnprintf(buf + i, sz - i, " %u", tsk->max_pkt); in tipc_sk_dump()
3974 i += scnprintf(buf + i, sz - i, " %x", tsk->peer_caps); in tipc_sk_dump()
3975 i += scnprintf(buf + i, sz - i, " %u", tsk->cong_link_cnt); in tipc_sk_dump()
3976 i += scnprintf(buf + i, sz - i, " %u", tsk->snt_unacked); in tipc_sk_dump()
3977 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_unacked); in tipc_sk_dump()
3978 i += scnprintf(buf + i, sz - i, " %u", atomic_read(&tsk->dupl_rcvcnt)); in tipc_sk_dump()