Lines Matching refs:tsk

130 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope,
132 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope,
134 static int tipc_sk_leave(struct tipc_sock *tsk);
136 static int tipc_sk_insert(struct tipc_sock *tsk);
137 static void tipc_sk_remove(struct tipc_sock *tsk);
147 static u32 tsk_own_node(struct tipc_sock *tsk) in tsk_own_node() argument
149 return msg_prevnode(&tsk->phdr); in tsk_own_node()
152 static u32 tsk_peer_node(struct tipc_sock *tsk) in tsk_peer_node() argument
154 return msg_destnode(&tsk->phdr); in tsk_peer_node()
157 static u32 tsk_peer_port(struct tipc_sock *tsk) in tsk_peer_port() argument
159 return msg_destport(&tsk->phdr); in tsk_peer_port()
162 static bool tsk_unreliable(struct tipc_sock *tsk) in tsk_unreliable() argument
164 return msg_src_droppable(&tsk->phdr) != 0; in tsk_unreliable()
167 static void tsk_set_unreliable(struct tipc_sock *tsk, bool unreliable) in tsk_set_unreliable() argument
169 msg_set_src_droppable(&tsk->phdr, unreliable ? 1 : 0); in tsk_set_unreliable()
172 static bool tsk_unreturnable(struct tipc_sock *tsk) in tsk_unreturnable() argument
174 return msg_dest_droppable(&tsk->phdr) != 0; in tsk_unreturnable()
177 static void tsk_set_unreturnable(struct tipc_sock *tsk, bool unreturnable) in tsk_set_unreturnable() argument
179 msg_set_dest_droppable(&tsk->phdr, unreturnable ? 1 : 0); in tsk_set_unreturnable()
182 static int tsk_importance(struct tipc_sock *tsk) in tsk_importance() argument
184 return msg_importance(&tsk->phdr); in tsk_importance()
187 static int tsk_set_importance(struct tipc_sock *tsk, int imp) in tsk_set_importance() argument
191 msg_set_importance(&tsk->phdr, (u32)imp); in tsk_set_importance()
200 static bool tsk_conn_cong(struct tipc_sock *tsk) in tsk_conn_cong() argument
202 return tsk->snt_unacked > tsk->snd_win; in tsk_conn_cong()
223 static u16 tsk_inc(struct tipc_sock *tsk, int msglen) in tsk_inc() argument
225 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in tsk_inc()
291 static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) in tsk_peer_msg() argument
293 struct sock *sk = &tsk->sk; in tsk_peer_msg()
295 u32 peer_port = tsk_peer_port(tsk); in tsk_peer_msg()
305 peer_node = tsk_peer_node(tsk); in tsk_peer_msg()
420 struct tipc_sock *tsk; in tipc_sk_create() local
447 tsk = tipc_sk(sk); in tipc_sk_create()
448 tsk->max_pkt = MAX_PKT_DEFAULT; in tipc_sk_create()
449 INIT_LIST_HEAD(&tsk->publications); in tipc_sk_create()
450 INIT_LIST_HEAD(&tsk->cong_links); in tipc_sk_create()
451 msg = &tsk->phdr; in tipc_sk_create()
457 if (tipc_sk_insert(tsk)) { in tipc_sk_create()
468 msg_set_origport(msg, tsk->portid); in tipc_sk_create()
476 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; in tipc_sk_create()
477 tsk->group_is_open = true; in tipc_sk_create()
478 atomic_set(&tsk->dupl_rcvcnt, 0); in tipc_sk_create()
481 tsk->snd_win = tsk_adv_blocks(RCVBUF_MIN); in tipc_sk_create()
482 tsk->rcv_win = tsk->snd_win; in tipc_sk_create()
485 tsk_set_unreturnable(tsk, true); in tipc_sk_create()
487 tsk_set_unreliable(tsk, true); in tipc_sk_create()
489 __skb_queue_head_init(&tsk->mc_method.deferredq); in tipc_sk_create()
496 struct tipc_sock *tsk = container_of(head, struct tipc_sock, rcu); in tipc_sk_callback() local
498 sock_put(&tsk->sk); in tipc_sk_callback()
505 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_shutdown() local
508 u32 dnode = tsk_peer_node(tsk); in __tipc_shutdown()
512 tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt && in __tipc_shutdown()
513 !tsk_conn_cong(tsk))); in __tipc_shutdown()
529 tipc_node_remove_conn(net, dnode, tsk->portid); in __tipc_shutdown()
540 tsk_own_node(tsk), tsk_peer_port(tsk), in __tipc_shutdown()
541 tsk->portid, error); in __tipc_shutdown()
543 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); in __tipc_shutdown()
544 tipc_node_remove_conn(net, dnode, tsk->portid); in __tipc_shutdown()
568 struct tipc_sock *tsk; in tipc_release() local
577 tsk = tipc_sk(sk); in tipc_release()
583 tipc_sk_leave(tsk); in tipc_release()
584 tipc_sk_withdraw(tsk, 0, NULL); in tipc_release()
585 __skb_queue_purge(&tsk->mc_method.deferredq); in tipc_release()
587 tipc_sk_remove(tsk); in tipc_release()
592 tipc_dest_list_purge(&tsk->cong_links); in tipc_release()
593 tsk->cong_link_cnt = 0; in tipc_release()
594 call_rcu(&tsk->rcu, tipc_sk_callback); in tipc_release()
620 struct tipc_sock *tsk = tipc_sk(sk); in tipc_bind() local
625 res = tipc_sk_withdraw(tsk, 0, NULL); in tipc_bind()
628 if (tsk->group) { in tipc_bind()
656 tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : in tipc_bind()
657 tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); in tipc_bind()
681 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getname() local
688 addr->addr.id.ref = tsk_peer_port(tsk); in tipc_getname()
689 addr->addr.id.node = tsk_peer_node(tsk); in tipc_getname()
691 addr->addr.id.ref = tsk->portid; in tipc_getname()
725 struct tipc_sock *tsk = tipc_sk(sk); in tipc_poll() local
738 if (!tsk->cong_link_cnt && !tsk_conn_cong(tsk)) in tipc_poll()
747 if (tsk->group_is_open && !tsk->cong_link_cnt) in tipc_poll()
777 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sendmcast() local
778 struct tipc_msg *hdr = &tsk->phdr; in tipc_sendmcast()
781 struct tipc_mc_method *method = &tsk->mc_method; in tipc_sendmcast()
786 if (tsk->group) in tipc_sendmcast()
790 rc = tipc_wait_for_cond(sock, &timeout, !tsk->cong_link_cnt); in tipc_sendmcast()
820 &tsk->cong_link_cnt); in tipc_sendmcast()
837 static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, in tipc_send_group_msg() argument
841 u16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group); in tipc_send_group_msg()
842 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_msg()
844 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_msg()
857 mtu = tipc_node_get_mtu(net, dnode, tsk->portid); in tipc_send_group_msg()
863 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in tipc_send_group_msg()
865 tipc_dest_push(&tsk->cong_links, dnode, 0); in tipc_send_group_msg()
866 tsk->cong_link_cnt++; in tipc_send_group_msg()
894 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_unicast() local
907 !tipc_dest_find(&tsk->cong_links, node, 0) && in tipc_send_group_unicast()
908 tsk->group && in tipc_send_group_unicast()
909 !tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_unicast()
917 rc = tipc_send_group_msg(net, tsk, m, mb, node, port, dlen); in tipc_send_group_unicast()
937 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_anycast() local
938 struct list_head *cong_links = &tsk->cong_links; in tipc_send_group_anycast()
940 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_anycast()
958 exclude = tipc_group_exclude(tsk->group); in tipc_send_group_anycast()
968 cong = tipc_group_cong(tsk->group, node, port, blks, in tipc_send_group_anycast()
988 tsk->group && in tipc_send_group_anycast()
989 !tipc_group_cong(tsk->group, node, port, in tipc_send_group_anycast()
1002 rc = tipc_send_group_msg(net, tsk, m, mbr, node, port, dlen); in tipc_send_group_anycast()
1023 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_bcast() local
1025 struct tipc_mc_method *method = &tsk->mc_method; in tipc_send_group_bcast()
1028 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_bcast()
1035 !tsk->cong_link_cnt && tsk->group && in tipc_send_group_bcast()
1036 !tipc_group_bc_cong(tsk->group, blks)); in tipc_send_group_bcast()
1040 dsts = tipc_group_dests(tsk->group); in tipc_send_group_bcast()
1055 msg_set_grp_bc_seqno(hdr, tipc_group_bc_snd_nxt(tsk->group)); in tipc_send_group_bcast()
1067 rc = tipc_mcast_xmit(net, &pkts, method, dsts, &tsk->cong_link_cnt); in tipc_send_group_bcast()
1072 tipc_group_update_bc_members(tsk->group, blks, ack); in tipc_send_group_bcast()
1096 struct tipc_sock *tsk = tipc_sk(sk); in tipc_send_group_mcast() local
1097 struct tipc_group *grp = tsk->group; in tipc_send_group_mcast()
1098 struct tipc_msg *hdr = &tsk->phdr; in tipc_send_group_mcast()
1216 static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb, in tipc_sk_conn_proto_rcv() argument
1221 u32 onode = tsk_own_node(tsk); in tipc_sk_conn_proto_rcv()
1222 struct sock *sk = &tsk->sk; in tipc_sk_conn_proto_rcv()
1227 if (!tsk_peer_msg(tsk, hdr)) { in tipc_sk_conn_proto_rcv()
1234 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk), in tipc_sk_conn_proto_rcv()
1235 tsk_peer_port(tsk)); in tipc_sk_conn_proto_rcv()
1249 tsk->probe_unacked = false; in tipc_sk_conn_proto_rcv()
1257 conn_cong = tsk_conn_cong(tsk); in tipc_sk_conn_proto_rcv()
1258 tsk->snt_unacked -= msg_conn_ack(hdr); in tipc_sk_conn_proto_rcv()
1259 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_conn_proto_rcv()
1260 tsk->snd_win = msg_adv_win(hdr); in tipc_sk_conn_proto_rcv()
1300 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendmsg() local
1303 struct list_head *clinks = &tsk->cong_links; in __tipc_sendmsg()
1305 struct tipc_group *grp = tsk->group; in __tipc_sendmsg()
1306 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendmsg()
1336 dest = &tsk->peer; in __tipc_sendmsg()
1346 if (tsk->published) in __tipc_sendmsg()
1349 tsk->conn_type = dest->addr.name.name.type; in __tipc_sendmsg()
1350 tsk->conn_instance = dest->addr.name.name.instance; in __tipc_sendmsg()
1391 mtu = tipc_node_get_mtu(net, dnode, tsk->portid); in __tipc_sendmsg()
1399 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in __tipc_sendmsg()
1402 tsk->cong_link_cnt++; in __tipc_sendmsg()
1440 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendstream() local
1441 struct tipc_msg *hdr = &tsk->phdr; in __tipc_sendstream()
1444 u32 dnode = tsk_peer_node(tsk); in __tipc_sendstream()
1457 tsk->peer_caps = tipc_node_get_capabilities(net, dnode); in __tipc_sendstream()
1458 tsk->snt_unacked = tsk_inc(tsk, dlen + msg_hdr_sz(hdr)); in __tipc_sendstream()
1465 (!tsk->cong_link_cnt && in __tipc_sendstream()
1466 !tsk_conn_cong(tsk) && in __tipc_sendstream()
1472 rc = tipc_msg_build(hdr, m, sent, send, tsk->max_pkt, &pkts); in __tipc_sendstream()
1478 rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); in __tipc_sendstream()
1480 tsk->cong_link_cnt = 1; in __tipc_sendstream()
1484 tsk->snt_unacked += tsk_inc(tsk, send + MIN_H_SIZE); in __tipc_sendstream()
1512 static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, in tipc_sk_finish_conn() argument
1515 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1517 struct tipc_msg *msg = &tsk->phdr; in tipc_sk_finish_conn()
1528 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); in tipc_sk_finish_conn()
1529 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid); in tipc_sk_finish_conn()
1530 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node); in tipc_sk_finish_conn()
1532 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_finish_conn()
1536 tsk->rcv_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1537 tsk->snd_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1587 struct tipc_sock *tsk) in tipc_sk_anc_data_recv() argument
1635 has_name = (tsk->conn_type != 0); in tipc_sk_anc_data_recv()
1636 anc_data[0] = tsk->conn_type; in tipc_sk_anc_data_recv()
1637 anc_data[1] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1638 anc_data[2] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1652 static void tipc_sk_send_ack(struct tipc_sock *tsk) in tipc_sk_send_ack() argument
1654 struct sock *sk = &tsk->sk; in tipc_sk_send_ack()
1658 u32 peer_port = tsk_peer_port(tsk); in tipc_sk_send_ack()
1659 u32 dnode = tsk_peer_node(tsk); in tipc_sk_send_ack()
1664 dnode, tsk_own_node(tsk), peer_port, in tipc_sk_send_ack()
1665 tsk->portid, TIPC_OK); in tipc_sk_send_ack()
1669 msg_set_conn_ack(msg, tsk->rcv_unacked); in tipc_sk_send_ack()
1670 tsk->rcv_unacked = 0; in tipc_sk_send_ack()
1673 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) { in tipc_sk_send_ack()
1674 tsk->rcv_win = tsk_adv_blocks(tsk->sk.sk_rcvbuf); in tipc_sk_send_ack()
1675 msg_set_adv_win(msg, tsk->rcv_win); in tipc_sk_send_ack()
1737 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvmsg() local
1774 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvmsg()
1807 if (tsk->group && msg_in_group(hdr) && !grp_evt) { in tipc_recvmsg()
1809 tipc_group_update_rcv_win(tsk->group, tsk_blocks(hlen + dlen), in tipc_recvmsg()
1821 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvmsg()
1822 if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE) in tipc_recvmsg()
1823 tipc_sk_send_ack(tsk); in tipc_recvmsg()
1844 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvstream() local
1887 rc = tipc_sk_anc_data_recv(m, skb, tsk); in tipc_recvstream()
1921 tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen); in tipc_recvstream()
1922 if (unlikely(tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE)) in tipc_recvstream()
1923 tipc_sk_send_ack(tsk); in tipc_recvstream()
1978 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_proto_rcv() local
1980 struct tipc_group *grp = tsk->group; in tipc_sk_proto_rcv()
1985 tipc_sk_conn_proto_rcv(tsk, skb, inputq, xmitq); in tipc_sk_proto_rcv()
1988 tipc_dest_del(&tsk->cong_links, msg_orignode(hdr), 0); in tipc_sk_proto_rcv()
1991 tsk->cong_link_cnt--; in tipc_sk_proto_rcv()
1998 tipc_group_member_evt(tsk->group, &wakeup, &sk->sk_rcvbuf, in tipc_sk_proto_rcv()
2017 static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb) in tipc_sk_filter_connect() argument
2019 struct sock *sk = &tsk->sk; in tipc_sk_filter_connect()
2023 u32 pport = tsk_peer_port(tsk); in tipc_sk_filter_connect()
2024 u32 pnode = tsk_peer_node(tsk); in tipc_sk_filter_connect()
2039 tipc_sk_finish_conn(tsk, oport, onode); in tipc_sk_filter_connect()
2040 msg_set_importance(&tsk->phdr, msg_importance(hdr)); in tipc_sk_filter_connect()
2061 delay %= (tsk->conn_timeout / 4); in tipc_sk_filter_connect()
2080 if (!tsk_peer_msg(tsk, hdr)) in tipc_sk_filter_connect()
2085 tipc_node_remove_conn(net, pnode, tsk->portid); in tipc_sk_filter_connect()
2118 struct tipc_sock *tsk = tipc_sk(sk); in rcvbuf_limit() local
2127 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in rcvbuf_limit()
2148 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_filter_rcv() local
2149 struct tipc_group *grp = tsk->group; in tipc_sk_filter_rcv()
2168 tipc_mcast_filter_msg(net, &tsk->mc_method.deferredq, &inputq); in tipc_sk_filter_rcv()
2174 if ((sk_conn && !tipc_sk_filter_connect(tsk, skb)) || in tipc_sk_filter_rcv()
2293 struct tipc_sock *tsk; in tipc_sk_rcv() local
2300 tsk = tipc_sk_lookup(net, dport); in tipc_sk_rcv()
2302 if (likely(tsk)) { in tipc_sk_rcv()
2303 sk = &tsk->sk; in tipc_sk_rcv()
2380 struct tipc_sock *tsk = tipc_sk(sk); in tipc_connect() local
2383 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; in tipc_connect()
2392 if (tsk->group) { in tipc_connect()
2398 memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc)); in tipc_connect()
2409 memcpy(&tsk->peer, dest, destlen); in tipc_connect()
2633 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_check_probing_state() local
2634 u32 pnode = tsk_peer_node(tsk); in tipc_sk_check_probing_state()
2635 u32 pport = tsk_peer_port(tsk); in tipc_sk_check_probing_state()
2636 u32 self = tsk_own_node(tsk); in tipc_sk_check_probing_state()
2637 u32 oport = tsk->portid; in tipc_sk_check_probing_state()
2640 if (tsk->probe_unacked) { in tipc_sk_check_probing_state()
2652 tsk->probe_unacked = true; in tipc_sk_check_probing_state()
2658 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_retry_connect() local
2661 if (tsk->cong_link_cnt) { in tipc_sk_retry_connect()
2672 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sk_timeout() local
2673 u32 pnode = tsk_peer_node(tsk); in tipc_sk_timeout()
2695 rc = tipc_node_xmit(sock_net(sk), &list, pnode, tsk->portid); in tipc_sk_timeout()
2699 tipc_dest_push(&tsk->cong_links, pnode, 0); in tipc_sk_timeout()
2700 tsk->cong_link_cnt = 1; in tipc_sk_timeout()
2705 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, in tipc_sk_publish() argument
2708 struct sock *sk = &tsk->sk; in tipc_sk_publish()
2718 key = tsk->portid + tsk->pub_count + 1; in tipc_sk_publish()
2719 if (key == tsk->portid) in tipc_sk_publish()
2723 scope, tsk->portid, key); in tipc_sk_publish()
2727 list_add(&publ->binding_sock, &tsk->publications); in tipc_sk_publish()
2728 tsk->pub_count++; in tipc_sk_publish()
2729 tsk->published = 1; in tipc_sk_publish()
2733 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, in tipc_sk_withdraw() argument
2736 struct net *net = sock_net(&tsk->sk); in tipc_sk_withdraw()
2744 list_for_each_entry_safe(publ, safe, &tsk->publications, binding_sock) { in tipc_sk_withdraw()
2763 if (list_empty(&tsk->publications)) in tipc_sk_withdraw()
2764 tsk->published = 0; in tipc_sk_withdraw()
2775 struct tipc_sock *tsk; in tipc_sk_reinit() local
2783 while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) { in tipc_sk_reinit()
2784 sock_hold(&tsk->sk); in tipc_sk_reinit()
2786 lock_sock(&tsk->sk); in tipc_sk_reinit()
2787 msg = &tsk->phdr; in tipc_sk_reinit()
2790 release_sock(&tsk->sk); in tipc_sk_reinit()
2792 sock_put(&tsk->sk); in tipc_sk_reinit()
2796 } while (tsk == ERR_PTR(-EAGAIN)); in tipc_sk_reinit()
2804 struct tipc_sock *tsk; in tipc_sk_lookup() local
2807 tsk = rhashtable_lookup_fast(&tn->sk_rht, &portid, tsk_rht_params); in tipc_sk_lookup()
2808 if (tsk) in tipc_sk_lookup()
2809 sock_hold(&tsk->sk); in tipc_sk_lookup()
2812 return tsk; in tipc_sk_lookup()
2815 static int tipc_sk_insert(struct tipc_sock *tsk) in tipc_sk_insert() argument
2817 struct sock *sk = &tsk->sk; in tipc_sk_insert()
2827 tsk->portid = portid; in tipc_sk_insert()
2828 sock_hold(&tsk->sk); in tipc_sk_insert()
2829 if (!rhashtable_lookup_insert_fast(&tn->sk_rht, &tsk->node, in tipc_sk_insert()
2832 sock_put(&tsk->sk); in tipc_sk_insert()
2838 static void tipc_sk_remove(struct tipc_sock *tsk) in tipc_sk_remove() argument
2840 struct sock *sk = &tsk->sk; in tipc_sk_remove()
2843 if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { in tipc_sk_remove()
2876 static int tipc_sk_join(struct tipc_sock *tsk, struct tipc_group_req *mreq) in tipc_sk_join() argument
2878 struct net *net = sock_net(&tsk->sk); in tipc_sk_join()
2879 struct tipc_group *grp = tsk->group; in tipc_sk_join()
2880 struct tipc_msg *hdr = &tsk->phdr; in tipc_sk_join()
2890 grp = tipc_group_create(net, tsk->portid, mreq, &tsk->group_is_open); in tipc_sk_join()
2893 tsk->group = grp; in tipc_sk_join()
2901 rc = tipc_sk_publish(tsk, mreq->scope, &seq); in tipc_sk_join()
2904 tsk->group = NULL; in tipc_sk_join()
2908 tsk->mc_method.rcast = true; in tipc_sk_join()
2909 tsk->mc_method.mandatory = true; in tipc_sk_join()
2910 tipc_group_join(net, grp, &tsk->sk.sk_rcvbuf); in tipc_sk_join()
2914 static int tipc_sk_leave(struct tipc_sock *tsk) in tipc_sk_leave() argument
2916 struct net *net = sock_net(&tsk->sk); in tipc_sk_leave()
2917 struct tipc_group *grp = tsk->group; in tipc_sk_leave()
2925 tsk->group = NULL; in tipc_sk_leave()
2926 tipc_sk_withdraw(tsk, scope, &seq); in tipc_sk_leave()
2947 struct tipc_sock *tsk = tipc_sk(sk); in tipc_setsockopt() local
2982 res = tsk_set_importance(tsk, value); in tipc_setsockopt()
2986 tsk_set_unreliable(tsk, value); in tipc_setsockopt()
2991 tsk_set_unreturnable(tsk, value); in tipc_setsockopt()
2997 tsk->mc_method.rcast = false; in tipc_setsockopt()
2998 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3001 tsk->mc_method.rcast = true; in tipc_setsockopt()
3002 tsk->mc_method.mandatory = true; in tipc_setsockopt()
3005 res = tipc_sk_join(tsk, &mreq); in tipc_setsockopt()
3008 res = tipc_sk_leave(tsk); in tipc_setsockopt()
3036 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getsockopt() local
3054 value = tsk_importance(tsk); in tipc_getsockopt()
3057 value = tsk_unreliable(tsk); in tipc_getsockopt()
3060 value = tsk_unreturnable(tsk); in tipc_getsockopt()
3063 value = tsk->conn_timeout; in tipc_getsockopt()
3077 if (tsk->group) in tipc_getsockopt()
3078 tipc_group_self(tsk->group, &seq, &scope); in tipc_getsockopt()
3266 static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) in __tipc_nl_add_sk_con() argument
3272 peer_node = tsk_peer_node(tsk); in __tipc_nl_add_sk_con()
3273 peer_port = tsk_peer_port(tsk); in __tipc_nl_add_sk_con()
3284 if (tsk->conn_type != 0) { in __tipc_nl_add_sk_con()
3287 if (nla_put_u32(skb, TIPC_NLA_CON_TYPE, tsk->conn_type)) in __tipc_nl_add_sk_con()
3289 if (nla_put_u32(skb, TIPC_NLA_CON_INST, tsk->conn_instance)) in __tipc_nl_add_sk_con()
3303 *tsk) in __tipc_nl_add_sk_info()
3306 struct sock *sk = &tsk->sk; in __tipc_nl_add_sk_info()
3308 if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid) || in __tipc_nl_add_sk_info()
3313 if (__tipc_nl_add_sk_con(skb, tsk)) in __tipc_nl_add_sk_info()
3315 } else if (!list_empty(&tsk->publications)) { in __tipc_nl_add_sk_info()
3324 struct tipc_sock *tsk) in __tipc_nl_add_sk() argument
3338 if (__tipc_nl_add_sk_info(skb, tsk)) in __tipc_nl_add_sk()
3357 struct tipc_sock *tsk)) in tipc_nl_sk_walk() argument
3360 struct tipc_sock *tsk; in tipc_nl_sk_walk() local
3364 while ((tsk = rhashtable_walk_next(iter)) != NULL) { in tipc_nl_sk_walk()
3365 if (IS_ERR(tsk)) { in tipc_nl_sk_walk()
3366 err = PTR_ERR(tsk); in tipc_nl_sk_walk()
3374 sock_hold(&tsk->sk); in tipc_nl_sk_walk()
3376 lock_sock(&tsk->sk); in tipc_nl_sk_walk()
3377 err = skb_handler(skb, cb, tsk); in tipc_nl_sk_walk()
3379 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3380 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3383 release_sock(&tsk->sk); in tipc_nl_sk_walk()
3385 sock_put(&tsk->sk); in tipc_nl_sk_walk()
3428 struct tipc_sock *tsk, u32 sk_filter_state, in tipc_sk_fill_sock_diag() argument
3431 struct sock *sk = &tsk->sk; in tipc_sk_fill_sock_diag()
3443 if (__tipc_nl_add_sk_info(skb, tsk)) in tipc_sk_fill_sock_diag()
3469 if (tsk->cong_link_cnt && in tipc_sk_fill_sock_diag()
3473 if (tsk_conn_cong(tsk) && in tipc_sk_fill_sock_diag()
3479 if (tsk->group) in tipc_sk_fill_sock_diag()
3480 if (tipc_group_fill_sock_diag(tsk->group, skb)) in tipc_sk_fill_sock_diag()
3543 struct tipc_sock *tsk, u32 *last_publ) in __tipc_nl_list_sk_publ() argument
3549 list_for_each_entry(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3565 p = list_first_entry(&tsk->publications, struct publication, in __tipc_nl_list_sk_publ()
3569 list_for_each_entry_from(p, &tsk->publications, binding_sock) { in __tipc_nl_list_sk_publ()
3588 struct tipc_sock *tsk; in tipc_nl_publ_dump() local
3616 tsk = tipc_sk_lookup(net, tsk_portid); in tipc_nl_publ_dump()
3617 if (!tsk) in tipc_nl_publ_dump()
3620 lock_sock(&tsk->sk); in tipc_nl_publ_dump()
3621 err = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ); in tipc_nl_publ_dump()
3624 release_sock(&tsk->sk); in tipc_nl_publ_dump()
3625 sock_put(&tsk->sk); in tipc_nl_publ_dump()
3646 struct tipc_sock *tsk; in tipc_sk_filtering() local
3654 tsk = tipc_sk(sk); in tipc_sk_filtering()
3666 return (_port == tsk->portid); in tipc_sk_filtering()
3671 if (tsk->published) { in tipc_sk_filtering()
3672 p = list_first_entry_or_null(&tsk->publications, in tipc_sk_filtering()
3682 type = tsk->conn_type; in tipc_sk_filtering()
3683 lower = tsk->conn_instance; in tipc_sk_filtering()
3684 upper = tsk->conn_instance; in tipc_sk_filtering()
3749 struct tipc_sock *tsk; in tipc_sk_dump() local
3758 tsk = tipc_sk(sk); in tipc_sk_dump()
3763 i += scnprintf(buf + i, sz - i, " %x", tsk_own_node(tsk)); in tipc_sk_dump()
3764 i += scnprintf(buf + i, sz - i, " %u", tsk->portid); in tipc_sk_dump()
3767 i += scnprintf(buf + i, sz - i, " %x", tsk_peer_node(tsk)); in tipc_sk_dump()
3768 i += scnprintf(buf + i, sz - i, " %u", tsk_peer_port(tsk)); in tipc_sk_dump()
3769 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_type); in tipc_sk_dump()
3770 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_instance); in tipc_sk_dump()
3772 i += scnprintf(buf + i, sz - i, " | %u", tsk->published); in tipc_sk_dump()
3773 if (tsk->published) { in tipc_sk_dump()
3774 p = list_first_entry_or_null(&tsk->publications, in tipc_sk_dump()
3780 i += scnprintf(buf + i, sz - i, " | %u", tsk->snd_win); in tipc_sk_dump()
3781 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_win); in tipc_sk_dump()
3782 i += scnprintf(buf + i, sz - i, " %u", tsk->max_pkt); in tipc_sk_dump()
3783 i += scnprintf(buf + i, sz - i, " %x", tsk->peer_caps); in tipc_sk_dump()
3784 i += scnprintf(buf + i, sz - i, " %u", tsk->cong_link_cnt); in tipc_sk_dump()
3785 i += scnprintf(buf + i, sz - i, " %u", tsk->snt_unacked); in tipc_sk_dump()
3786 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_unacked); in tipc_sk_dump()
3787 i += scnprintf(buf + i, sz - i, " %u", atomic_read(&tsk->dupl_rcvcnt)); in tipc_sk_dump()