Lines Matching refs:tsk
111 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope,
113 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope,
116 static int tipc_sk_insert(struct tipc_sock *tsk);
117 static void tipc_sk_remove(struct tipc_sock *tsk);
182 static u32 tsk_own_node(struct tipc_sock *tsk) in tsk_own_node() argument
184 return msg_prevnode(&tsk->phdr); in tsk_own_node()
187 static u32 tsk_peer_node(struct tipc_sock *tsk) in tsk_peer_node() argument
189 return msg_destnode(&tsk->phdr); in tsk_peer_node()
192 static u32 tsk_peer_port(struct tipc_sock *tsk) in tsk_peer_port() argument
194 return msg_destport(&tsk->phdr); in tsk_peer_port()
197 static bool tsk_unreliable(struct tipc_sock *tsk) in tsk_unreliable() argument
199 return msg_src_droppable(&tsk->phdr) != 0; in tsk_unreliable()
202 static void tsk_set_unreliable(struct tipc_sock *tsk, bool unreliable) in tsk_set_unreliable() argument
204 msg_set_src_droppable(&tsk->phdr, unreliable ? 1 : 0); in tsk_set_unreliable()
207 static bool tsk_unreturnable(struct tipc_sock *tsk) in tsk_unreturnable() argument
209 return msg_dest_droppable(&tsk->phdr) != 0; in tsk_unreturnable()
212 static void tsk_set_unreturnable(struct tipc_sock *tsk, bool unreturnable) in tsk_set_unreturnable() argument
214 msg_set_dest_droppable(&tsk->phdr, unreturnable ? 1 : 0); in tsk_set_unreturnable()
217 static int tsk_importance(struct tipc_sock *tsk) in tsk_importance() argument
219 return msg_importance(&tsk->phdr); in tsk_importance()
222 static int tsk_set_importance(struct tipc_sock *tsk, int imp) in tsk_set_importance() argument
226 msg_set_importance(&tsk->phdr, (u32)imp); in tsk_set_importance()
235 static int tsk_conn_cong(struct tipc_sock *tsk) in tsk_conn_cong() argument
237 return tsk->sent_unacked >= TIPC_FLOWCTRL_WIN; in tsk_conn_cong()
272 static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) in tsk_peer_msg() argument
274 struct tipc_net *tn = net_generic(sock_net(&tsk->sk), tipc_net_id); in tsk_peer_msg()
275 u32 peer_port = tsk_peer_port(tsk); in tsk_peer_msg()
279 if (unlikely(!tsk->connected)) in tsk_peer_msg()
286 peer_node = tsk_peer_node(tsk); in tsk_peer_msg()
319 struct tipc_sock *tsk; in tipc_sk_create() local
349 tsk = tipc_sk(sk); in tipc_sk_create()
350 tsk->max_pkt = MAX_PKT_DEFAULT; in tipc_sk_create()
351 INIT_LIST_HEAD(&tsk->publications); in tipc_sk_create()
352 msg = &tsk->phdr; in tipc_sk_create()
361 if (tipc_sk_insert(tsk)) { in tipc_sk_create()
365 msg_set_origport(msg, tsk->portid); in tipc_sk_create()
366 setup_timer(&sk->sk_timer, tipc_sk_timeout, (unsigned long)tsk); in tipc_sk_create()
371 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; in tipc_sk_create()
372 tsk->sent_unacked = 0; in tipc_sk_create()
373 atomic_set(&tsk->dupl_rcvcnt, 0); in tipc_sk_create()
376 tsk_set_unreturnable(tsk, true); in tipc_sk_create()
378 tsk_set_unreliable(tsk, true); in tipc_sk_create()
385 struct tipc_sock *tsk = container_of(head, struct tipc_sock, rcu); in tipc_sk_callback() local
387 sock_put(&tsk->sk); in tipc_sk_callback()
410 struct tipc_sock *tsk; in tipc_release() local
422 tsk = tipc_sk(sk); in tipc_release()
429 dnode = tsk_peer_node(tsk); in tipc_release()
440 tsk->connected = 0; in tipc_release()
441 tipc_node_remove_conn(net, dnode, tsk->portid); in tipc_release()
443 if (tipc_msg_reverse(tsk_own_node(tsk), skb, &dnode, in tipc_release()
449 tipc_sk_withdraw(tsk, 0, NULL); in tipc_release()
450 probing_state = tsk->probing_state; in tipc_release()
454 tipc_sk_remove(tsk); in tipc_release()
455 if (tsk->connected) { in tipc_release()
458 tsk_own_node(tsk), tsk_peer_port(tsk), in tipc_release()
459 tsk->portid, TIPC_ERR_NO_PORT); in tipc_release()
461 tipc_link_xmit_skb(net, skb, dnode, tsk->portid); in tipc_release()
462 tipc_node_remove_conn(net, dnode, tsk->portid); in tipc_release()
472 call_rcu(&tsk->rcu, tipc_sk_callback); in tipc_release()
498 struct tipc_sock *tsk = tipc_sk(sk); in tipc_bind() local
503 res = tipc_sk_withdraw(tsk, 0, NULL); in tipc_bind()
531 tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : in tipc_bind()
532 tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); in tipc_bind()
555 struct tipc_sock *tsk = tipc_sk(sock->sk); in tipc_getname() local
563 addr->addr.id.ref = tsk_peer_port(tsk); in tipc_getname()
564 addr->addr.id.node = tsk_peer_node(tsk); in tipc_getname()
566 addr->addr.id.ref = tsk->portid; in tipc_getname()
623 struct tipc_sock *tsk = tipc_sk(sk); in tipc_poll() local
630 if (!tsk->link_cong) in tipc_poll()
635 if (!tsk->link_cong && !tsk_conn_cong(tsk)) in tipc_poll()
666 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sendmcast() local
668 struct tipc_msg *mhdr = &tsk->phdr; in tipc_sendmcast()
770 static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff **skb) in tipc_sk_proto_rcv() argument
775 u32 own_node = tsk_own_node(tsk); in tipc_sk_proto_rcv()
777 if (!tsk_peer_msg(tsk, msg)) in tipc_sk_proto_rcv()
780 tsk->probing_state = TIPC_CONN_OK; in tipc_sk_proto_rcv()
783 conn_cong = tsk_conn_cong(tsk); in tipc_sk_proto_rcv()
784 tsk->sent_unacked -= msg_msgcnt(msg); in tipc_sk_proto_rcv()
786 tsk->sk.sk_write_space(&tsk->sk); in tipc_sk_proto_rcv()
802 struct tipc_sock *tsk = tipc_sk(sk); in tipc_wait_for_sndmsg() local
818 done = sk_wait_event(sk, timeo_p, !tsk->link_cong); in tipc_wait_for_sndmsg()
854 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendmsg() local
856 struct tipc_msg *mhdr = &tsk->phdr; in __tipc_sendmsg()
869 if (tsk->connected && sock->state == SS_READY) in __tipc_sendmsg()
870 dest = &tsk->remote; in __tipc_sendmsg()
882 if (tsk->published) in __tipc_sendmsg()
885 tsk->conn_type = dest->addr.name.name.type; in __tipc_sendmsg()
886 tsk->conn_instance = dest->addr.name.name.instance; in __tipc_sendmsg()
921 mtu = tipc_node_get_mtu(net, dnode, tsk->portid); in __tipc_sendmsg()
928 TIPC_SKB_CB(skb)->wakeup_pending = tsk->link_cong; in __tipc_sendmsg()
929 rc = tipc_link_xmit(net, pktchain, dnode, tsk->portid); in __tipc_sendmsg()
942 tsk->link_cong = 1; in __tipc_sendmsg()
954 struct tipc_sock *tsk = tipc_sk(sk); in tipc_wait_for_sndpkt() local
973 (!tsk->link_cong && in tipc_wait_for_sndpkt()
974 !tsk_conn_cong(tsk)) || in tipc_wait_for_sndpkt()
975 !tsk->connected); in tipc_wait_for_sndpkt()
1008 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_send_stream() local
1009 struct tipc_msg *mhdr = &tsk->phdr; in __tipc_send_stream()
1012 u32 portid = tsk->portid; in __tipc_send_stream()
1023 tsk->sent_unacked = 1; in __tipc_send_stream()
1037 dnode = tsk_peer_node(tsk); in __tipc_send_stream()
1041 mtu = tsk->max_pkt; in __tipc_send_stream()
1047 if (likely(!tsk_conn_cong(tsk))) { in __tipc_send_stream()
1050 tsk->sent_unacked++; in __tipc_send_stream()
1057 tsk->max_pkt = tipc_node_get_mtu(net, dnode, in __tipc_send_stream()
1064 tsk->link_cong = 1; in __tipc_send_stream()
1094 static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, in tipc_sk_finish_conn() argument
1097 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1099 struct tipc_msg *msg = &tsk->phdr; in tipc_sk_finish_conn()
1107 tsk->probing_intv = CONN_PROBING_INTERVAL; in tipc_sk_finish_conn()
1108 tsk->probing_state = TIPC_CONN_OK; in tipc_sk_finish_conn()
1109 tsk->connected = 1; in tipc_sk_finish_conn()
1110 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv); in tipc_sk_finish_conn()
1111 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); in tipc_sk_finish_conn()
1112 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid); in tipc_sk_finish_conn()
1149 struct tipc_sock *tsk) in tipc_sk_anc_data_recv() argument
1192 has_name = (tsk->conn_type != 0); in tipc_sk_anc_data_recv()
1193 anc_data[0] = tsk->conn_type; in tipc_sk_anc_data_recv()
1194 anc_data[1] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1195 anc_data[2] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1209 static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) in tipc_sk_send_ack() argument
1211 struct net *net = sock_net(&tsk->sk); in tipc_sk_send_ack()
1214 u32 peer_port = tsk_peer_port(tsk); in tipc_sk_send_ack()
1215 u32 dnode = tsk_peer_node(tsk); in tipc_sk_send_ack()
1217 if (!tsk->connected) in tipc_sk_send_ack()
1220 dnode, tsk_own_node(tsk), peer_port, in tipc_sk_send_ack()
1221 tsk->portid, TIPC_OK); in tipc_sk_send_ack()
1277 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvmsg() local
1320 res = tipc_sk_anc_data_recv(m, msg, tsk); in tipc_recvmsg()
1345 (++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) { in tipc_recvmsg()
1346 tipc_sk_send_ack(tsk, tsk->rcv_unacked); in tipc_recvmsg()
1347 tsk->rcv_unacked = 0; in tipc_recvmsg()
1371 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recv_stream() local
1416 res = tipc_sk_anc_data_recv(m, msg, tsk); in tipc_recv_stream()
1454 if (unlikely(++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) { in tipc_recv_stream()
1455 tipc_sk_send_ack(tsk, tsk->rcv_unacked); in tipc_recv_stream()
1456 tsk->rcv_unacked = 0; in tipc_recv_stream()
1514 static int filter_connect(struct tipc_sock *tsk, struct sk_buff **skb) in filter_connect() argument
1516 struct sock *sk = &tsk->sk; in filter_connect()
1528 if (tsk_peer_msg(tsk, msg)) { in filter_connect()
1531 tsk->connected = 0; in filter_connect()
1533 tipc_node_remove_conn(net, tsk_peer_node(tsk), in filter_connect()
1534 tsk->portid); in filter_connect()
1559 tipc_sk_finish_conn(tsk, msg_origport(msg), msg_orignode(msg)); in filter_connect()
1560 msg_set_importance(&tsk->phdr, msg_importance(msg)); in filter_connect()
1634 struct tipc_sock *tsk = tipc_sk(sk); in filter_rcv() local
1640 tipc_sk_proto_rcv(tsk, skb); in filter_rcv()
1646 tsk->link_cong = 0; in filter_rcv()
1660 rc = filter_connect(tsk, skb); in filter_rcv()
1693 struct tipc_sock *tsk = tipc_sk(sk); in tipc_backlog_rcv() local
1699 dcnt = &tsk->dupl_rcvcnt; in tipc_backlog_rcv()
1704 if (!err || tipc_msg_reverse(tsk_own_node(tsk), skb, &dnode, -err)) in tipc_backlog_rcv()
1705 tipc_link_xmit_skb(net, skb, dnode, tsk->portid); in tipc_backlog_rcv()
1769 struct tipc_sock *tsk; in tipc_sk_rcv() local
1777 tsk = tipc_sk_lookup(net, dport); in tipc_sk_rcv()
1778 if (likely(tsk)) { in tipc_sk_rcv()
1779 sk = &tsk->sk; in tipc_sk_rcv()
1841 struct tipc_sock *tsk = tipc_sk(sk); in tipc_connect() local
1844 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; in tipc_connect()
1853 memset(&tsk->remote, 0, sizeof(struct sockaddr_tipc)); in tipc_connect()
1854 tsk->connected = 0; in tipc_connect()
1858 memcpy(&tsk->remote, dest, destlen); in tipc_connect()
1859 tsk->connected = 1; in tipc_connect()
2070 struct tipc_sock *tsk = tipc_sk(sk); in tipc_shutdown() local
2092 if (tipc_msg_reverse(tsk_own_node(tsk), skb, &dnode, in tipc_shutdown()
2095 tsk->portid); in tipc_shutdown()
2097 dnode = tsk_peer_node(tsk); in tipc_shutdown()
2101 0, dnode, tsk_own_node(tsk), in tipc_shutdown()
2102 tsk_peer_port(tsk), in tipc_shutdown()
2103 tsk->portid, TIPC_CONN_SHUTDOWN); in tipc_shutdown()
2104 tipc_link_xmit_skb(net, skb, dnode, tsk->portid); in tipc_shutdown()
2106 tsk->connected = 0; in tipc_shutdown()
2108 tipc_node_remove_conn(net, dnode, tsk->portid); in tipc_shutdown()
2131 struct tipc_sock *tsk = (struct tipc_sock *)data; in tipc_sk_timeout() local
2132 struct sock *sk = &tsk->sk; in tipc_sk_timeout()
2135 u32 own_node = tsk_own_node(tsk); in tipc_sk_timeout()
2138 if (!tsk->connected) { in tipc_sk_timeout()
2142 peer_port = tsk_peer_port(tsk); in tipc_sk_timeout()
2143 peer_node = tsk_peer_node(tsk); in tipc_sk_timeout()
2145 if (tsk->probing_state == TIPC_CONN_PROBING) { in tipc_sk_timeout()
2148 tsk->connected = 0; in tipc_sk_timeout()
2149 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk), in tipc_sk_timeout()
2150 tsk_peer_port(tsk)); in tipc_sk_timeout()
2160 peer_port, tsk->portid, TIPC_OK); in tipc_sk_timeout()
2161 tsk->probing_state = TIPC_CONN_PROBING; in tipc_sk_timeout()
2162 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv); in tipc_sk_timeout()
2166 tipc_link_xmit_skb(sock_net(sk), skb, peer_node, tsk->portid); in tipc_sk_timeout()
2171 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, in tipc_sk_publish() argument
2174 struct net *net = sock_net(&tsk->sk); in tipc_sk_publish()
2178 if (tsk->connected) in tipc_sk_publish()
2180 key = tsk->portid + tsk->pub_count + 1; in tipc_sk_publish()
2181 if (key == tsk->portid) in tipc_sk_publish()
2185 scope, tsk->portid, key); in tipc_sk_publish()
2189 list_add(&publ->pport_list, &tsk->publications); in tipc_sk_publish()
2190 tsk->pub_count++; in tipc_sk_publish()
2191 tsk->published = 1; in tipc_sk_publish()
2195 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, in tipc_sk_withdraw() argument
2198 struct net *net = sock_net(&tsk->sk); in tipc_sk_withdraw()
2203 list_for_each_entry_safe(publ, safe, &tsk->publications, pport_list) { in tipc_sk_withdraw()
2222 if (list_empty(&tsk->publications)) in tipc_sk_withdraw()
2223 tsk->published = 0; in tipc_sk_withdraw()
2235 struct tipc_sock *tsk; in tipc_sk_reinit() local
2242 rht_for_each_entry_rcu(tsk, pos, tbl, i, node) { in tipc_sk_reinit()
2243 spin_lock_bh(&tsk->sk.sk_lock.slock); in tipc_sk_reinit()
2244 msg = &tsk->phdr; in tipc_sk_reinit()
2247 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_sk_reinit()
2256 struct tipc_sock *tsk; in tipc_sk_lookup() local
2259 tsk = rhashtable_lookup_fast(&tn->sk_rht, &portid, tsk_rht_params); in tipc_sk_lookup()
2260 if (tsk) in tipc_sk_lookup()
2261 sock_hold(&tsk->sk); in tipc_sk_lookup()
2264 return tsk; in tipc_sk_lookup()
2267 static int tipc_sk_insert(struct tipc_sock *tsk) in tipc_sk_insert() argument
2269 struct sock *sk = &tsk->sk; in tipc_sk_insert()
2279 tsk->portid = portid; in tipc_sk_insert()
2280 sock_hold(&tsk->sk); in tipc_sk_insert()
2281 if (!rhashtable_lookup_insert_fast(&tn->sk_rht, &tsk->node, in tipc_sk_insert()
2284 sock_put(&tsk->sk); in tipc_sk_insert()
2290 static void tipc_sk_remove(struct tipc_sock *tsk) in tipc_sk_remove() argument
2292 struct sock *sk = &tsk->sk; in tipc_sk_remove()
2295 if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { in tipc_sk_remove()
2345 struct tipc_sock *tsk = tipc_sk(sk); in tipc_setsockopt() local
2363 res = tsk_set_importance(tsk, value); in tipc_setsockopt()
2367 tsk_set_unreliable(tsk, value); in tipc_setsockopt()
2372 tsk_set_unreturnable(tsk, value); in tipc_setsockopt()
2404 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getsockopt() local
2421 value = tsk_importance(tsk); in tipc_getsockopt()
2424 value = tsk_unreliable(tsk); in tipc_getsockopt()
2427 value = tsk_unreturnable(tsk); in tipc_getsockopt()
2430 value = tsk->conn_timeout; in tipc_getsockopt()
2593 static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) in __tipc_nl_add_sk_con() argument
2599 peer_node = tsk_peer_node(tsk); in __tipc_nl_add_sk_con()
2600 peer_port = tsk_peer_port(tsk); in __tipc_nl_add_sk_con()
2609 if (tsk->conn_type != 0) { in __tipc_nl_add_sk_con()
2612 if (nla_put_u32(skb, TIPC_NLA_CON_TYPE, tsk->conn_type)) in __tipc_nl_add_sk_con()
2614 if (nla_put_u32(skb, TIPC_NLA_CON_INST, tsk->conn_instance)) in __tipc_nl_add_sk_con()
2629 struct tipc_sock *tsk) in __tipc_nl_add_sk() argument
2645 if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid)) in __tipc_nl_add_sk()
2650 if (tsk->connected) { in __tipc_nl_add_sk()
2651 err = __tipc_nl_add_sk_con(skb, tsk); in __tipc_nl_add_sk()
2654 } else if (!list_empty(&tsk->publications)) { in __tipc_nl_add_sk()
2674 struct tipc_sock *tsk; in tipc_nl_sk_dump() local
2685 rht_for_each_entry_rcu(tsk, pos, tbl, tbl_id, node) { in tipc_nl_sk_dump()
2686 spin_lock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2687 if (prev_portid && prev_portid != tsk->portid) { in tipc_nl_sk_dump()
2688 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2692 err = __tipc_nl_add_sk(skb, cb, tsk); in tipc_nl_sk_dump()
2694 prev_portid = tsk->portid; in tipc_nl_sk_dump()
2695 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2699 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2752 struct tipc_sock *tsk, u32 *last_publ) in __tipc_nl_list_sk_publ() argument
2758 list_for_each_entry(p, &tsk->publications, pport_list) { in __tipc_nl_list_sk_publ()
2774 p = list_first_entry(&tsk->publications, struct publication, in __tipc_nl_list_sk_publ()
2778 list_for_each_entry_from(p, &tsk->publications, pport_list) { in __tipc_nl_list_sk_publ()
2797 struct tipc_sock *tsk; in tipc_nl_publ_dump() local
2822 tsk = tipc_sk_lookup(net, tsk_portid); in tipc_nl_publ_dump()
2823 if (!tsk) in tipc_nl_publ_dump()
2826 lock_sock(&tsk->sk); in tipc_nl_publ_dump()
2827 err = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ); in tipc_nl_publ_dump()
2830 release_sock(&tsk->sk); in tipc_nl_publ_dump()
2831 sock_put(&tsk->sk); in tipc_nl_publ_dump()